babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4312. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Notify all Observers by calling their respective callback with the given data
  4356. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4357. * @param eventData defines the data to send to all observers
  4358. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4359. * @param target defines the original target of the state
  4360. * @param currentTarget defines the current target of the state
  4361. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4362. */
  4363. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4364. /**
  4365. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4366. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4367. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4368. * and it is crucial that all callbacks will be executed.
  4369. * The order of the callbacks is kept, callbacks are not executed parallel.
  4370. *
  4371. * @param eventData The data to be sent to each callback
  4372. * @param mask is used to filter observers defaults to -1
  4373. * @param target defines the callback target (see EventState)
  4374. * @param currentTarget defines he current object in the bubbling phase
  4375. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4376. */
  4377. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4378. /**
  4379. * Notify a specific observer
  4380. * @param observer defines the observer to notify
  4381. * @param eventData defines the data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. */
  4384. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4385. /**
  4386. * Gets a boolean indicating if the observable has at least one observer
  4387. * @returns true is the Observable has at least one Observer registered
  4388. */
  4389. hasObservers(): boolean;
  4390. /**
  4391. * Clear the list of observers
  4392. */
  4393. clear(): void;
  4394. /**
  4395. * Clone the current observable
  4396. * @returns a new observable
  4397. */
  4398. clone(): Observable<T>;
  4399. /**
  4400. * Does this observable handles observer registered with a given mask
  4401. * @param mask defines the mask to be tested
  4402. * @return whether or not one observer registered with the given mask is handeled
  4403. **/
  4404. hasSpecificMask(mask?: number): boolean;
  4405. }
  4406. }
  4407. declare module "babylonjs/Misc/filesInputStore" {
  4408. /**
  4409. * Class used to help managing file picking and drag'n'drop
  4410. * File Storage
  4411. */
  4412. export class FilesInputStore {
  4413. /**
  4414. * List of files ready to be loaded
  4415. */
  4416. static FilesToLoad: {
  4417. [key: string]: File;
  4418. };
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/constants" {
  4422. /** Defines the cross module used constants to avoid circular dependncies */
  4423. export class Constants {
  4424. /** Defines that alpha blending is disabled */
  4425. static readonly ALPHA_DISABLE: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4427. static readonly ALPHA_ADD: number;
  4428. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4429. static readonly ALPHA_COMBINE: number;
  4430. /** Defines that alpha blending to DEST - SRC * DEST */
  4431. static readonly ALPHA_SUBTRACT: number;
  4432. /** Defines that alpha blending to SRC * DEST */
  4433. static readonly ALPHA_MULTIPLY: number;
  4434. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4435. static readonly ALPHA_MAXIMIZED: number;
  4436. /** Defines that alpha blending to SRC + DEST */
  4437. static readonly ALPHA_ONEONE: number;
  4438. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_PREMULTIPLIED: number;
  4440. /**
  4441. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4442. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4443. */
  4444. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4445. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4446. static readonly ALPHA_INTERPOLATE: number;
  4447. /**
  4448. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4449. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4450. */
  4451. static readonly ALPHA_SCREENMODE: number;
  4452. /** Defines that the ressource is not delayed*/
  4453. static readonly DELAYLOADSTATE_NONE: number;
  4454. /** Defines that the ressource was successfully delay loaded */
  4455. static readonly DELAYLOADSTATE_LOADED: number;
  4456. /** Defines that the ressource is currently delay loading */
  4457. static readonly DELAYLOADSTATE_LOADING: number;
  4458. /** Defines that the ressource is delayed and has not started loading */
  4459. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4461. static readonly NEVER: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4463. static readonly ALWAYS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4465. static readonly LESS: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4467. static readonly EQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4469. static readonly LEQUAL: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4471. static readonly GREATER: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4473. static readonly GEQUAL: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4475. static readonly NOTEQUAL: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be kept */
  4477. static readonly KEEP: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4479. static readonly REPLACE: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4481. static readonly INCR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4483. static readonly DECR: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4485. static readonly INVERT: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4487. static readonly INCR_WRAP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4489. static readonly DECR_WRAP: number;
  4490. /** Texture is not repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4492. /** Texture is repeating outside of 0..1 UVs */
  4493. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4494. /** Texture is repeating and mirrored */
  4495. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4496. /** ALPHA */
  4497. static readonly TEXTUREFORMAT_ALPHA: number;
  4498. /** LUMINANCE */
  4499. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4500. /** LUMINANCE_ALPHA */
  4501. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4502. /** RGB */
  4503. static readonly TEXTUREFORMAT_RGB: number;
  4504. /** RGBA */
  4505. static readonly TEXTUREFORMAT_RGBA: number;
  4506. /** RED */
  4507. static readonly TEXTUREFORMAT_RED: number;
  4508. /** RED (2nd reference) */
  4509. static readonly TEXTUREFORMAT_R: number;
  4510. /** RG */
  4511. static readonly TEXTUREFORMAT_RG: number;
  4512. /** RED_INTEGER */
  4513. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4514. /** RED_INTEGER (2nd reference) */
  4515. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4516. /** RG_INTEGER */
  4517. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4518. /** RGB_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4520. /** RGBA_INTEGER */
  4521. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4522. /** UNSIGNED_BYTE */
  4523. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4524. /** UNSIGNED_BYTE (2nd reference) */
  4525. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4526. /** FLOAT */
  4527. static readonly TEXTURETYPE_FLOAT: number;
  4528. /** HALF_FLOAT */
  4529. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4530. /** BYTE */
  4531. static readonly TEXTURETYPE_BYTE: number;
  4532. /** SHORT */
  4533. static readonly TEXTURETYPE_SHORT: number;
  4534. /** UNSIGNED_SHORT */
  4535. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4536. /** INT */
  4537. static readonly TEXTURETYPE_INT: number;
  4538. /** UNSIGNED_INT */
  4539. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4540. /** UNSIGNED_SHORT_4_4_4_4 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4542. /** UNSIGNED_SHORT_5_5_5_1 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4544. /** UNSIGNED_SHORT_5_6_5 */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4546. /** UNSIGNED_INT_2_10_10_10_REV */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4548. /** UNSIGNED_INT_24_8 */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4550. /** UNSIGNED_INT_10F_11F_11F_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4552. /** UNSIGNED_INT_5_9_9_9_REV */
  4553. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4554. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4555. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4556. /** nearest is mag = nearest and min = nearest and mip = linear */
  4557. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4559. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4560. /** Trilinear is mag = linear and min = linear and mip = linear */
  4561. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4562. /** nearest is mag = nearest and min = nearest and mip = linear */
  4563. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4566. /** Trilinear is mag = linear and min = linear and mip = linear */
  4567. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4568. /** mag = nearest and min = nearest and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = nearest */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4572. /** mag = nearest and min = linear and mip = linear */
  4573. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4574. /** mag = nearest and min = linear and mip = none */
  4575. static readonly TEXTURE_NEAREST_LINEAR: number;
  4576. /** mag = nearest and min = nearest and mip = none */
  4577. static readonly TEXTURE_NEAREST_NEAREST: number;
  4578. /** mag = linear and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4580. /** mag = linear and min = nearest and mip = linear */
  4581. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4582. /** mag = linear and min = linear and mip = none */
  4583. static readonly TEXTURE_LINEAR_LINEAR: number;
  4584. /** mag = linear and min = nearest and mip = none */
  4585. static readonly TEXTURE_LINEAR_NEAREST: number;
  4586. /** Explicit coordinates mode */
  4587. static readonly TEXTURE_EXPLICIT_MODE: number;
  4588. /** Spherical coordinates mode */
  4589. static readonly TEXTURE_SPHERICAL_MODE: number;
  4590. /** Planar coordinates mode */
  4591. static readonly TEXTURE_PLANAR_MODE: number;
  4592. /** Cubic coordinates mode */
  4593. static readonly TEXTURE_CUBIC_MODE: number;
  4594. /** Projection coordinates mode */
  4595. static readonly TEXTURE_PROJECTION_MODE: number;
  4596. /** Skybox coordinates mode */
  4597. static readonly TEXTURE_SKYBOX_MODE: number;
  4598. /** Inverse Cubic coordinates mode */
  4599. static readonly TEXTURE_INVCUBIC_MODE: number;
  4600. /** Equirectangular coordinates mode */
  4601. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4604. /** Equirectangular Fixed Mirrored coordinates mode */
  4605. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4606. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4607. static readonly SCALEMODE_FLOOR: number;
  4608. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4609. static readonly SCALEMODE_NEAREST: number;
  4610. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4611. static readonly SCALEMODE_CEILING: number;
  4612. /**
  4613. * The dirty texture flag value
  4614. */
  4615. static readonly MATERIAL_TextureDirtyFlag: number;
  4616. /**
  4617. * The dirty light flag value
  4618. */
  4619. static readonly MATERIAL_LightDirtyFlag: number;
  4620. /**
  4621. * The dirty fresnel flag value
  4622. */
  4623. static readonly MATERIAL_FresnelDirtyFlag: number;
  4624. /**
  4625. * The dirty attribute flag value
  4626. */
  4627. static readonly MATERIAL_AttributesDirtyFlag: number;
  4628. /**
  4629. * The dirty misc flag value
  4630. */
  4631. static readonly MATERIAL_MiscDirtyFlag: number;
  4632. /**
  4633. * The all dirty flag value
  4634. */
  4635. static readonly MATERIAL_AllDirtyFlag: number;
  4636. /**
  4637. * Returns the triangle fill mode
  4638. */
  4639. static readonly MATERIAL_TriangleFillMode: number;
  4640. /**
  4641. * Returns the wireframe mode
  4642. */
  4643. static readonly MATERIAL_WireFrameFillMode: number;
  4644. /**
  4645. * Returns the point fill mode
  4646. */
  4647. static readonly MATERIAL_PointFillMode: number;
  4648. /**
  4649. * Returns the point list draw mode
  4650. */
  4651. static readonly MATERIAL_PointListDrawMode: number;
  4652. /**
  4653. * Returns the line list draw mode
  4654. */
  4655. static readonly MATERIAL_LineListDrawMode: number;
  4656. /**
  4657. * Returns the line loop draw mode
  4658. */
  4659. static readonly MATERIAL_LineLoopDrawMode: number;
  4660. /**
  4661. * Returns the line strip draw mode
  4662. */
  4663. static readonly MATERIAL_LineStripDrawMode: number;
  4664. /**
  4665. * Returns the triangle strip draw mode
  4666. */
  4667. static readonly MATERIAL_TriangleStripDrawMode: number;
  4668. /**
  4669. * Returns the triangle fan draw mode
  4670. */
  4671. static readonly MATERIAL_TriangleFanDrawMode: number;
  4672. /**
  4673. * Stores the clock-wise side orientation
  4674. */
  4675. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4676. /**
  4677. * Stores the counter clock-wise side orientation
  4678. */
  4679. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4680. /**
  4681. * Nothing
  4682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4683. */
  4684. static readonly ACTION_NothingTrigger: number;
  4685. /**
  4686. * On pick
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_OnPickTrigger: number;
  4690. /**
  4691. * On left pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnLeftPickTrigger: number;
  4695. /**
  4696. * On right pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnRightPickTrigger: number;
  4700. /**
  4701. * On center pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnCenterPickTrigger: number;
  4705. /**
  4706. * On pick down
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnPickDownTrigger: number;
  4710. /**
  4711. * On double pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnDoublePickTrigger: number;
  4715. /**
  4716. * On pick up
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickUpTrigger: number;
  4720. /**
  4721. * On pick out.
  4722. * This trigger will only be raised if you also declared a OnPickDown
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnPickOutTrigger: number;
  4726. /**
  4727. * On long press
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnLongPressTrigger: number;
  4731. /**
  4732. * On pointer over
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPointerOverTrigger: number;
  4736. /**
  4737. * On pointer out
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOutTrigger: number;
  4741. /**
  4742. * On every frame
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnEveryFrameTrigger: number;
  4746. /**
  4747. * On intersection enter
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4751. /**
  4752. * On intersection exit
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionExitTrigger: number;
  4756. /**
  4757. * On key down
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnKeyDownTrigger: number;
  4761. /**
  4762. * On key up
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyUpTrigger: number;
  4766. /**
  4767. * Billboard mode will only apply to Y axis
  4768. */
  4769. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4770. /**
  4771. * Billboard mode will apply to all axes
  4772. */
  4773. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4774. /**
  4775. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4776. */
  4777. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4778. /**
  4779. * Gets or sets base Assets URL
  4780. */
  4781. static readonly PARTICLES_BaseAssetsUrl: string;
  4782. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4783. * Test order :
  4784. * Is the bounding sphere outside the frustum ?
  4785. * If not, are the bounding box vertices outside the frustum ?
  4786. * It not, then the cullable object is in the frustum.
  4787. */
  4788. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4789. /** Culling strategy : Bounding Sphere Only.
  4790. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4791. * It's also less accurate than the standard because some not visible objects can still be selected.
  4792. * Test : is the bounding sphere outside the frustum ?
  4793. * If not, then the cullable object is in the frustum.
  4794. */
  4795. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4796. /** Culling strategy : Optimistic Inclusion.
  4797. * This in an inclusion test first, then the standard exclusion test.
  4798. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4799. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4800. * Anyway, it's as accurate as the standard strategy.
  4801. * Test :
  4802. * Is the cullable object bounding sphere center in the frustum ?
  4803. * If not, apply the default culling strategy.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4806. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4807. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4808. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4809. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4810. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4816. /**
  4817. * No logging while loading
  4818. */
  4819. static readonly SCENELOADER_NO_LOGGING: number;
  4820. /**
  4821. * Minimal logging while loading
  4822. */
  4823. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4824. /**
  4825. * Summary logging while loading
  4826. */
  4827. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4828. /**
  4829. * Detailled logging while loading
  4830. */
  4831. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4832. }
  4833. }
  4834. declare module "babylonjs/Misc/domManagement" {
  4835. /**
  4836. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4837. * Babylon.js
  4838. */
  4839. export class DomManagement {
  4840. /**
  4841. * Checks if the window object exists
  4842. * @returns true if the window object exists
  4843. */
  4844. static IsWindowObjectExist(): boolean;
  4845. /**
  4846. * Extracts text content from a DOM element hierarchy
  4847. * @param element defines the root element
  4848. * @returns a string
  4849. */
  4850. static GetDOMTextContent(element: HTMLElement): string;
  4851. }
  4852. }
  4853. declare module "babylonjs/Misc/logger" {
  4854. /**
  4855. * Logger used througouht the application to allow configuration of
  4856. * the log level required for the messages.
  4857. */
  4858. export class Logger {
  4859. /**
  4860. * No log
  4861. */
  4862. static readonly NoneLogLevel: number;
  4863. /**
  4864. * Only message logs
  4865. */
  4866. static readonly MessageLogLevel: number;
  4867. /**
  4868. * Only warning logs
  4869. */
  4870. static readonly WarningLogLevel: number;
  4871. /**
  4872. * Only error logs
  4873. */
  4874. static readonly ErrorLogLevel: number;
  4875. /**
  4876. * All logs
  4877. */
  4878. static readonly AllLogLevel: number;
  4879. private static _LogCache;
  4880. /**
  4881. * Gets a value indicating the number of loading errors
  4882. * @ignorenaming
  4883. */
  4884. static errorsCount: number;
  4885. /**
  4886. * Callback called when a new log is added
  4887. */
  4888. static OnNewCacheEntry: (entry: string) => void;
  4889. private static _AddLogEntry;
  4890. private static _FormatMessage;
  4891. private static _LogDisabled;
  4892. private static _LogEnabled;
  4893. private static _WarnDisabled;
  4894. private static _WarnEnabled;
  4895. private static _ErrorDisabled;
  4896. private static _ErrorEnabled;
  4897. /**
  4898. * Log a message to the console
  4899. */
  4900. static Log: (message: string) => void;
  4901. /**
  4902. * Write a warning message to the console
  4903. */
  4904. static Warn: (message: string) => void;
  4905. /**
  4906. * Write an error message to the console
  4907. */
  4908. static Error: (message: string) => void;
  4909. /**
  4910. * Gets current log cache (list of logs)
  4911. */
  4912. static readonly LogCache: string;
  4913. /**
  4914. * Clears the log cache
  4915. */
  4916. static ClearLogCache(): void;
  4917. /**
  4918. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4919. */
  4920. static LogLevels: number;
  4921. }
  4922. }
  4923. declare module "babylonjs/Misc/typeStore" {
  4924. /** @hidden */
  4925. export class _TypeStore {
  4926. /** @hidden */
  4927. static RegisteredTypes: {
  4928. [key: string]: Object;
  4929. };
  4930. /** @hidden */
  4931. static GetClass(fqdn: string): any;
  4932. }
  4933. }
  4934. declare module "babylonjs/Misc/deepCopier" {
  4935. /**
  4936. * Class containing a set of static utilities functions for deep copy.
  4937. */
  4938. export class DeepCopier {
  4939. /**
  4940. * Tries to copy an object by duplicating every property
  4941. * @param source defines the source object
  4942. * @param destination defines the target object
  4943. * @param doNotCopyList defines a list of properties to avoid
  4944. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4945. */
  4946. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4947. }
  4948. }
  4949. declare module "babylonjs/Misc/precisionDate" {
  4950. /**
  4951. * Class containing a set of static utilities functions for precision date
  4952. */
  4953. export class PrecisionDate {
  4954. /**
  4955. * Gets either window.performance.now() if supported or Date.now() else
  4956. */
  4957. static readonly Now: number;
  4958. }
  4959. }
  4960. declare module "babylonjs/Misc/devTools" {
  4961. /** @hidden */
  4962. export class _DevTools {
  4963. static WarnImport(name: string): string;
  4964. }
  4965. }
  4966. declare module "babylonjs/Misc/andOrNotEvaluator" {
  4967. /**
  4968. * Class used to evalaute queries containing `and` and `or` operators
  4969. */
  4970. export class AndOrNotEvaluator {
  4971. /**
  4972. * Evaluate a query
  4973. * @param query defines the query to evaluate
  4974. * @param evaluateCallback defines the callback used to filter result
  4975. * @returns true if the query matches
  4976. */
  4977. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4978. private static _HandleParenthesisContent;
  4979. private static _SimplifyNegation;
  4980. }
  4981. }
  4982. declare module "babylonjs/Misc/tags" {
  4983. /**
  4984. * Class used to store custom tags
  4985. */
  4986. export class Tags {
  4987. /**
  4988. * Adds support for tags on the given object
  4989. * @param obj defines the object to use
  4990. */
  4991. static EnableFor(obj: any): void;
  4992. /**
  4993. * Removes tags support
  4994. * @param obj defines the object to use
  4995. */
  4996. static DisableFor(obj: any): void;
  4997. /**
  4998. * Gets a boolean indicating if the given object has tags
  4999. * @param obj defines the object to use
  5000. * @returns a boolean
  5001. */
  5002. static HasTags(obj: any): boolean;
  5003. /**
  5004. * Gets the tags available on a given object
  5005. * @param obj defines the object to use
  5006. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5007. * @returns the tags
  5008. */
  5009. static GetTags(obj: any, asString?: boolean): any;
  5010. /**
  5011. * Adds tags to an object
  5012. * @param obj defines the object to use
  5013. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5014. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5015. */
  5016. static AddTagsTo(obj: any, tagsString: string): void;
  5017. /**
  5018. * @hidden
  5019. */
  5020. static _AddTagTo(obj: any, tag: string): void;
  5021. /**
  5022. * Removes specific tags from a specific object
  5023. * @param obj defines the object to use
  5024. * @param tagsString defines the tags to remove
  5025. */
  5026. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5027. /**
  5028. * @hidden
  5029. */
  5030. static _RemoveTagFrom(obj: any, tag: string): void;
  5031. /**
  5032. * Defines if tags hosted on an object match a given query
  5033. * @param obj defines the object to use
  5034. * @param tagsQuery defines the tag query
  5035. * @returns a boolean
  5036. */
  5037. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5038. }
  5039. }
  5040. declare module "babylonjs/Materials/materialDefines" {
  5041. /**
  5042. * Manages the defines for the Material
  5043. */
  5044. export class MaterialDefines {
  5045. private _keys;
  5046. private _isDirty;
  5047. /** @hidden */
  5048. _renderId: number;
  5049. /** @hidden */
  5050. _areLightsDirty: boolean;
  5051. /** @hidden */
  5052. _areAttributesDirty: boolean;
  5053. /** @hidden */
  5054. _areTexturesDirty: boolean;
  5055. /** @hidden */
  5056. _areFresnelDirty: boolean;
  5057. /** @hidden */
  5058. _areMiscDirty: boolean;
  5059. /** @hidden */
  5060. _areImageProcessingDirty: boolean;
  5061. /** @hidden */
  5062. _normals: boolean;
  5063. /** @hidden */
  5064. _uvs: boolean;
  5065. /** @hidden */
  5066. _needNormals: boolean;
  5067. /** @hidden */
  5068. _needUVs: boolean;
  5069. /**
  5070. * Specifies if the material needs to be re-calculated
  5071. */
  5072. readonly isDirty: boolean;
  5073. /**
  5074. * Marks the material to indicate that it has been re-calculated
  5075. */
  5076. markAsProcessed(): void;
  5077. /**
  5078. * Marks the material to indicate that it needs to be re-calculated
  5079. */
  5080. markAsUnprocessed(): void;
  5081. /**
  5082. * Marks the material to indicate all of its defines need to be re-calculated
  5083. */
  5084. markAllAsDirty(): void;
  5085. /**
  5086. * Marks the material to indicate that image processing needs to be re-calculated
  5087. */
  5088. markAsImageProcessingDirty(): void;
  5089. /**
  5090. * Marks the material to indicate the lights need to be re-calculated
  5091. */
  5092. markAsLightDirty(): void;
  5093. /**
  5094. * Marks the attribute state as changed
  5095. */
  5096. markAsAttributesDirty(): void;
  5097. /**
  5098. * Marks the texture state as changed
  5099. */
  5100. markAsTexturesDirty(): void;
  5101. /**
  5102. * Marks the fresnel state as changed
  5103. */
  5104. markAsFresnelDirty(): void;
  5105. /**
  5106. * Marks the misc state as changed
  5107. */
  5108. markAsMiscDirty(): void;
  5109. /**
  5110. * Rebuilds the material defines
  5111. */
  5112. rebuild(): void;
  5113. /**
  5114. * Specifies if two material defines are equal
  5115. * @param other - A material define instance to compare to
  5116. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5117. */
  5118. isEqual(other: MaterialDefines): boolean;
  5119. /**
  5120. * Clones this instance's defines to another instance
  5121. * @param other - material defines to clone values to
  5122. */
  5123. cloneTo(other: MaterialDefines): void;
  5124. /**
  5125. * Resets the material define values
  5126. */
  5127. reset(): void;
  5128. /**
  5129. * Converts the material define values to a string
  5130. * @returns - String of material define information
  5131. */
  5132. toString(): string;
  5133. }
  5134. }
  5135. declare module "babylonjs/Misc/performanceMonitor" {
  5136. /**
  5137. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5138. */
  5139. export class PerformanceMonitor {
  5140. private _enabled;
  5141. private _rollingFrameTime;
  5142. private _lastFrameTimeMs;
  5143. /**
  5144. * constructor
  5145. * @param frameSampleSize The number of samples required to saturate the sliding window
  5146. */
  5147. constructor(frameSampleSize?: number);
  5148. /**
  5149. * Samples current frame
  5150. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5151. */
  5152. sampleFrame(timeMs?: number): void;
  5153. /**
  5154. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5155. */
  5156. readonly averageFrameTime: number;
  5157. /**
  5158. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5159. */
  5160. readonly averageFrameTimeVariance: number;
  5161. /**
  5162. * Returns the frame time of the most recent frame
  5163. */
  5164. readonly instantaneousFrameTime: number;
  5165. /**
  5166. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5167. */
  5168. readonly averageFPS: number;
  5169. /**
  5170. * Returns the average framerate in frames per second using the most recent frame time
  5171. */
  5172. readonly instantaneousFPS: number;
  5173. /**
  5174. * Returns true if enough samples have been taken to completely fill the sliding window
  5175. */
  5176. readonly isSaturated: boolean;
  5177. /**
  5178. * Enables contributions to the sliding window sample set
  5179. */
  5180. enable(): void;
  5181. /**
  5182. * Disables contributions to the sliding window sample set
  5183. * Samples will not be interpolated over the disabled period
  5184. */
  5185. disable(): void;
  5186. /**
  5187. * Returns true if sampling is enabled
  5188. */
  5189. readonly isEnabled: boolean;
  5190. /**
  5191. * Resets performance monitor
  5192. */
  5193. reset(): void;
  5194. }
  5195. /**
  5196. * RollingAverage
  5197. *
  5198. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5199. */
  5200. export class RollingAverage {
  5201. /**
  5202. * Current average
  5203. */
  5204. average: number;
  5205. /**
  5206. * Current variance
  5207. */
  5208. variance: number;
  5209. protected _samples: Array<number>;
  5210. protected _sampleCount: number;
  5211. protected _pos: number;
  5212. protected _m2: number;
  5213. /**
  5214. * constructor
  5215. * @param length The number of samples required to saturate the sliding window
  5216. */
  5217. constructor(length: number);
  5218. /**
  5219. * Adds a sample to the sample set
  5220. * @param v The sample value
  5221. */
  5222. add(v: number): void;
  5223. /**
  5224. * Returns previously added values or null if outside of history or outside the sliding window domain
  5225. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5226. * @return Value previously recorded with add() or null if outside of range
  5227. */
  5228. history(i: number): number;
  5229. /**
  5230. * Returns true if enough samples have been taken to completely fill the sliding window
  5231. * @return true if sample-set saturated
  5232. */
  5233. isSaturated(): boolean;
  5234. /**
  5235. * Resets the rolling average (equivalent to 0 samples taken so far)
  5236. */
  5237. reset(): void;
  5238. /**
  5239. * Wraps a value around the sample range boundaries
  5240. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5241. * @return Wrapped position in sample range
  5242. */
  5243. protected _wrapPosition(i: number): number;
  5244. }
  5245. }
  5246. declare module "babylonjs/Misc/stringDictionary" {
  5247. import { Nullable } from "babylonjs/types";
  5248. /**
  5249. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5250. * The underlying implementation relies on an associative array to ensure the best performances.
  5251. * The value can be anything including 'null' but except 'undefined'
  5252. */
  5253. export class StringDictionary<T> {
  5254. /**
  5255. * This will clear this dictionary and copy the content from the 'source' one.
  5256. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5257. * @param source the dictionary to take the content from and copy to this dictionary
  5258. */
  5259. copyFrom(source: StringDictionary<T>): void;
  5260. /**
  5261. * Get a value based from its key
  5262. * @param key the given key to get the matching value from
  5263. * @return the value if found, otherwise undefined is returned
  5264. */
  5265. get(key: string): T | undefined;
  5266. /**
  5267. * Get a value from its key or add it if it doesn't exist.
  5268. * This method will ensure you that a given key/data will be present in the dictionary.
  5269. * @param key the given key to get the matching value from
  5270. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5271. * The factory will only be invoked if there's no data for the given key.
  5272. * @return the value corresponding to the key.
  5273. */
  5274. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5275. /**
  5276. * Get a value from its key if present in the dictionary otherwise add it
  5277. * @param key the key to get the value from
  5278. * @param val if there's no such key/value pair in the dictionary add it with this value
  5279. * @return the value corresponding to the key
  5280. */
  5281. getOrAdd(key: string, val: T): T;
  5282. /**
  5283. * Check if there's a given key in the dictionary
  5284. * @param key the key to check for
  5285. * @return true if the key is present, false otherwise
  5286. */
  5287. contains(key: string): boolean;
  5288. /**
  5289. * Add a new key and its corresponding value
  5290. * @param key the key to add
  5291. * @param value the value corresponding to the key
  5292. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5293. */
  5294. add(key: string, value: T): boolean;
  5295. /**
  5296. * Update a specific value associated to a key
  5297. * @param key defines the key to use
  5298. * @param value defines the value to store
  5299. * @returns true if the value was updated (or false if the key was not found)
  5300. */
  5301. set(key: string, value: T): boolean;
  5302. /**
  5303. * Get the element of the given key and remove it from the dictionary
  5304. * @param key defines the key to search
  5305. * @returns the value associated with the key or null if not found
  5306. */
  5307. getAndRemove(key: string): Nullable<T>;
  5308. /**
  5309. * Remove a key/value from the dictionary.
  5310. * @param key the key to remove
  5311. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5312. */
  5313. remove(key: string): boolean;
  5314. /**
  5315. * Clear the whole content of the dictionary
  5316. */
  5317. clear(): void;
  5318. /**
  5319. * Gets the current count
  5320. */
  5321. readonly count: number;
  5322. /**
  5323. * Execute a callback on each key/val of the dictionary.
  5324. * Note that you can remove any element in this dictionary in the callback implementation
  5325. * @param callback the callback to execute on a given key/value pair
  5326. */
  5327. forEach(callback: (key: string, val: T) => void): void;
  5328. /**
  5329. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5330. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5331. * Note that you can remove any element in this dictionary in the callback implementation
  5332. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5333. * @returns the first item
  5334. */
  5335. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5336. private _count;
  5337. private _data;
  5338. }
  5339. }
  5340. declare module "babylonjs/Misc/promise" {
  5341. /**
  5342. * Helper class that provides a small promise polyfill
  5343. */
  5344. export class PromisePolyfill {
  5345. /**
  5346. * Static function used to check if the polyfill is required
  5347. * If this is the case then the function will inject the polyfill to window.Promise
  5348. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5349. */
  5350. static Apply(force?: boolean): void;
  5351. }
  5352. }
  5353. declare module "babylonjs/Meshes/buffer" {
  5354. import { Nullable, DataArray } from "babylonjs/types";
  5355. /**
  5356. * Class used to store data that will be store in GPU memory
  5357. */
  5358. export class Buffer {
  5359. private _engine;
  5360. private _buffer;
  5361. /** @hidden */
  5362. _data: Nullable<DataArray>;
  5363. private _updatable;
  5364. private _instanced;
  5365. /**
  5366. * Gets the byte stride.
  5367. */
  5368. readonly byteStride: number;
  5369. /**
  5370. * Constructor
  5371. * @param engine the engine
  5372. * @param data the data to use for this buffer
  5373. * @param updatable whether the data is updatable
  5374. * @param stride the stride (optional)
  5375. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5376. * @param instanced whether the buffer is instanced (optional)
  5377. * @param useBytes set to true if the stride in in bytes (optional)
  5378. */
  5379. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5380. /**
  5381. * Create a new VertexBuffer based on the current buffer
  5382. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5383. * @param offset defines offset in the buffer (0 by default)
  5384. * @param size defines the size in floats of attributes (position is 3 for instance)
  5385. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5386. * @param instanced defines if the vertex buffer contains indexed data
  5387. * @param useBytes defines if the offset and stride are in bytes
  5388. * @returns the new vertex buffer
  5389. */
  5390. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5391. /**
  5392. * Gets a boolean indicating if the Buffer is updatable?
  5393. * @returns true if the buffer is updatable
  5394. */
  5395. isUpdatable(): boolean;
  5396. /**
  5397. * Gets current buffer's data
  5398. * @returns a DataArray or null
  5399. */
  5400. getData(): Nullable<DataArray>;
  5401. /**
  5402. * Gets underlying native buffer
  5403. * @returns underlying native buffer
  5404. */
  5405. getBuffer(): Nullable<WebGLBuffer>;
  5406. /**
  5407. * Gets the stride in float32 units (i.e. byte stride / 4).
  5408. * May not be an integer if the byte stride is not divisible by 4.
  5409. * DEPRECATED. Use byteStride instead.
  5410. * @returns the stride in float32 units
  5411. */
  5412. getStrideSize(): number;
  5413. /**
  5414. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5415. * @param data defines the data to store
  5416. */
  5417. create(data?: Nullable<DataArray>): void;
  5418. /** @hidden */
  5419. _rebuild(): void;
  5420. /**
  5421. * Update current buffer data
  5422. * @param data defines the data to store
  5423. */
  5424. update(data: DataArray): void;
  5425. /**
  5426. * Updates the data directly.
  5427. * @param data the new data
  5428. * @param offset the new offset
  5429. * @param vertexCount the vertex count (optional)
  5430. * @param useBytes set to true if the offset is in bytes
  5431. */
  5432. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5433. /**
  5434. * Release all resources
  5435. */
  5436. dispose(): void;
  5437. }
  5438. /**
  5439. * Specialized buffer used to store vertex data
  5440. */
  5441. export class VertexBuffer {
  5442. /** @hidden */
  5443. _buffer: Buffer;
  5444. private _kind;
  5445. private _size;
  5446. private _ownsBuffer;
  5447. private _instanced;
  5448. private _instanceDivisor;
  5449. /**
  5450. * The byte type.
  5451. */
  5452. static readonly BYTE: number;
  5453. /**
  5454. * The unsigned byte type.
  5455. */
  5456. static readonly UNSIGNED_BYTE: number;
  5457. /**
  5458. * The short type.
  5459. */
  5460. static readonly SHORT: number;
  5461. /**
  5462. * The unsigned short type.
  5463. */
  5464. static readonly UNSIGNED_SHORT: number;
  5465. /**
  5466. * The integer type.
  5467. */
  5468. static readonly INT: number;
  5469. /**
  5470. * The unsigned integer type.
  5471. */
  5472. static readonly UNSIGNED_INT: number;
  5473. /**
  5474. * The float type.
  5475. */
  5476. static readonly FLOAT: number;
  5477. /**
  5478. * Gets or sets the instance divisor when in instanced mode
  5479. */
  5480. instanceDivisor: number;
  5481. /**
  5482. * Gets the byte stride.
  5483. */
  5484. readonly byteStride: number;
  5485. /**
  5486. * Gets the byte offset.
  5487. */
  5488. readonly byteOffset: number;
  5489. /**
  5490. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5491. */
  5492. readonly normalized: boolean;
  5493. /**
  5494. * Gets the data type of each component in the array.
  5495. */
  5496. readonly type: number;
  5497. /**
  5498. * Constructor
  5499. * @param engine the engine
  5500. * @param data the data to use for this vertex buffer
  5501. * @param kind the vertex buffer kind
  5502. * @param updatable whether the data is updatable
  5503. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5504. * @param stride the stride (optional)
  5505. * @param instanced whether the buffer is instanced (optional)
  5506. * @param offset the offset of the data (optional)
  5507. * @param size the number of components (optional)
  5508. * @param type the type of the component (optional)
  5509. * @param normalized whether the data contains normalized data (optional)
  5510. * @param useBytes set to true if stride and offset are in bytes (optional)
  5511. */
  5512. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5513. /** @hidden */
  5514. _rebuild(): void;
  5515. /**
  5516. * Returns the kind of the VertexBuffer (string)
  5517. * @returns a string
  5518. */
  5519. getKind(): string;
  5520. /**
  5521. * Gets a boolean indicating if the VertexBuffer is updatable?
  5522. * @returns true if the buffer is updatable
  5523. */
  5524. isUpdatable(): boolean;
  5525. /**
  5526. * Gets current buffer's data
  5527. * @returns a DataArray or null
  5528. */
  5529. getData(): Nullable<DataArray>;
  5530. /**
  5531. * Gets underlying native buffer
  5532. * @returns underlying native buffer
  5533. */
  5534. getBuffer(): Nullable<WebGLBuffer>;
  5535. /**
  5536. * Gets the stride in float32 units (i.e. byte stride / 4).
  5537. * May not be an integer if the byte stride is not divisible by 4.
  5538. * DEPRECATED. Use byteStride instead.
  5539. * @returns the stride in float32 units
  5540. */
  5541. getStrideSize(): number;
  5542. /**
  5543. * Returns the offset as a multiple of the type byte length.
  5544. * DEPRECATED. Use byteOffset instead.
  5545. * @returns the offset in bytes
  5546. */
  5547. getOffset(): number;
  5548. /**
  5549. * Returns the number of components per vertex attribute (integer)
  5550. * @returns the size in float
  5551. */
  5552. getSize(): number;
  5553. /**
  5554. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5555. * @returns true if this buffer is instanced
  5556. */
  5557. getIsInstanced(): boolean;
  5558. /**
  5559. * Returns the instancing divisor, zero for non-instanced (integer).
  5560. * @returns a number
  5561. */
  5562. getInstanceDivisor(): number;
  5563. /**
  5564. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5565. * @param data defines the data to store
  5566. */
  5567. create(data?: DataArray): void;
  5568. /**
  5569. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5570. * This function will create a new buffer if the current one is not updatable
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5576. * Returns the directly updated WebGLBuffer.
  5577. * @param data the new data
  5578. * @param offset the new offset
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5582. /**
  5583. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5584. */
  5585. dispose(): void;
  5586. /**
  5587. * Enumerates each value of this vertex buffer as numbers.
  5588. * @param count the number of values to enumerate
  5589. * @param callback the callback function called for each value
  5590. */
  5591. forEach(count: number, callback: (value: number, index: number) => void): void;
  5592. /**
  5593. * Positions
  5594. */
  5595. static readonly PositionKind: string;
  5596. /**
  5597. * Normals
  5598. */
  5599. static readonly NormalKind: string;
  5600. /**
  5601. * Tangents
  5602. */
  5603. static readonly TangentKind: string;
  5604. /**
  5605. * Texture coordinates
  5606. */
  5607. static readonly UVKind: string;
  5608. /**
  5609. * Texture coordinates 2
  5610. */
  5611. static readonly UV2Kind: string;
  5612. /**
  5613. * Texture coordinates 3
  5614. */
  5615. static readonly UV3Kind: string;
  5616. /**
  5617. * Texture coordinates 4
  5618. */
  5619. static readonly UV4Kind: string;
  5620. /**
  5621. * Texture coordinates 5
  5622. */
  5623. static readonly UV5Kind: string;
  5624. /**
  5625. * Texture coordinates 6
  5626. */
  5627. static readonly UV6Kind: string;
  5628. /**
  5629. * Colors
  5630. */
  5631. static readonly ColorKind: string;
  5632. /**
  5633. * Matrix indices (for bones)
  5634. */
  5635. static readonly MatricesIndicesKind: string;
  5636. /**
  5637. * Matrix weights (for bones)
  5638. */
  5639. static readonly MatricesWeightsKind: string;
  5640. /**
  5641. * Additional matrix indices (for bones)
  5642. */
  5643. static readonly MatricesIndicesExtraKind: string;
  5644. /**
  5645. * Additional matrix weights (for bones)
  5646. */
  5647. static readonly MatricesWeightsExtraKind: string;
  5648. /**
  5649. * Deduces the stride given a kind.
  5650. * @param kind The kind string to deduce
  5651. * @returns The deduced stride
  5652. */
  5653. static DeduceStride(kind: string): number;
  5654. /**
  5655. * Gets the byte length of the given type.
  5656. * @param type the type
  5657. * @returns the number of bytes
  5658. */
  5659. static GetTypeByteLength(type: number): number;
  5660. /**
  5661. * Enumerates each value of the given parameters as numbers.
  5662. * @param data the data to enumerate
  5663. * @param byteOffset the byte offset of the data
  5664. * @param byteStride the byte stride of the data
  5665. * @param componentCount the number of components per element
  5666. * @param componentType the type of the component
  5667. * @param count the total number of components
  5668. * @param normalized whether the data is normalized
  5669. * @param callback the callback function called for each value
  5670. */
  5671. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5672. private static _GetFloatValue;
  5673. }
  5674. }
  5675. declare module "babylonjs/Maths/sphericalPolynomial" {
  5676. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5677. /**
  5678. * Class representing spherical polynomial coefficients to the 3rd degree
  5679. */
  5680. export class SphericalPolynomial {
  5681. /**
  5682. * The x coefficients of the spherical polynomial
  5683. */
  5684. x: Vector3;
  5685. /**
  5686. * The y coefficients of the spherical polynomial
  5687. */
  5688. y: Vector3;
  5689. /**
  5690. * The z coefficients of the spherical polynomial
  5691. */
  5692. z: Vector3;
  5693. /**
  5694. * The xx coefficients of the spherical polynomial
  5695. */
  5696. xx: Vector3;
  5697. /**
  5698. * The yy coefficients of the spherical polynomial
  5699. */
  5700. yy: Vector3;
  5701. /**
  5702. * The zz coefficients of the spherical polynomial
  5703. */
  5704. zz: Vector3;
  5705. /**
  5706. * The xy coefficients of the spherical polynomial
  5707. */
  5708. xy: Vector3;
  5709. /**
  5710. * The yz coefficients of the spherical polynomial
  5711. */
  5712. yz: Vector3;
  5713. /**
  5714. * The zx coefficients of the spherical polynomial
  5715. */
  5716. zx: Vector3;
  5717. /**
  5718. * Adds an ambient color to the spherical polynomial
  5719. * @param color the color to add
  5720. */
  5721. addAmbient(color: Color3): void;
  5722. /**
  5723. * Scales the spherical polynomial by the given amount
  5724. * @param scale the amount to scale
  5725. */
  5726. scale(scale: number): void;
  5727. /**
  5728. * Gets the spherical polynomial from harmonics
  5729. * @param harmonics the spherical harmonics
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5733. /**
  5734. * Constructs a spherical polynomial from an array.
  5735. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5736. * @returns the spherical polynomial
  5737. */
  5738. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5739. }
  5740. /**
  5741. * Class representing spherical harmonics coefficients to the 3rd degree
  5742. */
  5743. export class SphericalHarmonics {
  5744. /**
  5745. * The l0,0 coefficients of the spherical harmonics
  5746. */
  5747. l00: Vector3;
  5748. /**
  5749. * The l1,-1 coefficients of the spherical harmonics
  5750. */
  5751. l1_1: Vector3;
  5752. /**
  5753. * The l1,0 coefficients of the spherical harmonics
  5754. */
  5755. l10: Vector3;
  5756. /**
  5757. * The l1,1 coefficients of the spherical harmonics
  5758. */
  5759. l11: Vector3;
  5760. /**
  5761. * The l2,-2 coefficients of the spherical harmonics
  5762. */
  5763. l2_2: Vector3;
  5764. /**
  5765. * The l2,-1 coefficients of the spherical harmonics
  5766. */
  5767. l2_1: Vector3;
  5768. /**
  5769. * The l2,0 coefficients of the spherical harmonics
  5770. */
  5771. l20: Vector3;
  5772. /**
  5773. * The l2,1 coefficients of the spherical harmonics
  5774. */
  5775. l21: Vector3;
  5776. /**
  5777. * The l2,2 coefficients of the spherical harmonics
  5778. */
  5779. lL22: Vector3;
  5780. /**
  5781. * Adds a light to the spherical harmonics
  5782. * @param direction the direction of the light
  5783. * @param color the color of the light
  5784. * @param deltaSolidAngle the delta solid angle of the light
  5785. */
  5786. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5787. /**
  5788. * Scales the spherical harmonics by the given amount
  5789. * @param scale the amount to scale
  5790. */
  5791. scale(scale: number): void;
  5792. /**
  5793. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5794. *
  5795. * ```
  5796. * E_lm = A_l * L_lm
  5797. * ```
  5798. *
  5799. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5800. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5801. * the scaling factors are given in equation 9.
  5802. */
  5803. convertIncidentRadianceToIrradiance(): void;
  5804. /**
  5805. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5806. *
  5807. * ```
  5808. * L = (1/pi) * E * rho
  5809. * ```
  5810. *
  5811. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5812. */
  5813. convertIrradianceToLambertianRadiance(): void;
  5814. /**
  5815. * Gets the spherical harmonics from polynomial
  5816. * @param polynomial the spherical polynomial
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5820. /**
  5821. * Constructs a spherical harmonics from an array.
  5822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5823. * @returns the spherical harmonics
  5824. */
  5825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5826. }
  5827. }
  5828. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5829. import { Nullable } from "babylonjs/types";
  5830. /**
  5831. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5832. */
  5833. export interface CubeMapInfo {
  5834. /**
  5835. * The pixel array for the front face.
  5836. * This is stored in format, left to right, up to down format.
  5837. */
  5838. front: Nullable<ArrayBufferView>;
  5839. /**
  5840. * The pixel array for the back face.
  5841. * This is stored in format, left to right, up to down format.
  5842. */
  5843. back: Nullable<ArrayBufferView>;
  5844. /**
  5845. * The pixel array for the left face.
  5846. * This is stored in format, left to right, up to down format.
  5847. */
  5848. left: Nullable<ArrayBufferView>;
  5849. /**
  5850. * The pixel array for the right face.
  5851. * This is stored in format, left to right, up to down format.
  5852. */
  5853. right: Nullable<ArrayBufferView>;
  5854. /**
  5855. * The pixel array for the up face.
  5856. * This is stored in format, left to right, up to down format.
  5857. */
  5858. up: Nullable<ArrayBufferView>;
  5859. /**
  5860. * The pixel array for the down face.
  5861. * This is stored in format, left to right, up to down format.
  5862. */
  5863. down: Nullable<ArrayBufferView>;
  5864. /**
  5865. * The size of the cubemap stored.
  5866. *
  5867. * Each faces will be size * size pixels.
  5868. */
  5869. size: number;
  5870. /**
  5871. * The format of the texture.
  5872. *
  5873. * RGBA, RGB.
  5874. */
  5875. format: number;
  5876. /**
  5877. * The type of the texture data.
  5878. *
  5879. * UNSIGNED_INT, FLOAT.
  5880. */
  5881. type: number;
  5882. /**
  5883. * Specifies whether the texture is in gamma space.
  5884. */
  5885. gammaSpace: boolean;
  5886. }
  5887. /**
  5888. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5889. */
  5890. export class PanoramaToCubeMapTools {
  5891. private static FACE_FRONT;
  5892. private static FACE_BACK;
  5893. private static FACE_RIGHT;
  5894. private static FACE_LEFT;
  5895. private static FACE_DOWN;
  5896. private static FACE_UP;
  5897. /**
  5898. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5899. *
  5900. * @param float32Array The source data.
  5901. * @param inputWidth The width of the input panorama.
  5902. * @param inputHeight The height of the input panorama.
  5903. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5904. * @return The cubemap data
  5905. */
  5906. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5907. private static CreateCubemapTexture;
  5908. private static CalcProjectionSpherical;
  5909. }
  5910. }
  5911. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5912. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5914. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5915. /**
  5916. * Helper class dealing with the extraction of spherical polynomial dataArray
  5917. * from a cube map.
  5918. */
  5919. export class CubeMapToSphericalPolynomialTools {
  5920. private static FileFaces;
  5921. /**
  5922. * Converts a texture to the according Spherical Polynomial data.
  5923. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5924. *
  5925. * @param texture The texture to extract the information from.
  5926. * @return The Spherical Polynomial data.
  5927. */
  5928. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5929. /**
  5930. * Converts a cubemap to the according Spherical Polynomial data.
  5931. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5932. *
  5933. * @param cubeInfo The Cube map to extract the information from.
  5934. * @return The Spherical Polynomial data.
  5935. */
  5936. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5937. }
  5938. }
  5939. declare module "babylonjs/Engines/engineStore" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Engine } from "babylonjs/Engines/engine";
  5942. import { Scene } from "babylonjs/scene";
  5943. /**
  5944. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5945. * during the life time of the application.
  5946. */
  5947. export class EngineStore {
  5948. /** Gets the list of created engines */
  5949. static Instances: import("babylonjs/Engines/engine").Engine[];
  5950. /**
  5951. * Gets the latest created engine
  5952. */
  5953. static readonly LastCreatedEngine: Nullable<Engine>;
  5954. /**
  5955. * Gets the latest created scene
  5956. */
  5957. static readonly LastCreatedScene: Nullable<Scene>;
  5958. }
  5959. }
  5960. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5961. /**
  5962. * Define options used to create a render target texture
  5963. */
  5964. export class RenderTargetCreationOptions {
  5965. /**
  5966. * Specifies is mipmaps must be generated
  5967. */
  5968. generateMipMaps?: boolean;
  5969. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5970. generateDepthBuffer?: boolean;
  5971. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5972. generateStencilBuffer?: boolean;
  5973. /** Defines texture type (int by default) */
  5974. type?: number;
  5975. /** Defines sampling mode (trilinear by default) */
  5976. samplingMode?: number;
  5977. /** Defines format (RGBA by default) */
  5978. format?: number;
  5979. }
  5980. }
  5981. declare module "babylonjs/States/alphaCullingState" {
  5982. /**
  5983. * @hidden
  5984. **/
  5985. export class _AlphaState {
  5986. private _isAlphaBlendDirty;
  5987. private _isBlendFunctionParametersDirty;
  5988. private _isBlendEquationParametersDirty;
  5989. private _isBlendConstantsDirty;
  5990. private _alphaBlend;
  5991. private _blendFunctionParameters;
  5992. private _blendEquationParameters;
  5993. private _blendConstants;
  5994. /**
  5995. * Initializes the state.
  5996. */
  5997. constructor();
  5998. readonly isDirty: boolean;
  5999. alphaBlend: boolean;
  6000. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6001. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6002. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6003. reset(): void;
  6004. apply(gl: WebGLRenderingContext): void;
  6005. }
  6006. }
  6007. declare module "babylonjs/States/depthCullingState" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * @hidden
  6011. **/
  6012. export class _DepthCullingState {
  6013. private _isDepthTestDirty;
  6014. private _isDepthMaskDirty;
  6015. private _isDepthFuncDirty;
  6016. private _isCullFaceDirty;
  6017. private _isCullDirty;
  6018. private _isZOffsetDirty;
  6019. private _isFrontFaceDirty;
  6020. private _depthTest;
  6021. private _depthMask;
  6022. private _depthFunc;
  6023. private _cull;
  6024. private _cullFace;
  6025. private _zOffset;
  6026. private _frontFace;
  6027. /**
  6028. * Initializes the state.
  6029. */
  6030. constructor();
  6031. readonly isDirty: boolean;
  6032. zOffset: number;
  6033. cullFace: Nullable<number>;
  6034. cull: Nullable<boolean>;
  6035. depthFunc: Nullable<number>;
  6036. depthMask: boolean;
  6037. depthTest: boolean;
  6038. frontFace: Nullable<number>;
  6039. reset(): void;
  6040. apply(gl: WebGLRenderingContext): void;
  6041. }
  6042. }
  6043. declare module "babylonjs/States/stencilState" {
  6044. /**
  6045. * @hidden
  6046. **/
  6047. export class _StencilState {
  6048. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6049. static readonly ALWAYS: number;
  6050. /** Passed to stencilOperation to specify that stencil value must be kept */
  6051. static readonly KEEP: number;
  6052. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6053. static readonly REPLACE: number;
  6054. private _isStencilTestDirty;
  6055. private _isStencilMaskDirty;
  6056. private _isStencilFuncDirty;
  6057. private _isStencilOpDirty;
  6058. private _stencilTest;
  6059. private _stencilMask;
  6060. private _stencilFunc;
  6061. private _stencilFuncRef;
  6062. private _stencilFuncMask;
  6063. private _stencilOpStencilFail;
  6064. private _stencilOpDepthFail;
  6065. private _stencilOpStencilDepthPass;
  6066. readonly isDirty: boolean;
  6067. stencilFunc: number;
  6068. stencilFuncRef: number;
  6069. stencilFuncMask: number;
  6070. stencilOpStencilFail: number;
  6071. stencilOpDepthFail: number;
  6072. stencilOpStencilDepthPass: number;
  6073. stencilMask: number;
  6074. stencilTest: boolean;
  6075. constructor();
  6076. reset(): void;
  6077. apply(gl: WebGLRenderingContext): void;
  6078. }
  6079. }
  6080. declare module "babylonjs/States/index" {
  6081. export * from "babylonjs/States/alphaCullingState";
  6082. export * from "babylonjs/States/depthCullingState";
  6083. export * from "babylonjs/States/stencilState";
  6084. }
  6085. declare module "babylonjs/Instrumentation/timeToken" {
  6086. import { Nullable } from "babylonjs/types";
  6087. /**
  6088. * @hidden
  6089. **/
  6090. export class _TimeToken {
  6091. _startTimeQuery: Nullable<WebGLQuery>;
  6092. _endTimeQuery: Nullable<WebGLQuery>;
  6093. _timeElapsedQuery: Nullable<WebGLQuery>;
  6094. _timeElapsedQueryEnded: boolean;
  6095. }
  6096. }
  6097. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6098. import { Nullable } from "babylonjs/types";
  6099. /**
  6100. * Internal interface used to track InternalTexture already bound to the GL context
  6101. */
  6102. export interface IInternalTextureTracker {
  6103. /**
  6104. * Gets or set the previous tracker in the list
  6105. */
  6106. previous: Nullable<IInternalTextureTracker>;
  6107. /**
  6108. * Gets or set the next tracker in the list
  6109. */
  6110. next: Nullable<IInternalTextureTracker>;
  6111. }
  6112. /**
  6113. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6114. */
  6115. export class DummyInternalTextureTracker {
  6116. /**
  6117. * Gets or set the previous tracker in the list
  6118. */
  6119. previous: Nullable<IInternalTextureTracker>;
  6120. /**
  6121. * Gets or set the next tracker in the list
  6122. */
  6123. next: Nullable<IInternalTextureTracker>;
  6124. }
  6125. }
  6126. declare module "babylonjs/Materials/Textures/internalTexture" {
  6127. import { Observable } from "babylonjs/Misc/observable";
  6128. import { Nullable, int } from "babylonjs/types";
  6129. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6130. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6131. import { Engine } from "babylonjs/Engines/engine";
  6132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6133. /**
  6134. * Class used to store data associated with WebGL texture data for the engine
  6135. * This class should not be used directly
  6136. */
  6137. export class InternalTexture implements IInternalTextureTracker {
  6138. /** hidden */
  6139. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6140. /**
  6141. * The source of the texture data is unknown
  6142. */
  6143. static DATASOURCE_UNKNOWN: number;
  6144. /**
  6145. * Texture data comes from an URL
  6146. */
  6147. static DATASOURCE_URL: number;
  6148. /**
  6149. * Texture data is only used for temporary storage
  6150. */
  6151. static DATASOURCE_TEMP: number;
  6152. /**
  6153. * Texture data comes from raw data (ArrayBuffer)
  6154. */
  6155. static DATASOURCE_RAW: number;
  6156. /**
  6157. * Texture content is dynamic (video or dynamic texture)
  6158. */
  6159. static DATASOURCE_DYNAMIC: number;
  6160. /**
  6161. * Texture content is generated by rendering to it
  6162. */
  6163. static DATASOURCE_RENDERTARGET: number;
  6164. /**
  6165. * Texture content is part of a multi render target process
  6166. */
  6167. static DATASOURCE_MULTIRENDERTARGET: number;
  6168. /**
  6169. * Texture data comes from a cube data file
  6170. */
  6171. static DATASOURCE_CUBE: number;
  6172. /**
  6173. * Texture data comes from a raw cube data
  6174. */
  6175. static DATASOURCE_CUBERAW: number;
  6176. /**
  6177. * Texture data come from a prefiltered cube data file
  6178. */
  6179. static DATASOURCE_CUBEPREFILTERED: number;
  6180. /**
  6181. * Texture content is raw 3D data
  6182. */
  6183. static DATASOURCE_RAW3D: number;
  6184. /**
  6185. * Texture content is a depth texture
  6186. */
  6187. static DATASOURCE_DEPTHTEXTURE: number;
  6188. /**
  6189. * Texture data comes from a raw cube data encoded with RGBD
  6190. */
  6191. static DATASOURCE_CUBERAW_RGBD: number;
  6192. /**
  6193. * Defines if the texture is ready
  6194. */
  6195. isReady: boolean;
  6196. /**
  6197. * Defines if the texture is a cube texture
  6198. */
  6199. isCube: boolean;
  6200. /**
  6201. * Defines if the texture contains 3D data
  6202. */
  6203. is3D: boolean;
  6204. /**
  6205. * Gets the URL used to load this texture
  6206. */
  6207. url: string;
  6208. /**
  6209. * Gets the sampling mode of the texture
  6210. */
  6211. samplingMode: number;
  6212. /**
  6213. * Gets a boolean indicating if the texture needs mipmaps generation
  6214. */
  6215. generateMipMaps: boolean;
  6216. /**
  6217. * Gets the number of samples used by the texture (WebGL2+ only)
  6218. */
  6219. samples: number;
  6220. /**
  6221. * Gets the type of the texture (int, float...)
  6222. */
  6223. type: number;
  6224. /**
  6225. * Gets the format of the texture (RGB, RGBA...)
  6226. */
  6227. format: number;
  6228. /**
  6229. * Observable called when the texture is loaded
  6230. */
  6231. onLoadedObservable: Observable<InternalTexture>;
  6232. /**
  6233. * Gets the width of the texture
  6234. */
  6235. width: number;
  6236. /**
  6237. * Gets the height of the texture
  6238. */
  6239. height: number;
  6240. /**
  6241. * Gets the depth of the texture
  6242. */
  6243. depth: number;
  6244. /**
  6245. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6246. */
  6247. baseWidth: number;
  6248. /**
  6249. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6250. */
  6251. baseHeight: number;
  6252. /**
  6253. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6254. */
  6255. baseDepth: number;
  6256. /**
  6257. * Gets a boolean indicating if the texture is inverted on Y axis
  6258. */
  6259. invertY: boolean;
  6260. /**
  6261. * Gets or set the previous tracker in the list
  6262. */
  6263. previous: Nullable<IInternalTextureTracker>;
  6264. /**
  6265. * Gets or set the next tracker in the list
  6266. */
  6267. next: Nullable<IInternalTextureTracker>;
  6268. /** @hidden */
  6269. _invertVScale: boolean;
  6270. /** @hidden */
  6271. _initialSlot: number;
  6272. /** @hidden */
  6273. _designatedSlot: number;
  6274. /** @hidden */
  6275. _dataSource: number;
  6276. /** @hidden */
  6277. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6278. /** @hidden */
  6279. _bufferView: Nullable<ArrayBufferView>;
  6280. /** @hidden */
  6281. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6282. /** @hidden */
  6283. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6284. /** @hidden */
  6285. _size: number;
  6286. /** @hidden */
  6287. _extension: string;
  6288. /** @hidden */
  6289. _files: Nullable<string[]>;
  6290. /** @hidden */
  6291. _workingCanvas: HTMLCanvasElement;
  6292. /** @hidden */
  6293. _workingContext: CanvasRenderingContext2D;
  6294. /** @hidden */
  6295. _framebuffer: Nullable<WebGLFramebuffer>;
  6296. /** @hidden */
  6297. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6298. /** @hidden */
  6299. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6300. /** @hidden */
  6301. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6302. /** @hidden */
  6303. _attachments: Nullable<number[]>;
  6304. /** @hidden */
  6305. _cachedCoordinatesMode: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedWrapU: Nullable<number>;
  6308. /** @hidden */
  6309. _cachedWrapV: Nullable<number>;
  6310. /** @hidden */
  6311. _cachedWrapR: Nullable<number>;
  6312. /** @hidden */
  6313. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6314. /** @hidden */
  6315. _isDisabled: boolean;
  6316. /** @hidden */
  6317. _compression: Nullable<string>;
  6318. /** @hidden */
  6319. _generateStencilBuffer: boolean;
  6320. /** @hidden */
  6321. _generateDepthBuffer: boolean;
  6322. /** @hidden */
  6323. _comparisonFunction: number;
  6324. /** @hidden */
  6325. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6326. /** @hidden */
  6327. _lodGenerationScale: number;
  6328. /** @hidden */
  6329. _lodGenerationOffset: number;
  6330. /** @hidden */
  6331. _lodTextureHigh: BaseTexture;
  6332. /** @hidden */
  6333. _lodTextureMid: BaseTexture;
  6334. /** @hidden */
  6335. _lodTextureLow: BaseTexture;
  6336. /** @hidden */
  6337. _isRGBD: boolean;
  6338. /** @hidden */
  6339. _webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */
  6341. _references: number;
  6342. private _engine;
  6343. /**
  6344. * Gets the Engine the texture belongs to.
  6345. * @returns The babylon engine
  6346. */
  6347. getEngine(): Engine;
  6348. /**
  6349. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6350. */
  6351. readonly dataSource: number;
  6352. /**
  6353. * Creates a new InternalTexture
  6354. * @param engine defines the engine to use
  6355. * @param dataSource defines the type of data that will be used
  6356. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6357. */
  6358. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6359. /**
  6360. * Increments the number of references (ie. the number of Texture that point to it)
  6361. */
  6362. incrementReferences(): void;
  6363. /**
  6364. * Change the size of the texture (not the size of the content)
  6365. * @param width defines the new width
  6366. * @param height defines the new height
  6367. * @param depth defines the new depth (1 by default)
  6368. */
  6369. updateSize(width: int, height: int, depth?: int): void;
  6370. /** @hidden */
  6371. _rebuild(): void;
  6372. /** @hidden */
  6373. _swapAndDie(target: InternalTexture): void;
  6374. /**
  6375. * Dispose the current allocated resources
  6376. */
  6377. dispose(): void;
  6378. }
  6379. }
  6380. declare module "babylonjs/Animations/easing" {
  6381. /**
  6382. * This represents the main contract an easing function should follow.
  6383. * Easing functions are used throughout the animation system.
  6384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6385. */
  6386. export interface IEasingFunction {
  6387. /**
  6388. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6389. * of the easing function.
  6390. * The link below provides some of the most common examples of easing functions.
  6391. * @see https://easings.net/
  6392. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6393. * @returns the corresponding value on the curve defined by the easing function
  6394. */
  6395. ease(gradient: number): number;
  6396. }
  6397. /**
  6398. * Base class used for every default easing function.
  6399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6400. */
  6401. export class EasingFunction implements IEasingFunction {
  6402. /**
  6403. * Interpolation follows the mathematical formula associated with the easing function.
  6404. */
  6405. static readonly EASINGMODE_EASEIN: number;
  6406. /**
  6407. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6408. */
  6409. static readonly EASINGMODE_EASEOUT: number;
  6410. /**
  6411. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6412. */
  6413. static readonly EASINGMODE_EASEINOUT: number;
  6414. private _easingMode;
  6415. /**
  6416. * Sets the easing mode of the current function.
  6417. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6418. */
  6419. setEasingMode(easingMode: number): void;
  6420. /**
  6421. * Gets the current easing mode.
  6422. * @returns the easing mode
  6423. */
  6424. getEasingMode(): number;
  6425. /**
  6426. * @hidden
  6427. */
  6428. easeInCore(gradient: number): number;
  6429. /**
  6430. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6431. * of the easing function.
  6432. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6433. * @returns the corresponding value on the curve defined by the easing function
  6434. */
  6435. ease(gradient: number): number;
  6436. }
  6437. /**
  6438. * Easing function with a circle shape (see link below).
  6439. * @see https://easings.net/#easeInCirc
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export class CircleEase extends EasingFunction implements IEasingFunction {
  6443. /** @hidden */
  6444. easeInCore(gradient: number): number;
  6445. }
  6446. /**
  6447. * Easing function with a ease back shape (see link below).
  6448. * @see https://easings.net/#easeInBack
  6449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6450. */
  6451. export class BackEase extends EasingFunction implements IEasingFunction {
  6452. /** Defines the amplitude of the function */
  6453. amplitude: number;
  6454. /**
  6455. * Instantiates a back ease easing
  6456. * @see https://easings.net/#easeInBack
  6457. * @param amplitude Defines the amplitude of the function
  6458. */
  6459. constructor(
  6460. /** Defines the amplitude of the function */
  6461. amplitude?: number);
  6462. /** @hidden */
  6463. easeInCore(gradient: number): number;
  6464. }
  6465. /**
  6466. * Easing function with a bouncing shape (see link below).
  6467. * @see https://easings.net/#easeInBounce
  6468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6469. */
  6470. export class BounceEase extends EasingFunction implements IEasingFunction {
  6471. /** Defines the number of bounces */
  6472. bounces: number;
  6473. /** Defines the amplitude of the bounce */
  6474. bounciness: number;
  6475. /**
  6476. * Instantiates a bounce easing
  6477. * @see https://easings.net/#easeInBounce
  6478. * @param bounces Defines the number of bounces
  6479. * @param bounciness Defines the amplitude of the bounce
  6480. */
  6481. constructor(
  6482. /** Defines the number of bounces */
  6483. bounces?: number,
  6484. /** Defines the amplitude of the bounce */
  6485. bounciness?: number);
  6486. /** @hidden */
  6487. easeInCore(gradient: number): number;
  6488. }
  6489. /**
  6490. * Easing function with a power of 3 shape (see link below).
  6491. * @see https://easings.net/#easeInCubic
  6492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6493. */
  6494. export class CubicEase extends EasingFunction implements IEasingFunction {
  6495. /** @hidden */
  6496. easeInCore(gradient: number): number;
  6497. }
  6498. /**
  6499. * Easing function with an elastic shape (see link below).
  6500. * @see https://easings.net/#easeInElastic
  6501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6502. */
  6503. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6504. /** Defines the number of oscillations*/
  6505. oscillations: number;
  6506. /** Defines the amplitude of the oscillations*/
  6507. springiness: number;
  6508. /**
  6509. * Instantiates an elastic easing function
  6510. * @see https://easings.net/#easeInElastic
  6511. * @param oscillations Defines the number of oscillations
  6512. * @param springiness Defines the amplitude of the oscillations
  6513. */
  6514. constructor(
  6515. /** Defines the number of oscillations*/
  6516. oscillations?: number,
  6517. /** Defines the amplitude of the oscillations*/
  6518. springiness?: number);
  6519. /** @hidden */
  6520. easeInCore(gradient: number): number;
  6521. }
  6522. /**
  6523. * Easing function with an exponential shape (see link below).
  6524. * @see https://easings.net/#easeInExpo
  6525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6526. */
  6527. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6528. /** Defines the exponent of the function */
  6529. exponent: number;
  6530. /**
  6531. * Instantiates an exponential easing function
  6532. * @see https://easings.net/#easeInExpo
  6533. * @param exponent Defines the exponent of the function
  6534. */
  6535. constructor(
  6536. /** Defines the exponent of the function */
  6537. exponent?: number);
  6538. /** @hidden */
  6539. easeInCore(gradient: number): number;
  6540. }
  6541. /**
  6542. * Easing function with a power shape (see link below).
  6543. * @see https://easings.net/#easeInQuad
  6544. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6545. */
  6546. export class PowerEase extends EasingFunction implements IEasingFunction {
  6547. /** Defines the power of the function */
  6548. power: number;
  6549. /**
  6550. * Instantiates an power base easing function
  6551. * @see https://easings.net/#easeInQuad
  6552. * @param power Defines the power of the function
  6553. */
  6554. constructor(
  6555. /** Defines the power of the function */
  6556. power?: number);
  6557. /** @hidden */
  6558. easeInCore(gradient: number): number;
  6559. }
  6560. /**
  6561. * Easing function with a power of 2 shape (see link below).
  6562. * @see https://easings.net/#easeInQuad
  6563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6564. */
  6565. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6566. /** @hidden */
  6567. easeInCore(gradient: number): number;
  6568. }
  6569. /**
  6570. * Easing function with a power of 4 shape (see link below).
  6571. * @see https://easings.net/#easeInQuart
  6572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6573. */
  6574. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with a power of 5 shape (see link below).
  6580. * @see https://easings.net/#easeInQuint
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a sin shape (see link below).
  6589. * @see https://easings.net/#easeInSine
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class SineEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with a bezier shape (see link below).
  6598. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the x component of the start tangent in the bezier curve */
  6603. x1: number;
  6604. /** Defines the y component of the start tangent in the bezier curve */
  6605. y1: number;
  6606. /** Defines the x component of the end tangent in the bezier curve */
  6607. x2: number;
  6608. /** Defines the y component of the end tangent in the bezier curve */
  6609. y2: number;
  6610. /**
  6611. * Instantiates a bezier function
  6612. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6613. * @param x1 Defines the x component of the start tangent in the bezier curve
  6614. * @param y1 Defines the y component of the start tangent in the bezier curve
  6615. * @param x2 Defines the x component of the end tangent in the bezier curve
  6616. * @param y2 Defines the y component of the end tangent in the bezier curve
  6617. */
  6618. constructor(
  6619. /** Defines the x component of the start tangent in the bezier curve */
  6620. x1?: number,
  6621. /** Defines the y component of the start tangent in the bezier curve */
  6622. y1?: number,
  6623. /** Defines the x component of the end tangent in the bezier curve */
  6624. x2?: number,
  6625. /** Defines the y component of the end tangent in the bezier curve */
  6626. y2?: number);
  6627. /** @hidden */
  6628. easeInCore(gradient: number): number;
  6629. }
  6630. }
  6631. declare module "babylonjs/Animations/animationKey" {
  6632. /**
  6633. * Defines an interface which represents an animation key frame
  6634. */
  6635. export interface IAnimationKey {
  6636. /**
  6637. * Frame of the key frame
  6638. */
  6639. frame: number;
  6640. /**
  6641. * Value at the specifies key frame
  6642. */
  6643. value: any;
  6644. /**
  6645. * The input tangent for the cubic hermite spline
  6646. */
  6647. inTangent?: any;
  6648. /**
  6649. * The output tangent for the cubic hermite spline
  6650. */
  6651. outTangent?: any;
  6652. /**
  6653. * The animation interpolation type
  6654. */
  6655. interpolation?: AnimationKeyInterpolation;
  6656. }
  6657. /**
  6658. * Enum for the animation key frame interpolation type
  6659. */
  6660. export enum AnimationKeyInterpolation {
  6661. /**
  6662. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6663. */
  6664. STEP = 1
  6665. }
  6666. }
  6667. declare module "babylonjs/Animations/animationRange" {
  6668. /**
  6669. * Represents the range of an animation
  6670. */
  6671. export class AnimationRange {
  6672. /**The name of the animation range**/
  6673. name: string;
  6674. /**The starting frame of the animation */
  6675. from: number;
  6676. /**The ending frame of the animation*/
  6677. to: number;
  6678. /**
  6679. * Initializes the range of an animation
  6680. * @param name The name of the animation range
  6681. * @param from The starting frame of the animation
  6682. * @param to The ending frame of the animation
  6683. */
  6684. constructor(
  6685. /**The name of the animation range**/
  6686. name: string,
  6687. /**The starting frame of the animation */
  6688. from: number,
  6689. /**The ending frame of the animation*/
  6690. to: number);
  6691. /**
  6692. * Makes a copy of the animation range
  6693. * @returns A copy of the animation range
  6694. */
  6695. clone(): AnimationRange;
  6696. }
  6697. }
  6698. declare module "babylonjs/Animations/animationEvent" {
  6699. /**
  6700. * Composed of a frame, and an action function
  6701. */
  6702. export class AnimationEvent {
  6703. /** The frame for which the event is triggered **/
  6704. frame: number;
  6705. /** The event to perform when triggered **/
  6706. action: (currentFrame: number) => void;
  6707. /** Specifies if the event should be triggered only once**/
  6708. onlyOnce?: boolean | undefined;
  6709. /**
  6710. * Specifies if the animation event is done
  6711. */
  6712. isDone: boolean;
  6713. /**
  6714. * Initializes the animation event
  6715. * @param frame The frame for which the event is triggered
  6716. * @param action The event to perform when triggered
  6717. * @param onlyOnce Specifies if the event should be triggered only once
  6718. */
  6719. constructor(
  6720. /** The frame for which the event is triggered **/
  6721. frame: number,
  6722. /** The event to perform when triggered **/
  6723. action: (currentFrame: number) => void,
  6724. /** Specifies if the event should be triggered only once**/
  6725. onlyOnce?: boolean | undefined);
  6726. /** @hidden */
  6727. _clone(): AnimationEvent;
  6728. }
  6729. }
  6730. declare module "babylonjs/Behaviors/behavior" {
  6731. import { Nullable } from "babylonjs/types";
  6732. /**
  6733. * Interface used to define a behavior
  6734. */
  6735. export interface Behavior<T> {
  6736. /** gets or sets behavior's name */
  6737. name: string;
  6738. /**
  6739. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6740. */
  6741. init(): void;
  6742. /**
  6743. * Called when the behavior is attached to a target
  6744. * @param target defines the target where the behavior is attached to
  6745. */
  6746. attach(target: T): void;
  6747. /**
  6748. * Called when the behavior is detached from its target
  6749. */
  6750. detach(): void;
  6751. }
  6752. /**
  6753. * Interface implemented by classes supporting behaviors
  6754. */
  6755. export interface IBehaviorAware<T> {
  6756. /**
  6757. * Attach a behavior
  6758. * @param behavior defines the behavior to attach
  6759. * @returns the current host
  6760. */
  6761. addBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Remove a behavior from the current object
  6764. * @param behavior defines the behavior to detach
  6765. * @returns the current host
  6766. */
  6767. removeBehavior(behavior: Behavior<T>): T;
  6768. /**
  6769. * Gets a behavior using its name to search
  6770. * @param name defines the name to search
  6771. * @returns the behavior or null if not found
  6772. */
  6773. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6793. /**
  6794. * Class used to store bounding sphere information
  6795. */
  6796. export class BoundingSphere {
  6797. /**
  6798. * Gets the center of the bounding sphere in local space
  6799. */
  6800. readonly center: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in local space
  6803. */
  6804. radius: number;
  6805. /**
  6806. * Gets the center of the bounding sphere in world space
  6807. */
  6808. readonly centerWorld: Vector3;
  6809. /**
  6810. * Radius of the bounding sphere in world space
  6811. */
  6812. radiusWorld: number;
  6813. /**
  6814. * Gets the minimum vector in local space
  6815. */
  6816. readonly minimum: Vector3;
  6817. /**
  6818. * Gets the maximum vector in local space
  6819. */
  6820. readonly maximum: Vector3;
  6821. private _worldMatrix;
  6822. private static readonly TmpVector3;
  6823. /**
  6824. * Creates a new bounding sphere
  6825. * @param min defines the minimum vector (in local space)
  6826. * @param max defines the maximum vector (in local space)
  6827. * @param worldMatrix defines the new world matrix
  6828. */
  6829. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6830. /**
  6831. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6832. * @param min defines the new minimum vector (in local space)
  6833. * @param max defines the new maximum vector (in local space)
  6834. * @param worldMatrix defines the new world matrix
  6835. */
  6836. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6837. /**
  6838. * Scale the current bounding sphere by applying a scale factor
  6839. * @param factor defines the scale factor to apply
  6840. * @returns the current bounding box
  6841. */
  6842. scale(factor: number): BoundingSphere;
  6843. /**
  6844. * Gets the world matrix of the bounding box
  6845. * @returns a matrix
  6846. */
  6847. getWorldMatrix(): DeepImmutable<Matrix>;
  6848. /** @hidden */
  6849. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6850. /**
  6851. * Tests if the bounding sphere is intersecting the frustum planes
  6852. * @param frustumPlanes defines the frustum planes to test
  6853. * @returns true if there is an intersection
  6854. */
  6855. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6856. /**
  6857. * Tests if the bounding sphere center is in between the frustum planes.
  6858. * Used for optimistic fast inclusion.
  6859. * @param frustumPlanes defines the frustum planes to test
  6860. * @returns true if the sphere center is in between the frustum planes
  6861. */
  6862. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6863. /**
  6864. * Tests if a point is inside the bounding sphere
  6865. * @param point defines the point to test
  6866. * @returns true if the point is inside the bounding sphere
  6867. */
  6868. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6869. /**
  6870. * Checks if two sphere intersct
  6871. * @param sphere0 sphere 0
  6872. * @param sphere1 sphere 1
  6873. * @returns true if the speres intersect
  6874. */
  6875. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6876. }
  6877. }
  6878. declare module "babylonjs/Culling/boundingBox" {
  6879. import { DeepImmutable } from "babylonjs/types";
  6880. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6881. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6882. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6883. /**
  6884. * Class used to store bounding box information
  6885. */
  6886. export class BoundingBox implements ICullable {
  6887. /**
  6888. * Gets the 8 vectors representing the bounding box in local space
  6889. */
  6890. readonly vectors: Vector3[];
  6891. /**
  6892. * Gets the center of the bounding box in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Gets the center of the bounding box in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Gets the extend size in local space
  6901. */
  6902. readonly extendSize: Vector3;
  6903. /**
  6904. * Gets the extend size in world space
  6905. */
  6906. readonly extendSizeWorld: Vector3;
  6907. /**
  6908. * Gets the OBB (object bounding box) directions
  6909. */
  6910. readonly directions: Vector3[];
  6911. /**
  6912. * Gets the 8 vectors representing the bounding box in world space
  6913. */
  6914. readonly vectorsWorld: Vector3[];
  6915. /**
  6916. * Gets the minimum vector in world space
  6917. */
  6918. readonly minimumWorld: Vector3;
  6919. /**
  6920. * Gets the maximum vector in world space
  6921. */
  6922. readonly maximumWorld: Vector3;
  6923. /**
  6924. * Gets the minimum vector in local space
  6925. */
  6926. readonly minimum: Vector3;
  6927. /**
  6928. * Gets the maximum vector in local space
  6929. */
  6930. readonly maximum: Vector3;
  6931. private _worldMatrix;
  6932. private static readonly TmpVector3;
  6933. /**
  6934. * @hidden
  6935. */
  6936. _tag: number;
  6937. /**
  6938. * Creates a new bounding box
  6939. * @param min defines the minimum vector (in local space)
  6940. * @param max defines the maximum vector (in local space)
  6941. * @param worldMatrix defines the new world matrix
  6942. */
  6943. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6944. /**
  6945. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6946. * @param min defines the new minimum vector (in local space)
  6947. * @param max defines the new maximum vector (in local space)
  6948. * @param worldMatrix defines the new world matrix
  6949. */
  6950. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6951. /**
  6952. * Scale the current bounding box by applying a scale factor
  6953. * @param factor defines the scale factor to apply
  6954. * @returns the current bounding box
  6955. */
  6956. scale(factor: number): BoundingBox;
  6957. /**
  6958. * Gets the world matrix of the bounding box
  6959. * @returns a matrix
  6960. */
  6961. getWorldMatrix(): DeepImmutable<Matrix>;
  6962. /** @hidden */
  6963. _update(world: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * Tests if the bounding box is intersecting the frustum planes
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if the bounding box is entirely inside the frustum planes
  6972. * @param frustumPlanes defines the frustum planes to test
  6973. * @returns true if there is an inclusion
  6974. */
  6975. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6976. /**
  6977. * Tests if a point is inside the bounding box
  6978. * @param point defines the point to test
  6979. * @returns true if the point is inside the bounding box
  6980. */
  6981. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6982. /**
  6983. * Tests if the bounding box intersects with a bounding sphere
  6984. * @param sphere defines the sphere to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6988. /**
  6989. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6990. * @param min defines the min vector to use
  6991. * @param max defines the max vector to use
  6992. * @returns true if there is an intersection
  6993. */
  6994. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6995. /**
  6996. * Tests if two bounding boxes are intersections
  6997. * @param box0 defines the first box to test
  6998. * @param box1 defines the second box to test
  6999. * @returns true if there is an intersection
  7000. */
  7001. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7002. /**
  7003. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7004. * @param minPoint defines the minimum vector of the bounding box
  7005. * @param maxPoint defines the maximum vector of the bounding box
  7006. * @param sphereCenter defines the sphere center
  7007. * @param sphereRadius defines the sphere radius
  7008. * @returns true if there is an intersection
  7009. */
  7010. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7011. /**
  7012. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7013. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7014. * @param frustumPlanes defines the frustum planes to test
  7015. * @return true if there is an inclusion
  7016. */
  7017. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7018. /**
  7019. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7020. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7021. * @param frustumPlanes defines the frustum planes to test
  7022. * @return true if there is an intersection
  7023. */
  7024. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Collisions/collider" {
  7028. import { Nullable, IndicesArray } from "babylonjs/types";
  7029. import { Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7031. /** @hidden */
  7032. export class Collider {
  7033. /** Define if a collision was found */
  7034. collisionFound: boolean;
  7035. /**
  7036. * Define last intersection point in local space
  7037. */
  7038. intersectionPoint: Vector3;
  7039. /**
  7040. * Define last collided mesh
  7041. */
  7042. collidedMesh: Nullable<AbstractMesh>;
  7043. private _collisionPoint;
  7044. private _planeIntersectionPoint;
  7045. private _tempVector;
  7046. private _tempVector2;
  7047. private _tempVector3;
  7048. private _tempVector4;
  7049. private _edge;
  7050. private _baseToVertex;
  7051. private _destinationPoint;
  7052. private _slidePlaneNormal;
  7053. private _displacementVector;
  7054. /** @hidden */
  7055. _radius: Vector3;
  7056. /** @hidden */
  7057. _retry: number;
  7058. private _velocity;
  7059. private _basePoint;
  7060. private _epsilon;
  7061. /** @hidden */
  7062. _velocityWorldLength: number;
  7063. /** @hidden */
  7064. _basePointWorld: Vector3;
  7065. private _velocityWorld;
  7066. private _normalizedVelocity;
  7067. /** @hidden */
  7068. _initialVelocity: Vector3;
  7069. /** @hidden */
  7070. _initialPosition: Vector3;
  7071. private _nearestDistance;
  7072. private _collisionMask;
  7073. collisionMask: number;
  7074. /**
  7075. * Gets the plane normal used to compute the sliding response (in local space)
  7076. */
  7077. readonly slidePlaneNormal: Vector3;
  7078. /** @hidden */
  7079. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7080. /** @hidden */
  7081. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7082. /** @hidden */
  7083. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7084. /** @hidden */
  7085. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7086. /** @hidden */
  7087. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7088. /** @hidden */
  7089. _getResponse(pos: Vector3, vel: Vector3): void;
  7090. }
  7091. }
  7092. declare module "babylonjs/Culling/boundingInfo" {
  7093. import { DeepImmutable } from "babylonjs/types";
  7094. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7095. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7096. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7097. import { Collider } from "babylonjs/Collisions/collider";
  7098. /**
  7099. * Interface for cullable objects
  7100. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7101. */
  7102. export interface ICullable {
  7103. /**
  7104. * Checks if the object or part of the object is in the frustum
  7105. * @param frustumPlanes Camera near/planes
  7106. * @returns true if the object is in frustum otherwise false
  7107. */
  7108. isInFrustum(frustumPlanes: Plane[]): boolean;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7116. }
  7117. /**
  7118. * Info for a bounding data of a mesh
  7119. */
  7120. export class BoundingInfo implements ICullable {
  7121. /**
  7122. * Bounding box for the mesh
  7123. */
  7124. readonly boundingBox: BoundingBox;
  7125. /**
  7126. * Bounding sphere for the mesh
  7127. */
  7128. readonly boundingSphere: BoundingSphere;
  7129. private _isLocked;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Constructs bounding info
  7133. * @param minimum min vector of the bounding box/sphere
  7134. * @param maximum max vector of the bounding box/sphere
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * min vector of the bounding box/sphere
  7147. */
  7148. readonly minimum: Vector3;
  7149. /**
  7150. * max vector of the bounding box/sphere
  7151. */
  7152. readonly maximum: Vector3;
  7153. /**
  7154. * If the info is locked and won't be updated to avoid perf overhead
  7155. */
  7156. isLocked: boolean;
  7157. /**
  7158. * Updates the bounding sphere and box
  7159. * @param world world matrix to be used to update
  7160. */
  7161. update(world: DeepImmutable<Matrix>): void;
  7162. /**
  7163. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7164. * @param center New center of the bounding info
  7165. * @param extend New extend of the bounding info
  7166. * @returns the current bounding info
  7167. */
  7168. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7169. /**
  7170. * Scale the current bounding info by applying a scale factor
  7171. * @param factor defines the scale factor to apply
  7172. * @returns the current bounding info
  7173. */
  7174. scale(factor: number): BoundingInfo;
  7175. /**
  7176. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7177. * @param frustumPlanes defines the frustum to test
  7178. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7179. * @returns true if the bounding info is in the frustum planes
  7180. */
  7181. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7182. /**
  7183. * Gets the world distance between the min and max points of the bounding box
  7184. */
  7185. readonly diagonalLength: number;
  7186. /**
  7187. * Checks if a cullable object (mesh...) is in the camera frustum
  7188. * Unlike isInFrustum this cheks the full bounding box
  7189. * @param frustumPlanes Camera near/planes
  7190. * @returns true if the object is in frustum otherwise false
  7191. */
  7192. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7193. /** @hidden */
  7194. _checkCollision(collider: Collider): boolean;
  7195. /**
  7196. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7197. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7198. * @param point the point to check intersection with
  7199. * @returns if the point intersects
  7200. */
  7201. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7202. /**
  7203. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7204. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7205. * @param boundingInfo the bounding info to check intersection with
  7206. * @param precise if the intersection should be done using OBB
  7207. * @returns if the bounding info intersects
  7208. */
  7209. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7210. }
  7211. }
  7212. declare module "babylonjs/Misc/smartArray" {
  7213. /**
  7214. * Defines an array and its length.
  7215. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7216. */
  7217. export interface ISmartArrayLike<T> {
  7218. /**
  7219. * The data of the array.
  7220. */
  7221. data: Array<T>;
  7222. /**
  7223. * The active length of the array.
  7224. */
  7225. length: number;
  7226. }
  7227. /**
  7228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7229. */
  7230. export class SmartArray<T> implements ISmartArrayLike<T> {
  7231. /**
  7232. * The full set of data from the array.
  7233. */
  7234. data: Array<T>;
  7235. /**
  7236. * The active length of the array.
  7237. */
  7238. length: number;
  7239. protected _id: number;
  7240. /**
  7241. * Instantiates a Smart Array.
  7242. * @param capacity defines the default capacity of the array.
  7243. */
  7244. constructor(capacity: number);
  7245. /**
  7246. * Pushes a value at the end of the active data.
  7247. * @param value defines the object to push in the array.
  7248. */
  7249. push(value: T): void;
  7250. /**
  7251. * Iterates over the active data and apply the lambda to them.
  7252. * @param func defines the action to apply on each value.
  7253. */
  7254. forEach(func: (content: T) => void): void;
  7255. /**
  7256. * Sorts the full sets of data.
  7257. * @param compareFn defines the comparison function to apply.
  7258. */
  7259. sort(compareFn: (a: T, b: T) => number): void;
  7260. /**
  7261. * Resets the active data to an empty array.
  7262. */
  7263. reset(): void;
  7264. /**
  7265. * Releases all the data from the array as well as the array.
  7266. */
  7267. dispose(): void;
  7268. /**
  7269. * Concats the active data with a given array.
  7270. * @param array defines the data to concatenate with.
  7271. */
  7272. concat(array: any): void;
  7273. /**
  7274. * Returns the position of a value in the active data.
  7275. * @param value defines the value to find the index for
  7276. * @returns the index if found in the active data otherwise -1
  7277. */
  7278. indexOf(value: T): number;
  7279. /**
  7280. * Returns whether an element is part of the active data.
  7281. * @param value defines the value to look for
  7282. * @returns true if found in the active data otherwise false
  7283. */
  7284. contains(value: T): boolean;
  7285. private static _GlobalId;
  7286. }
  7287. /**
  7288. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7289. * The data in this array can only be present once
  7290. */
  7291. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7292. private _duplicateId;
  7293. /**
  7294. * Pushes a value at the end of the active data.
  7295. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7296. * @param value defines the object to push in the array.
  7297. */
  7298. push(value: T): void;
  7299. /**
  7300. * Pushes a value at the end of the active data.
  7301. * If the data is already present, it won t be added again
  7302. * @param value defines the object to push in the array.
  7303. * @returns true if added false if it was already present
  7304. */
  7305. pushNoDuplicate(value: T): boolean;
  7306. /**
  7307. * Resets the active data to an empty array.
  7308. */
  7309. reset(): void;
  7310. /**
  7311. * Concats the active data with a given array.
  7312. * This ensures no dupplicate will be present in the result.
  7313. * @param array defines the data to concatenate with.
  7314. */
  7315. concatWithNoDuplicate(array: any): void;
  7316. }
  7317. }
  7318. declare module "babylonjs/Materials/multiMaterial" {
  7319. import { Nullable } from "babylonjs/types";
  7320. import { Scene } from "babylonjs/scene";
  7321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7322. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7324. import { Material } from "babylonjs/Materials/material";
  7325. /**
  7326. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7327. * separate meshes. This can be use to improve performances.
  7328. * @see http://doc.babylonjs.com/how_to/multi_materials
  7329. */
  7330. export class MultiMaterial extends Material {
  7331. private _subMaterials;
  7332. /**
  7333. * Gets or Sets the list of Materials used within the multi material.
  7334. * They need to be ordered according to the submeshes order in the associated mesh
  7335. */
  7336. subMaterials: Nullable<Material>[];
  7337. /**
  7338. * Function used to align with Node.getChildren()
  7339. * @returns the list of Materials used within the multi material
  7340. */
  7341. getChildren(): Nullable<Material>[];
  7342. /**
  7343. * Instantiates a new Multi Material
  7344. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7345. * separate meshes. This can be use to improve performances.
  7346. * @see http://doc.babylonjs.com/how_to/multi_materials
  7347. * @param name Define the name in the scene
  7348. * @param scene Define the scene the material belongs to
  7349. */
  7350. constructor(name: string, scene: Scene);
  7351. private _hookArray;
  7352. /**
  7353. * Get one of the submaterial by its index in the submaterials array
  7354. * @param index The index to look the sub material at
  7355. * @returns The Material if the index has been defined
  7356. */
  7357. getSubMaterial(index: number): Nullable<Material>;
  7358. /**
  7359. * Get the list of active textures for the whole sub materials list.
  7360. * @returns All the textures that will be used during the rendering
  7361. */
  7362. getActiveTextures(): BaseTexture[];
  7363. /**
  7364. * Gets the current class name of the material e.g. "MultiMaterial"
  7365. * Mainly use in serialization.
  7366. * @returns the class name
  7367. */
  7368. getClassName(): string;
  7369. /**
  7370. * Checks if the material is ready to render the requested sub mesh
  7371. * @param mesh Define the mesh the submesh belongs to
  7372. * @param subMesh Define the sub mesh to look readyness for
  7373. * @param useInstances Define whether or not the material is used with instances
  7374. * @returns true if ready, otherwise false
  7375. */
  7376. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7377. /**
  7378. * Clones the current material and its related sub materials
  7379. * @param name Define the name of the newly cloned material
  7380. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7381. * @returns the cloned material
  7382. */
  7383. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7384. /**
  7385. * Serializes the materials into a JSON representation.
  7386. * @returns the JSON representation
  7387. */
  7388. serialize(): any;
  7389. /**
  7390. * Dispose the material and release its associated resources
  7391. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7392. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7393. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7394. */
  7395. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7396. /**
  7397. * Creates a MultiMaterial from parsed MultiMaterial data.
  7398. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7399. * @param scene defines the hosting scene
  7400. * @returns a new MultiMaterial
  7401. */
  7402. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7403. }
  7404. }
  7405. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7406. /**
  7407. * Class used to represent data loading progression
  7408. */
  7409. export class SceneLoaderFlags {
  7410. private static _ForceFullSceneLoadingForIncremental;
  7411. private static _ShowLoadingScreen;
  7412. private static _CleanBoneMatrixWeights;
  7413. private static _loggingLevel;
  7414. /**
  7415. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7416. */
  7417. static ForceFullSceneLoadingForIncremental: boolean;
  7418. /**
  7419. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7420. */
  7421. static ShowLoadingScreen: boolean;
  7422. /**
  7423. * Defines the current logging level (while loading the scene)
  7424. * @ignorenaming
  7425. */
  7426. static loggingLevel: number;
  7427. /**
  7428. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7429. */
  7430. static CleanBoneMatrixWeights: boolean;
  7431. }
  7432. }
  7433. declare module "babylonjs/Meshes/transformNode" {
  7434. import { DeepImmutable } from "babylonjs/types";
  7435. import { Observable } from "babylonjs/Misc/observable";
  7436. import { Nullable } from "babylonjs/types";
  7437. import { Camera } from "babylonjs/Cameras/camera";
  7438. import { Scene } from "babylonjs/scene";
  7439. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7440. import { Node } from "babylonjs/node";
  7441. import { Bone } from "babylonjs/Bones/bone";
  7442. /**
  7443. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7444. * @see https://doc.babylonjs.com/how_to/transformnode
  7445. */
  7446. export class TransformNode extends Node {
  7447. /**
  7448. * Object will not rotate to face the camera
  7449. */
  7450. static BILLBOARDMODE_NONE: number;
  7451. /**
  7452. * Object will rotate to face the camera but only on the x axis
  7453. */
  7454. static BILLBOARDMODE_X: number;
  7455. /**
  7456. * Object will rotate to face the camera but only on the y axis
  7457. */
  7458. static BILLBOARDMODE_Y: number;
  7459. /**
  7460. * Object will rotate to face the camera but only on the z axis
  7461. */
  7462. static BILLBOARDMODE_Z: number;
  7463. /**
  7464. * Object will rotate to face the camera
  7465. */
  7466. static BILLBOARDMODE_ALL: number;
  7467. private _forward;
  7468. private _forwardInverted;
  7469. private _up;
  7470. private _right;
  7471. private _rightInverted;
  7472. private _position;
  7473. private _rotation;
  7474. private _rotationQuaternion;
  7475. protected _scaling: Vector3;
  7476. protected _isDirty: boolean;
  7477. private _transformToBoneReferal;
  7478. /**
  7479. * Set the billboard mode. Default is 0.
  7480. *
  7481. * | Value | Type | Description |
  7482. * | --- | --- | --- |
  7483. * | 0 | BILLBOARDMODE_NONE | |
  7484. * | 1 | BILLBOARDMODE_X | |
  7485. * | 2 | BILLBOARDMODE_Y | |
  7486. * | 4 | BILLBOARDMODE_Z | |
  7487. * | 7 | BILLBOARDMODE_ALL | |
  7488. *
  7489. */
  7490. billboardMode: number;
  7491. /**
  7492. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7493. */
  7494. scalingDeterminant: number;
  7495. /**
  7496. * Sets the distance of the object to max, often used by skybox
  7497. */
  7498. infiniteDistance: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7501. * By default the system will update normals to compensate
  7502. */
  7503. ignoreNonUniformScaling: boolean;
  7504. /** @hidden */
  7505. _poseMatrix: Matrix;
  7506. /** @hidden */
  7507. _localMatrix: Matrix;
  7508. private _absolutePosition;
  7509. private _pivotMatrix;
  7510. private _pivotMatrixInverse;
  7511. protected _postMultiplyPivotMatrix: boolean;
  7512. private _tempMatrix;
  7513. protected _isWorldMatrixFrozen: boolean;
  7514. /** @hidden */
  7515. _indexInSceneTransformNodesArray: number;
  7516. /**
  7517. * An event triggered after the world matrix is updated
  7518. */
  7519. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7520. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7521. /**
  7522. * Gets a string identifying the name of the class
  7523. * @returns "TransformNode" string
  7524. */
  7525. getClassName(): string;
  7526. /**
  7527. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7528. */
  7529. position: Vector3;
  7530. /**
  7531. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7532. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7533. */
  7534. rotation: Vector3;
  7535. /**
  7536. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7537. */
  7538. scaling: Vector3;
  7539. /**
  7540. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7541. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7542. */
  7543. rotationQuaternion: Nullable<Quaternion>;
  7544. /**
  7545. * The forward direction of that transform in world space.
  7546. */
  7547. readonly forward: Vector3;
  7548. /**
  7549. * The up direction of that transform in world space.
  7550. */
  7551. readonly up: Vector3;
  7552. /**
  7553. * The right direction of that transform in world space.
  7554. */
  7555. readonly right: Vector3;
  7556. /**
  7557. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7558. * @param matrix the matrix to copy the pose from
  7559. * @returns this TransformNode.
  7560. */
  7561. updatePoseMatrix(matrix: Matrix): TransformNode;
  7562. /**
  7563. * Returns the mesh Pose matrix.
  7564. * @returns the pose matrix
  7565. */
  7566. getPoseMatrix(): Matrix;
  7567. /** @hidden */
  7568. _isSynchronized(): boolean;
  7569. /** @hidden */
  7570. _initCache(): void;
  7571. /**
  7572. * Flag the transform node as dirty (Forcing it to update everything)
  7573. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7574. * @returns this transform node
  7575. */
  7576. markAsDirty(property: string): TransformNode;
  7577. /**
  7578. * Returns the current mesh absolute position.
  7579. * Returns a Vector3.
  7580. */
  7581. readonly absolutePosition: Vector3;
  7582. /**
  7583. * Sets a new matrix to apply before all other transformation
  7584. * @param matrix defines the transform matrix
  7585. * @returns the current TransformNode
  7586. */
  7587. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7588. /**
  7589. * Sets a new pivot matrix to the current node
  7590. * @param matrix defines the new pivot matrix to use
  7591. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  7592. * @returns the current TransformNode
  7593. */
  7594. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7595. /**
  7596. * Returns the mesh pivot matrix.
  7597. * Default : Identity.
  7598. * @returns the matrix
  7599. */
  7600. getPivotMatrix(): Matrix;
  7601. /**
  7602. * Prevents the World matrix to be computed any longer.
  7603. * @returns the TransformNode.
  7604. */
  7605. freezeWorldMatrix(): TransformNode;
  7606. /**
  7607. * Allows back the World matrix computation.
  7608. * @returns the TransformNode.
  7609. */
  7610. unfreezeWorldMatrix(): this;
  7611. /**
  7612. * True if the World matrix has been frozen.
  7613. */
  7614. readonly isWorldMatrixFrozen: boolean;
  7615. /**
  7616. * Retuns the mesh absolute position in the World.
  7617. * @returns a Vector3.
  7618. */
  7619. getAbsolutePosition(): Vector3;
  7620. /**
  7621. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7622. * @param absolutePosition the absolute position to set
  7623. * @returns the TransformNode.
  7624. */
  7625. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7626. /**
  7627. * Sets the mesh position in its local space.
  7628. * @param vector3 the position to set in localspace
  7629. * @returns the TransformNode.
  7630. */
  7631. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7632. /**
  7633. * Returns the mesh position in the local space from the current World matrix values.
  7634. * @returns a new Vector3.
  7635. */
  7636. getPositionExpressedInLocalSpace(): Vector3;
  7637. /**
  7638. * Translates the mesh along the passed Vector3 in its local space.
  7639. * @param vector3 the distance to translate in localspace
  7640. * @returns the TransformNode.
  7641. */
  7642. locallyTranslate(vector3: Vector3): TransformNode;
  7643. private static _lookAtVectorCache;
  7644. /**
  7645. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7646. * @param targetPoint the position (must be in same space as current mesh) to look at
  7647. * @param yawCor optional yaw (y-axis) correction in radians
  7648. * @param pitchCor optional pitch (x-axis) correction in radians
  7649. * @param rollCor optional roll (z-axis) correction in radians
  7650. * @param space the choosen space of the target
  7651. * @returns the TransformNode.
  7652. */
  7653. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7654. /**
  7655. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7656. * This Vector3 is expressed in the World space.
  7657. * @param localAxis axis to rotate
  7658. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7659. */
  7660. getDirection(localAxis: Vector3): Vector3;
  7661. /**
  7662. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7663. * localAxis is expressed in the mesh local space.
  7664. * result is computed in the Wordl space from the mesh World matrix.
  7665. * @param localAxis axis to rotate
  7666. * @param result the resulting transformnode
  7667. * @returns this TransformNode.
  7668. */
  7669. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7670. /**
  7671. * Sets this transform node rotation to the given local axis.
  7672. * @param localAxis the axis in local space
  7673. * @param yawCor optional yaw (y-axis) correction in radians
  7674. * @param pitchCor optional pitch (x-axis) correction in radians
  7675. * @param rollCor optional roll (z-axis) correction in radians
  7676. * @returns this TransformNode
  7677. */
  7678. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7679. /**
  7680. * Sets a new pivot point to the current node
  7681. * @param point defines the new pivot point to use
  7682. * @param space defines if the point is in world or local space (local by default)
  7683. * @returns the current TransformNode
  7684. */
  7685. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7686. /**
  7687. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7688. * @returns the pivot point
  7689. */
  7690. getPivotPoint(): Vector3;
  7691. /**
  7692. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7693. * @param result the vector3 to store the result
  7694. * @returns this TransformNode.
  7695. */
  7696. getPivotPointToRef(result: Vector3): TransformNode;
  7697. /**
  7698. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7699. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7700. */
  7701. getAbsolutePivotPoint(): Vector3;
  7702. /**
  7703. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7704. * @param result vector3 to store the result
  7705. * @returns this TransformNode.
  7706. */
  7707. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7708. /**
  7709. * Defines the passed node as the parent of the current node.
  7710. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7711. * @param node the node ot set as the parent
  7712. * @returns this TransformNode.
  7713. */
  7714. setParent(node: Nullable<Node>): TransformNode;
  7715. private _nonUniformScaling;
  7716. /**
  7717. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7718. */
  7719. readonly nonUniformScaling: boolean;
  7720. /** @hidden */
  7721. _updateNonUniformScalingState(value: boolean): boolean;
  7722. /**
  7723. * Attach the current TransformNode to another TransformNode associated with a bone
  7724. * @param bone Bone affecting the TransformNode
  7725. * @param affectedTransformNode TransformNode associated with the bone
  7726. * @returns this object
  7727. */
  7728. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7729. /**
  7730. * Detach the transform node if its associated with a bone
  7731. * @returns this object
  7732. */
  7733. detachFromBone(): TransformNode;
  7734. private static _rotationAxisCache;
  7735. /**
  7736. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7737. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7738. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7739. * The passed axis is also normalized.
  7740. * @param axis the axis to rotate around
  7741. * @param amount the amount to rotate in radians
  7742. * @param space Space to rotate in (Default: local)
  7743. * @returns the TransformNode.
  7744. */
  7745. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7746. /**
  7747. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7748. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7749. * The passed axis is also normalized. .
  7750. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7751. * @param point the point to rotate around
  7752. * @param axis the axis to rotate around
  7753. * @param amount the amount to rotate in radians
  7754. * @returns the TransformNode
  7755. */
  7756. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7757. /**
  7758. * Translates the mesh along the axis vector for the passed distance in the given space.
  7759. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7760. * @param axis the axis to translate in
  7761. * @param distance the distance to translate
  7762. * @param space Space to rotate in (Default: local)
  7763. * @returns the TransformNode.
  7764. */
  7765. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7766. /**
  7767. * Adds a rotation step to the mesh current rotation.
  7768. * x, y, z are Euler angles expressed in radians.
  7769. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7770. * This means this rotation is made in the mesh local space only.
  7771. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7772. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7773. * ```javascript
  7774. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7775. * ```
  7776. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7777. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  7778. * @param x Rotation to add
  7779. * @param y Rotation to add
  7780. * @param z Rotation to add
  7781. * @returns the TransformNode.
  7782. */
  7783. addRotation(x: number, y: number, z: number): TransformNode;
  7784. /**
  7785. * Computes the world matrix of the node
  7786. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7787. * @returns the world matrix
  7788. */
  7789. computeWorldMatrix(force?: boolean): Matrix;
  7790. protected _afterComputeWorldMatrix(): void;
  7791. /**
  7792. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7793. * @param func callback function to add
  7794. *
  7795. * @returns the TransformNode.
  7796. */
  7797. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7798. /**
  7799. * Removes a registered callback function.
  7800. * @param func callback function to remove
  7801. * @returns the TransformNode.
  7802. */
  7803. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7804. /**
  7805. * Gets the position of the current mesh in camera space
  7806. * @param camera defines the camera to use
  7807. * @returns a position
  7808. */
  7809. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7810. /**
  7811. * Returns the distance from the mesh to the active camera
  7812. * @param camera defines the camera to use
  7813. * @returns the distance
  7814. */
  7815. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7816. /**
  7817. * Clone the current transform node
  7818. * @param name Name of the new clone
  7819. * @param newParent New parent for the clone
  7820. * @param doNotCloneChildren Do not clone children hierarchy
  7821. * @returns the new transform node
  7822. */
  7823. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7824. /**
  7825. * Serializes the objects information.
  7826. * @param currentSerializationObject defines the object to serialize in
  7827. * @returns the serialized object
  7828. */
  7829. serialize(currentSerializationObject?: any): any;
  7830. /**
  7831. * Returns a new TransformNode object parsed from the source provided.
  7832. * @param parsedTransformNode is the source.
  7833. * @param scene the scne the object belongs to
  7834. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7835. * @returns a new TransformNode object parsed from the source provided.
  7836. */
  7837. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7838. /**
  7839. * Get all child-transformNodes of this node
  7840. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7841. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7842. * @returns an array of TransformNode
  7843. */
  7844. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7845. /**
  7846. * Releases resources associated with this transform node.
  7847. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7848. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7849. */
  7850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7851. }
  7852. }
  7853. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7854. /**
  7855. * Class used to override all child animations of a given target
  7856. */
  7857. export class AnimationPropertiesOverride {
  7858. /**
  7859. * Gets or sets a value indicating if animation blending must be used
  7860. */
  7861. enableBlending: boolean;
  7862. /**
  7863. * Gets or sets the blending speed to use when enableBlending is true
  7864. */
  7865. blendingSpeed: number;
  7866. /**
  7867. * Gets or sets the default loop mode to use
  7868. */
  7869. loopMode: number;
  7870. }
  7871. }
  7872. declare module "babylonjs/Bones/bone" {
  7873. import { Skeleton } from "babylonjs/Bones/skeleton";
  7874. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7875. import { Nullable } from "babylonjs/types";
  7876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7878. import { Node } from "babylonjs/node";
  7879. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7880. /**
  7881. * Class used to store bone information
  7882. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7883. */
  7884. export class Bone extends Node {
  7885. /**
  7886. * defines the bone name
  7887. */
  7888. name: string;
  7889. private static _tmpVecs;
  7890. private static _tmpQuat;
  7891. private static _tmpMats;
  7892. /**
  7893. * Gets the list of child bones
  7894. */
  7895. children: Bone[];
  7896. /** Gets the animations associated with this bone */
  7897. animations: import("babylonjs/Animations/animation").Animation[];
  7898. /**
  7899. * Gets or sets bone length
  7900. */
  7901. length: number;
  7902. /**
  7903. * @hidden Internal only
  7904. * Set this value to map this bone to a different index in the transform matrices
  7905. * Set this value to -1 to exclude the bone from the transform matrices
  7906. */
  7907. _index: Nullable<number>;
  7908. private _skeleton;
  7909. private _localMatrix;
  7910. private _restPose;
  7911. private _baseMatrix;
  7912. private _absoluteTransform;
  7913. private _invertedAbsoluteTransform;
  7914. private _parent;
  7915. private _scalingDeterminant;
  7916. private _worldTransform;
  7917. private _localScaling;
  7918. private _localRotation;
  7919. private _localPosition;
  7920. private _needToDecompose;
  7921. private _needToCompose;
  7922. /** @hidden */
  7923. _linkedTransformNode: Nullable<TransformNode>;
  7924. /** @hidden */
  7925. /** @hidden */
  7926. _matrix: Matrix;
  7927. /**
  7928. * Create a new bone
  7929. * @param name defines the bone name
  7930. * @param skeleton defines the parent skeleton
  7931. * @param parentBone defines the parent (can be null if the bone is the root)
  7932. * @param localMatrix defines the local matrix
  7933. * @param restPose defines the rest pose matrix
  7934. * @param baseMatrix defines the base matrix
  7935. * @param index defines index of the bone in the hiearchy
  7936. */
  7937. constructor(
  7938. /**
  7939. * defines the bone name
  7940. */
  7941. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7942. /**
  7943. * Gets the current object class name.
  7944. * @return the class name
  7945. */
  7946. getClassName(): string;
  7947. /**
  7948. * Gets the parent skeleton
  7949. * @returns a skeleton
  7950. */
  7951. getSkeleton(): Skeleton;
  7952. /**
  7953. * Gets parent bone
  7954. * @returns a bone or null if the bone is the root of the bone hierarchy
  7955. */
  7956. getParent(): Nullable<Bone>;
  7957. /**
  7958. * Returns an array containing the root bones
  7959. * @returns an array containing the root bones
  7960. */
  7961. getChildren(): Array<Bone>;
  7962. /**
  7963. * Sets the parent bone
  7964. * @param parent defines the parent (can be null if the bone is the root)
  7965. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7966. */
  7967. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7968. /**
  7969. * Gets the local matrix
  7970. * @returns a matrix
  7971. */
  7972. getLocalMatrix(): Matrix;
  7973. /**
  7974. * Gets the base matrix (initial matrix which remains unchanged)
  7975. * @returns a matrix
  7976. */
  7977. getBaseMatrix(): Matrix;
  7978. /**
  7979. * Gets the rest pose matrix
  7980. * @returns a matrix
  7981. */
  7982. getRestPose(): Matrix;
  7983. /**
  7984. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7985. */
  7986. getWorldMatrix(): Matrix;
  7987. /**
  7988. * Sets the local matrix to rest pose matrix
  7989. */
  7990. returnToRest(): void;
  7991. /**
  7992. * Gets the inverse of the absolute transform matrix.
  7993. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7994. * @returns a matrix
  7995. */
  7996. getInvertedAbsoluteTransform(): Matrix;
  7997. /**
  7998. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7999. * @returns a matrix
  8000. */
  8001. getAbsoluteTransform(): Matrix;
  8002. /**
  8003. * Links with the given transform node.
  8004. * The local matrix of this bone is copied from the transform node every frame.
  8005. * @param transformNode defines the transform node to link to
  8006. */
  8007. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8008. /** Gets or sets current position (in local space) */
  8009. position: Vector3;
  8010. /** Gets or sets current rotation (in local space) */
  8011. rotation: Vector3;
  8012. /** Gets or sets current rotation quaternion (in local space) */
  8013. rotationQuaternion: Quaternion;
  8014. /** Gets or sets current scaling (in local space) */
  8015. scaling: Vector3;
  8016. /**
  8017. * Gets the animation properties override
  8018. */
  8019. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8020. private _decompose;
  8021. private _compose;
  8022. /**
  8023. * Update the base and local matrices
  8024. * @param matrix defines the new base or local matrix
  8025. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8026. * @param updateLocalMatrix defines if the local matrix should be updated
  8027. */
  8028. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8029. /** @hidden */
  8030. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8031. /**
  8032. * Flag the bone as dirty (Forcing it to update everything)
  8033. */
  8034. markAsDirty(): void;
  8035. private _markAsDirtyAndCompose;
  8036. private _markAsDirtyAndDecompose;
  8037. /**
  8038. * Translate the bone in local or world space
  8039. * @param vec The amount to translate the bone
  8040. * @param space The space that the translation is in
  8041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8042. */
  8043. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8044. /**
  8045. * Set the postion of the bone in local or world space
  8046. * @param position The position to set the bone
  8047. * @param space The space that the position is in
  8048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8049. */
  8050. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8051. /**
  8052. * Set the absolute position of the bone (world space)
  8053. * @param position The position to set the bone
  8054. * @param mesh The mesh that this bone is attached to
  8055. */
  8056. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8057. /**
  8058. * Scale the bone on the x, y and z axes (in local space)
  8059. * @param x The amount to scale the bone on the x axis
  8060. * @param y The amount to scale the bone on the y axis
  8061. * @param z The amount to scale the bone on the z axis
  8062. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8063. */
  8064. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8065. /**
  8066. * Set the bone scaling in local space
  8067. * @param scale defines the scaling vector
  8068. */
  8069. setScale(scale: Vector3): void;
  8070. /**
  8071. * Gets the current scaling in local space
  8072. * @returns the current scaling vector
  8073. */
  8074. getScale(): Vector3;
  8075. /**
  8076. * Gets the current scaling in local space and stores it in a target vector
  8077. * @param result defines the target vector
  8078. */
  8079. getScaleToRef(result: Vector3): void;
  8080. /**
  8081. * Set the yaw, pitch, and roll of the bone in local or world space
  8082. * @param yaw The rotation of the bone on the y axis
  8083. * @param pitch The rotation of the bone on the x axis
  8084. * @param roll The rotation of the bone on the z axis
  8085. * @param space The space that the axes of rotation are in
  8086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8087. */
  8088. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8089. /**
  8090. * Add a rotation to the bone on an axis in local or world space
  8091. * @param axis The axis to rotate the bone on
  8092. * @param amount The amount to rotate the bone
  8093. * @param space The space that the axis is in
  8094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8095. */
  8096. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8097. /**
  8098. * Set the rotation of the bone to a particular axis angle in local or world space
  8099. * @param axis The axis to rotate the bone on
  8100. * @param angle The angle that the bone should be rotated to
  8101. * @param space The space that the axis is in
  8102. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8103. */
  8104. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8105. /**
  8106. * Set the euler rotation of the bone in local of world space
  8107. * @param rotation The euler rotation that the bone should be set to
  8108. * @param space The space that the rotation is in
  8109. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8110. */
  8111. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8112. /**
  8113. * Set the quaternion rotation of the bone in local of world space
  8114. * @param quat The quaternion rotation that the bone should be set to
  8115. * @param space The space that the rotation is in
  8116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8117. */
  8118. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8119. /**
  8120. * Set the rotation matrix of the bone in local of world space
  8121. * @param rotMat The rotation matrix that the bone should be set to
  8122. * @param space The space that the rotation is in
  8123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8124. */
  8125. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8126. private _rotateWithMatrix;
  8127. private _getNegativeRotationToRef;
  8128. /**
  8129. * Get the position of the bone in local or world space
  8130. * @param space The space that the returned position is in
  8131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8132. * @returns The position of the bone
  8133. */
  8134. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8135. /**
  8136. * Copy the position of the bone to a vector3 in local or world space
  8137. * @param space The space that the returned position is in
  8138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8139. * @param result The vector3 to copy the position to
  8140. */
  8141. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8142. /**
  8143. * Get the absolute position of the bone (world space)
  8144. * @param mesh The mesh that this bone is attached to
  8145. * @returns The absolute position of the bone
  8146. */
  8147. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8148. /**
  8149. * Copy the absolute position of the bone (world space) to the result param
  8150. * @param mesh The mesh that this bone is attached to
  8151. * @param result The vector3 to copy the absolute position to
  8152. */
  8153. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8154. /**
  8155. * Compute the absolute transforms of this bone and its children
  8156. */
  8157. computeAbsoluteTransforms(): void;
  8158. /**
  8159. * Get the world direction from an axis that is in the local space of the bone
  8160. * @param localAxis The local direction that is used to compute the world direction
  8161. * @param mesh The mesh that this bone is attached to
  8162. * @returns The world direction
  8163. */
  8164. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8165. /**
  8166. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8167. * @param localAxis The local direction that is used to compute the world direction
  8168. * @param mesh The mesh that this bone is attached to
  8169. * @param result The vector3 that the world direction will be copied to
  8170. */
  8171. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8172. /**
  8173. * Get the euler rotation of the bone in local or world space
  8174. * @param space The space that the rotation should be in
  8175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8176. * @returns The euler rotation
  8177. */
  8178. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8179. /**
  8180. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8181. * @param space The space that the rotation should be in
  8182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8183. * @param result The vector3 that the rotation should be copied to
  8184. */
  8185. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8186. /**
  8187. * Get the quaternion rotation of the bone in either local or world space
  8188. * @param space The space that the rotation should be in
  8189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8190. * @returns The quaternion rotation
  8191. */
  8192. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8193. /**
  8194. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8195. * @param space The space that the rotation should be in
  8196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8197. * @param result The quaternion that the rotation should be copied to
  8198. */
  8199. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8200. /**
  8201. * Get the rotation matrix of the bone in local or world space
  8202. * @param space The space that the rotation should be in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. * @returns The rotation matrix
  8205. */
  8206. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8207. /**
  8208. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8209. * @param space The space that the rotation should be in
  8210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8211. * @param result The quaternion that the rotation should be copied to
  8212. */
  8213. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8214. /**
  8215. * Get the world position of a point that is in the local space of the bone
  8216. * @param position The local position
  8217. * @param mesh The mesh that this bone is attached to
  8218. * @returns The world position
  8219. */
  8220. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8221. /**
  8222. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8223. * @param position The local position
  8224. * @param mesh The mesh that this bone is attached to
  8225. * @param result The vector3 that the world position should be copied to
  8226. */
  8227. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8228. /**
  8229. * Get the local position of a point that is in world space
  8230. * @param position The world position
  8231. * @param mesh The mesh that this bone is attached to
  8232. * @returns The local position
  8233. */
  8234. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8235. /**
  8236. * Get the local position of a point that is in world space and copy it to the result param
  8237. * @param position The world position
  8238. * @param mesh The mesh that this bone is attached to
  8239. * @param result The vector3 that the local position should be copied to
  8240. */
  8241. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8242. }
  8243. }
  8244. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8245. import { Nullable } from "babylonjs/types";
  8246. import { Scene } from "babylonjs/scene";
  8247. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8248. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8249. /**
  8250. * Class for creating a cube texture
  8251. */
  8252. export class CubeTexture extends BaseTexture {
  8253. private _delayedOnLoad;
  8254. /**
  8255. * The url of the texture
  8256. */
  8257. url: string;
  8258. /**
  8259. * Gets or sets the center of the bounding box associated with the cube texture.
  8260. * It must define where the camera used to render the texture was set
  8261. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8262. */
  8263. boundingBoxPosition: Vector3;
  8264. private _boundingBoxSize;
  8265. /**
  8266. * Gets or sets the size of the bounding box associated with the cube texture
  8267. * When defined, the cubemap will switch to local mode
  8268. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8269. * @example https://www.babylonjs-playground.com/#RNASML
  8270. */
  8271. /**
  8272. * Returns the bounding box size
  8273. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8274. */
  8275. boundingBoxSize: Vector3;
  8276. protected _rotationY: number;
  8277. /**
  8278. * Sets texture matrix rotation angle around Y axis in radians.
  8279. */
  8280. /**
  8281. * Gets texture matrix rotation angle around Y axis radians.
  8282. */
  8283. rotationY: number;
  8284. /**
  8285. * Are mip maps generated for this texture or not.
  8286. */
  8287. readonly noMipmap: boolean;
  8288. private _noMipmap;
  8289. private _files;
  8290. private _extensions;
  8291. private _textureMatrix;
  8292. private _format;
  8293. private _createPolynomials;
  8294. /** @hidden */
  8295. _prefiltered: boolean;
  8296. /**
  8297. * Creates a cube texture from an array of image urls
  8298. * @param files defines an array of image urls
  8299. * @param scene defines the hosting scene
  8300. * @param noMipmap specifies if mip maps are not used
  8301. * @returns a cube texture
  8302. */
  8303. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8304. /**
  8305. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8306. * @param url defines the url of the prefiltered texture
  8307. * @param scene defines the scene the texture is attached to
  8308. * @param forcedExtension defines the extension of the file if different from the url
  8309. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8310. * @return the prefiltered texture
  8311. */
  8312. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8313. /**
  8314. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8315. * as prefiltered data.
  8316. * @param rootUrl defines the url of the texture or the root name of the six images
  8317. * @param scene defines the scene the texture is attached to
  8318. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8319. * @param noMipmap defines if mipmaps should be created or not
  8320. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8321. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8322. * @param onError defines a callback triggered in case of error during load
  8323. * @param format defines the internal format to use for the texture once loaded
  8324. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8325. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8326. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8327. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8328. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8329. * @return the cube texture
  8330. */
  8331. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8332. /**
  8333. * Get the current class name of the texture useful for serialization or dynamic coding.
  8334. * @returns "CubeTexture"
  8335. */
  8336. getClassName(): string;
  8337. /**
  8338. * Update the url (and optional buffer) of this texture if url was null during construction.
  8339. * @param url the url of the texture
  8340. * @param forcedExtension defines the extension to use
  8341. * @param onLoad callback called when the texture is loaded (defaults to null)
  8342. */
  8343. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8344. /**
  8345. * Delays loading of the cube texture
  8346. * @param forcedExtension defines the extension to use
  8347. */
  8348. delayLoad(forcedExtension?: string): void;
  8349. /**
  8350. * Returns the reflection texture matrix
  8351. * @returns the reflection texture matrix
  8352. */
  8353. getReflectionTextureMatrix(): Matrix;
  8354. /**
  8355. * Sets the reflection texture matrix
  8356. * @param value Reflection texture matrix
  8357. */
  8358. setReflectionTextureMatrix(value: Matrix): void;
  8359. /**
  8360. * Parses text to create a cube texture
  8361. * @param parsedTexture define the serialized text to read from
  8362. * @param scene defines the hosting scene
  8363. * @param rootUrl defines the root url of the cube texture
  8364. * @returns a cube texture
  8365. */
  8366. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8367. /**
  8368. * Makes a clone, or deep copy, of the cube texture
  8369. * @returns a new cube texture
  8370. */
  8371. clone(): CubeTexture;
  8372. }
  8373. }
  8374. declare module "babylonjs/Shaders/postprocess.vertex" {
  8375. /** @hidden */
  8376. export var postprocessVertexShader: {
  8377. name: string;
  8378. shader: string;
  8379. };
  8380. }
  8381. declare module "babylonjs/Cameras/targetCamera" {
  8382. import { Nullable } from "babylonjs/types";
  8383. import { Camera } from "babylonjs/Cameras/camera";
  8384. import { Scene } from "babylonjs/scene";
  8385. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8386. /**
  8387. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8388. * This is the base of the follow, arc rotate cameras and Free camera
  8389. * @see http://doc.babylonjs.com/features/cameras
  8390. */
  8391. export class TargetCamera extends Camera {
  8392. private static _RigCamTransformMatrix;
  8393. private static _TargetTransformMatrix;
  8394. private static _TargetFocalPoint;
  8395. /**
  8396. * Define the current direction the camera is moving to
  8397. */
  8398. cameraDirection: Vector3;
  8399. /**
  8400. * Define the current rotation the camera is rotating to
  8401. */
  8402. cameraRotation: Vector2;
  8403. /**
  8404. * When set, the up vector of the camera will be updated by the rotation of the camera
  8405. */
  8406. updateUpVectorFromRotation: boolean;
  8407. private _tmpQuaternion;
  8408. /**
  8409. * Define the current rotation of the camera
  8410. */
  8411. rotation: Vector3;
  8412. /**
  8413. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8414. */
  8415. rotationQuaternion: Quaternion;
  8416. /**
  8417. * Define the current speed of the camera
  8418. */
  8419. speed: number;
  8420. /**
  8421. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8422. * around all axis.
  8423. */
  8424. noRotationConstraint: boolean;
  8425. /**
  8426. * Define the current target of the camera as an object or a position.
  8427. */
  8428. lockedTarget: any;
  8429. /** @hidden */
  8430. _currentTarget: Vector3;
  8431. /** @hidden */
  8432. _initialFocalDistance: number;
  8433. /** @hidden */
  8434. _viewMatrix: Matrix;
  8435. /** @hidden */
  8436. _camMatrix: Matrix;
  8437. /** @hidden */
  8438. _cameraTransformMatrix: Matrix;
  8439. /** @hidden */
  8440. _cameraRotationMatrix: Matrix;
  8441. /** @hidden */
  8442. _referencePoint: Vector3;
  8443. /** @hidden */
  8444. _transformedReferencePoint: Vector3;
  8445. protected _globalCurrentTarget: Vector3;
  8446. protected _globalCurrentUpVector: Vector3;
  8447. /** @hidden */
  8448. _reset: () => void;
  8449. private _defaultUp;
  8450. /**
  8451. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8452. * This is the base of the follow, arc rotate cameras and Free camera
  8453. * @see http://doc.babylonjs.com/features/cameras
  8454. * @param name Defines the name of the camera in the scene
  8455. * @param position Defines the start position of the camera in the scene
  8456. * @param scene Defines the scene the camera belongs to
  8457. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8458. */
  8459. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8460. /**
  8461. * Gets the position in front of the camera at a given distance.
  8462. * @param distance The distance from the camera we want the position to be
  8463. * @returns the position
  8464. */
  8465. getFrontPosition(distance: number): Vector3;
  8466. /** @hidden */
  8467. _getLockedTargetPosition(): Nullable<Vector3>;
  8468. private _storedPosition;
  8469. private _storedRotation;
  8470. private _storedRotationQuaternion;
  8471. /**
  8472. * Store current camera state of the camera (fov, position, rotation, etc..)
  8473. * @returns the camera
  8474. */
  8475. storeState(): Camera;
  8476. /**
  8477. * Restored camera state. You must call storeState() first
  8478. * @returns whether it was successful or not
  8479. * @hidden
  8480. */
  8481. _restoreStateValues(): boolean;
  8482. /** @hidden */
  8483. _initCache(): void;
  8484. /** @hidden */
  8485. _updateCache(ignoreParentClass?: boolean): void;
  8486. /** @hidden */
  8487. _isSynchronizedViewMatrix(): boolean;
  8488. /** @hidden */
  8489. _computeLocalCameraSpeed(): number;
  8490. /**
  8491. * Defines the target the camera should look at.
  8492. * This will automatically adapt alpha beta and radius to fit within the new target.
  8493. * @param target Defines the new target as a Vector or a mesh
  8494. */
  8495. setTarget(target: Vector3): void;
  8496. /**
  8497. * Return the current target position of the camera. This value is expressed in local space.
  8498. * @returns the target position
  8499. */
  8500. getTarget(): Vector3;
  8501. /** @hidden */
  8502. _decideIfNeedsToMove(): boolean;
  8503. /** @hidden */
  8504. _updatePosition(): void;
  8505. /** @hidden */
  8506. _checkInputs(): void;
  8507. protected _updateCameraRotationMatrix(): void;
  8508. /**
  8509. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8510. * @returns the current camera
  8511. */
  8512. private _rotateUpVectorWithCameraRotationMatrix;
  8513. private _cachedRotationZ;
  8514. private _cachedQuaternionRotationZ;
  8515. /** @hidden */
  8516. _getViewMatrix(): Matrix;
  8517. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8518. /**
  8519. * @hidden
  8520. */
  8521. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8522. /**
  8523. * @hidden
  8524. */
  8525. _updateRigCameras(): void;
  8526. private _getRigCamPositionAndTarget;
  8527. /**
  8528. * Gets the current object class name.
  8529. * @return the class name
  8530. */
  8531. getClassName(): string;
  8532. }
  8533. }
  8534. declare module "babylonjs/Cameras/cameraInputsManager" {
  8535. import { Nullable } from "babylonjs/types";
  8536. import { Camera } from "babylonjs/Cameras/camera";
  8537. /**
  8538. * @ignore
  8539. * This is a list of all the different input types that are available in the application.
  8540. * Fo instance: ArcRotateCameraGamepadInput...
  8541. */
  8542. export var CameraInputTypes: {};
  8543. /**
  8544. * This is the contract to implement in order to create a new input class.
  8545. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8546. */
  8547. export interface ICameraInput<TCamera extends Camera> {
  8548. /**
  8549. * Defines the camera the input is attached to.
  8550. */
  8551. camera: Nullable<TCamera>;
  8552. /**
  8553. * Gets the class name of the current intput.
  8554. * @returns the class name
  8555. */
  8556. getClassName(): string;
  8557. /**
  8558. * Get the friendly name associated with the input class.
  8559. * @returns the input friendly name
  8560. */
  8561. getSimpleName(): string;
  8562. /**
  8563. * Attach the input controls to a specific dom element to get the input from.
  8564. * @param element Defines the element the controls should be listened from
  8565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8566. */
  8567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8568. /**
  8569. * Detach the current controls from the specified dom element.
  8570. * @param element Defines the element to stop listening the inputs from
  8571. */
  8572. detachControl(element: Nullable<HTMLElement>): void;
  8573. /**
  8574. * Update the current camera state depending on the inputs that have been used this frame.
  8575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8576. */
  8577. checkInputs?: () => void;
  8578. }
  8579. /**
  8580. * Represents a map of input types to input instance or input index to input instance.
  8581. */
  8582. export interface CameraInputsMap<TCamera extends Camera> {
  8583. /**
  8584. * Accessor to the input by input type.
  8585. */
  8586. [name: string]: ICameraInput<TCamera>;
  8587. /**
  8588. * Accessor to the input by input index.
  8589. */
  8590. [idx: number]: ICameraInput<TCamera>;
  8591. }
  8592. /**
  8593. * This represents the input manager used within a camera.
  8594. * It helps dealing with all the different kind of input attached to a camera.
  8595. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8596. */
  8597. export class CameraInputsManager<TCamera extends Camera> {
  8598. /**
  8599. * Defines the list of inputs attahed to the camera.
  8600. */
  8601. attached: CameraInputsMap<TCamera>;
  8602. /**
  8603. * Defines the dom element the camera is collecting inputs from.
  8604. * This is null if the controls have not been attached.
  8605. */
  8606. attachedElement: Nullable<HTMLElement>;
  8607. /**
  8608. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8609. */
  8610. noPreventDefault: boolean;
  8611. /**
  8612. * Defined the camera the input manager belongs to.
  8613. */
  8614. camera: TCamera;
  8615. /**
  8616. * Update the current camera state depending on the inputs that have been used this frame.
  8617. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8618. */
  8619. checkInputs: () => void;
  8620. /**
  8621. * Instantiate a new Camera Input Manager.
  8622. * @param camera Defines the camera the input manager blongs to
  8623. */
  8624. constructor(camera: TCamera);
  8625. /**
  8626. * Add an input method to a camera
  8627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8628. * @param input camera input method
  8629. */
  8630. add(input: ICameraInput<TCamera>): void;
  8631. /**
  8632. * Remove a specific input method from a camera
  8633. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8634. * @param inputToRemove camera input method
  8635. */
  8636. remove(inputToRemove: ICameraInput<TCamera>): void;
  8637. /**
  8638. * Remove a specific input type from a camera
  8639. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8640. * @param inputType the type of the input to remove
  8641. */
  8642. removeByType(inputType: string): void;
  8643. private _addCheckInputs;
  8644. /**
  8645. * Attach the input controls to the currently attached dom element to listen the events from.
  8646. * @param input Defines the input to attach
  8647. */
  8648. attachInput(input: ICameraInput<TCamera>): void;
  8649. /**
  8650. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8651. * @param element Defines the dom element to collect the events from
  8652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8653. */
  8654. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8655. /**
  8656. * Detach the current manager inputs controls from a specific dom element.
  8657. * @param element Defines the dom element to collect the events from
  8658. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8659. */
  8660. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8661. /**
  8662. * Rebuild the dynamic inputCheck function from the current list of
  8663. * defined inputs in the manager.
  8664. */
  8665. rebuildInputCheck(): void;
  8666. /**
  8667. * Remove all attached input methods from a camera
  8668. */
  8669. clear(): void;
  8670. /**
  8671. * Serialize the current input manager attached to a camera.
  8672. * This ensures than once parsed,
  8673. * the input associated to the camera will be identical to the current ones
  8674. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8675. */
  8676. serialize(serializedCamera: any): void;
  8677. /**
  8678. * Parses an input manager serialized JSON to restore the previous list of inputs
  8679. * and states associated to a camera.
  8680. * @param parsedCamera Defines the JSON to parse
  8681. */
  8682. parse(parsedCamera: any): void;
  8683. }
  8684. }
  8685. declare module "babylonjs/Events/keyboardEvents" {
  8686. /**
  8687. * Gather the list of keyboard event types as constants.
  8688. */
  8689. export class KeyboardEventTypes {
  8690. /**
  8691. * The keydown event is fired when a key becomes active (pressed).
  8692. */
  8693. static readonly KEYDOWN: number;
  8694. /**
  8695. * The keyup event is fired when a key has been released.
  8696. */
  8697. static readonly KEYUP: number;
  8698. }
  8699. /**
  8700. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8701. */
  8702. export class KeyboardInfo {
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number;
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent;
  8711. /**
  8712. * Instantiates a new keyboard info.
  8713. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8714. * @param type Defines the type of event (KeyboardEventTypes)
  8715. * @param event Defines the related dom event
  8716. */
  8717. constructor(
  8718. /**
  8719. * Defines the type of event (KeyboardEventTypes)
  8720. */
  8721. type: number,
  8722. /**
  8723. * Defines the related dom event
  8724. */
  8725. event: KeyboardEvent);
  8726. }
  8727. /**
  8728. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8729. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8730. */
  8731. export class KeyboardInfoPre extends KeyboardInfo {
  8732. /**
  8733. * Defines the type of event (KeyboardEventTypes)
  8734. */
  8735. type: number;
  8736. /**
  8737. * Defines the related dom event
  8738. */
  8739. event: KeyboardEvent;
  8740. /**
  8741. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8742. */
  8743. skipOnPointerObservable: boolean;
  8744. /**
  8745. * Instantiates a new keyboard pre info.
  8746. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8747. * @param type Defines the type of event (KeyboardEventTypes)
  8748. * @param event Defines the related dom event
  8749. */
  8750. constructor(
  8751. /**
  8752. * Defines the type of event (KeyboardEventTypes)
  8753. */
  8754. type: number,
  8755. /**
  8756. * Defines the related dom event
  8757. */
  8758. event: KeyboardEvent);
  8759. }
  8760. }
  8761. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8762. import { Nullable } from "babylonjs/types";
  8763. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8764. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8765. /**
  8766. * Manage the keyboard inputs to control the movement of a free camera.
  8767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8768. */
  8769. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8770. /**
  8771. * Defines the camera the input is attached to.
  8772. */
  8773. camera: FreeCamera;
  8774. /**
  8775. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8776. */
  8777. keysUp: number[];
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8780. */
  8781. keysDown: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8784. */
  8785. keysLeft: number[];
  8786. /**
  8787. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8788. */
  8789. keysRight: number[];
  8790. private _keys;
  8791. private _onCanvasBlurObserver;
  8792. private _onKeyboardObserver;
  8793. private _engine;
  8794. private _scene;
  8795. /**
  8796. * Attach the input controls to a specific dom element to get the input from.
  8797. * @param element Defines the element the controls should be listened from
  8798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8799. */
  8800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8801. /**
  8802. * Detach the current controls from the specified dom element.
  8803. * @param element Defines the element to stop listening the inputs from
  8804. */
  8805. detachControl(element: Nullable<HTMLElement>): void;
  8806. /**
  8807. * Update the current camera state depending on the inputs that have been used this frame.
  8808. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8809. */
  8810. checkInputs(): void;
  8811. /**
  8812. * Gets the class name of the current intput.
  8813. * @returns the class name
  8814. */
  8815. getClassName(): string;
  8816. /** @hidden */
  8817. _onLostFocus(): void;
  8818. /**
  8819. * Get the friendly name associated with the input class.
  8820. * @returns the input friendly name
  8821. */
  8822. getSimpleName(): string;
  8823. }
  8824. }
  8825. declare module "babylonjs/Lights/shadowLight" {
  8826. import { Camera } from "babylonjs/Cameras/camera";
  8827. import { Scene } from "babylonjs/scene";
  8828. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8830. import { Light } from "babylonjs/Lights/light";
  8831. /**
  8832. * Interface describing all the common properties and methods a shadow light needs to implement.
  8833. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8834. * as well as binding the different shadow properties to the effects.
  8835. */
  8836. export interface IShadowLight extends Light {
  8837. /**
  8838. * The light id in the scene (used in scene.findLighById for instance)
  8839. */
  8840. id: string;
  8841. /**
  8842. * The position the shdow will be casted from.
  8843. */
  8844. position: Vector3;
  8845. /**
  8846. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8847. */
  8848. direction: Vector3;
  8849. /**
  8850. * The transformed position. Position of the light in world space taking parenting in account.
  8851. */
  8852. transformedPosition: Vector3;
  8853. /**
  8854. * The transformed direction. Direction of the light in world space taking parenting in account.
  8855. */
  8856. transformedDirection: Vector3;
  8857. /**
  8858. * The friendly name of the light in the scene.
  8859. */
  8860. name: string;
  8861. /**
  8862. * Defines the shadow projection clipping minimum z value.
  8863. */
  8864. shadowMinZ: number;
  8865. /**
  8866. * Defines the shadow projection clipping maximum z value.
  8867. */
  8868. shadowMaxZ: number;
  8869. /**
  8870. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8871. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8872. */
  8873. computeTransformedInformation(): boolean;
  8874. /**
  8875. * Gets the scene the light belongs to.
  8876. * @returns The scene
  8877. */
  8878. getScene(): Scene;
  8879. /**
  8880. * Callback defining a custom Projection Matrix Builder.
  8881. * This can be used to override the default projection matrix computation.
  8882. */
  8883. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8884. /**
  8885. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8886. * @param matrix The materix to updated with the projection information
  8887. * @param viewMatrix The transform matrix of the light
  8888. * @param renderList The list of mesh to render in the map
  8889. * @returns The current light
  8890. */
  8891. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8892. /**
  8893. * Gets the current depth scale used in ESM.
  8894. * @returns The scale
  8895. */
  8896. getDepthScale(): number;
  8897. /**
  8898. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8899. * @returns true if a cube texture needs to be use
  8900. */
  8901. needCube(): boolean;
  8902. /**
  8903. * Detects if the projection matrix requires to be recomputed this frame.
  8904. * @returns true if it requires to be recomputed otherwise, false.
  8905. */
  8906. needProjectionMatrixCompute(): boolean;
  8907. /**
  8908. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8909. */
  8910. forceProjectionMatrixCompute(): void;
  8911. /**
  8912. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8913. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8914. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8915. */
  8916. getShadowDirection(faceIndex?: number): Vector3;
  8917. /**
  8918. * Gets the minZ used for shadow according to both the scene and the light.
  8919. * @param activeCamera The camera we are returning the min for
  8920. * @returns the depth min z
  8921. */
  8922. getDepthMinZ(activeCamera: Camera): number;
  8923. /**
  8924. * Gets the maxZ used for shadow according to both the scene and the light.
  8925. * @param activeCamera The camera we are returning the max for
  8926. * @returns the depth max z
  8927. */
  8928. getDepthMaxZ(activeCamera: Camera): number;
  8929. }
  8930. /**
  8931. * Base implementation IShadowLight
  8932. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8933. */
  8934. export abstract class ShadowLight extends Light implements IShadowLight {
  8935. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8936. protected _position: Vector3;
  8937. protected _setPosition(value: Vector3): void;
  8938. /**
  8939. * Sets the position the shadow will be casted from. Also use as the light position for both
  8940. * point and spot lights.
  8941. */
  8942. /**
  8943. * Sets the position the shadow will be casted from. Also use as the light position for both
  8944. * point and spot lights.
  8945. */
  8946. position: Vector3;
  8947. protected _direction: Vector3;
  8948. protected _setDirection(value: Vector3): void;
  8949. /**
  8950. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8951. * Also use as the light direction on spot and directional lights.
  8952. */
  8953. /**
  8954. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8955. * Also use as the light direction on spot and directional lights.
  8956. */
  8957. direction: Vector3;
  8958. private _shadowMinZ;
  8959. /**
  8960. * Gets the shadow projection clipping minimum z value.
  8961. */
  8962. /**
  8963. * Sets the shadow projection clipping minimum z value.
  8964. */
  8965. shadowMinZ: number;
  8966. private _shadowMaxZ;
  8967. /**
  8968. * Sets the shadow projection clipping maximum z value.
  8969. */
  8970. /**
  8971. * Gets the shadow projection clipping maximum z value.
  8972. */
  8973. shadowMaxZ: number;
  8974. /**
  8975. * Callback defining a custom Projection Matrix Builder.
  8976. * This can be used to override the default projection matrix computation.
  8977. */
  8978. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8979. /**
  8980. * The transformed position. Position of the light in world space taking parenting in account.
  8981. */
  8982. transformedPosition: Vector3;
  8983. /**
  8984. * The transformed direction. Direction of the light in world space taking parenting in account.
  8985. */
  8986. transformedDirection: Vector3;
  8987. private _needProjectionMatrixCompute;
  8988. /**
  8989. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8990. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8991. */
  8992. computeTransformedInformation(): boolean;
  8993. /**
  8994. * Return the depth scale used for the shadow map.
  8995. * @returns the depth scale.
  8996. */
  8997. getDepthScale(): number;
  8998. /**
  8999. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9000. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9001. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9002. */
  9003. getShadowDirection(faceIndex?: number): Vector3;
  9004. /**
  9005. * Returns the ShadowLight absolute position in the World.
  9006. * @returns the position vector in world space
  9007. */
  9008. getAbsolutePosition(): Vector3;
  9009. /**
  9010. * Sets the ShadowLight direction toward the passed target.
  9011. * @param target The point to target in local space
  9012. * @returns the updated ShadowLight direction
  9013. */
  9014. setDirectionToTarget(target: Vector3): Vector3;
  9015. /**
  9016. * Returns the light rotation in euler definition.
  9017. * @returns the x y z rotation in local space.
  9018. */
  9019. getRotation(): Vector3;
  9020. /**
  9021. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9022. * @returns true if a cube texture needs to be use
  9023. */
  9024. needCube(): boolean;
  9025. /**
  9026. * Detects if the projection matrix requires to be recomputed this frame.
  9027. * @returns true if it requires to be recomputed otherwise, false.
  9028. */
  9029. needProjectionMatrixCompute(): boolean;
  9030. /**
  9031. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9032. */
  9033. forceProjectionMatrixCompute(): void;
  9034. /** @hidden */
  9035. _initCache(): void;
  9036. /** @hidden */
  9037. _isSynchronized(): boolean;
  9038. /**
  9039. * Computes the world matrix of the node
  9040. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9041. * @returns the world matrix
  9042. */
  9043. computeWorldMatrix(force?: boolean): Matrix;
  9044. /**
  9045. * Gets the minZ used for shadow according to both the scene and the light.
  9046. * @param activeCamera The camera we are returning the min for
  9047. * @returns the depth min z
  9048. */
  9049. getDepthMinZ(activeCamera: Camera): number;
  9050. /**
  9051. * Gets the maxZ used for shadow according to both the scene and the light.
  9052. * @param activeCamera The camera we are returning the max for
  9053. * @returns the depth max z
  9054. */
  9055. getDepthMaxZ(activeCamera: Camera): number;
  9056. /**
  9057. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9058. * @param matrix The materix to updated with the projection information
  9059. * @param viewMatrix The transform matrix of the light
  9060. * @param renderList The list of mesh to render in the map
  9061. * @returns The current light
  9062. */
  9063. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9064. }
  9065. }
  9066. declare module "babylonjs/Materials/materialHelper" {
  9067. import { Nullable } from "babylonjs/types";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Engine } from "babylonjs/Engines/engine";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9073. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9075. /**
  9076. * "Static Class" containing the most commonly used helper while dealing with material for
  9077. * rendering purpose.
  9078. *
  9079. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9080. *
  9081. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9082. */
  9083. export class MaterialHelper {
  9084. /**
  9085. * Bind the current view position to an effect.
  9086. * @param effect The effect to be bound
  9087. * @param scene The scene the eyes position is used from
  9088. */
  9089. static BindEyePosition(effect: Effect, scene: Scene): void;
  9090. /**
  9091. * Helps preparing the defines values about the UVs in used in the effect.
  9092. * UVs are shared as much as we can accross channels in the shaders.
  9093. * @param texture The texture we are preparing the UVs for
  9094. * @param defines The defines to update
  9095. * @param key The channel key "diffuse", "specular"... used in the shader
  9096. */
  9097. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9098. /**
  9099. * Binds a texture matrix value to its corrsponding uniform
  9100. * @param texture The texture to bind the matrix for
  9101. * @param uniformBuffer The uniform buffer receivin the data
  9102. * @param key The channel key "diffuse", "specular"... used in the shader
  9103. */
  9104. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9105. /**
  9106. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9107. * @param mesh defines the current mesh
  9108. * @param scene defines the current scene
  9109. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9110. * @param pointsCloud defines if point cloud rendering has to be turned on
  9111. * @param fogEnabled defines if fog has to be turned on
  9112. * @param alphaTest defines if alpha testing has to be turned on
  9113. * @param defines defines the current list of defines
  9114. */
  9115. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9116. /**
  9117. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9118. * @param scene defines the current scene
  9119. * @param engine defines the current engine
  9120. * @param defines specifies the list of active defines
  9121. * @param useInstances defines if instances have to be turned on
  9122. * @param useClipPlane defines if clip plane have to be turned on
  9123. */
  9124. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9125. /**
  9126. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9127. * @param mesh The mesh containing the geometry data we will draw
  9128. * @param defines The defines to update
  9129. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9130. * @param useBones Precise whether bones should be used or not (override mesh info)
  9131. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9132. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9133. * @returns false if defines are considered not dirty and have not been checked
  9134. */
  9135. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9136. /**
  9137. * Prepares the defines related to the light information passed in parameter
  9138. * @param scene The scene we are intending to draw
  9139. * @param mesh The mesh the effect is compiling for
  9140. * @param defines The defines to update
  9141. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9142. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9143. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9144. * @returns true if normals will be required for the rest of the effect
  9145. */
  9146. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9147. /**
  9148. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9149. * that won t be acctive due to defines being turned off.
  9150. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9151. * @param samplersList The samplers list
  9152. * @param defines The defines helping in the list generation
  9153. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9154. */
  9155. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9156. /**
  9157. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9158. * @param defines The defines to update while falling back
  9159. * @param fallbacks The authorized effect fallbacks
  9160. * @param maxSimultaneousLights The maximum number of lights allowed
  9161. * @param rank the current rank of the Effect
  9162. * @returns The newly affected rank
  9163. */
  9164. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9165. /**
  9166. * Prepares the list of attributes required for morph targets according to the effect defines.
  9167. * @param attribs The current list of supported attribs
  9168. * @param mesh The mesh to prepare the morph targets attributes for
  9169. * @param defines The current Defines of the effect
  9170. */
  9171. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9172. /**
  9173. * Prepares the list of attributes required for bones according to the effect defines.
  9174. * @param attribs The current list of supported attribs
  9175. * @param mesh The mesh to prepare the bones attributes for
  9176. * @param defines The current Defines of the effect
  9177. * @param fallbacks The current efffect fallback strategy
  9178. */
  9179. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9180. /**
  9181. * Prepares the list of attributes required for instances according to the effect defines.
  9182. * @param attribs The current list of supported attribs
  9183. * @param defines The current Defines of the effect
  9184. */
  9185. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9186. /**
  9187. * Binds the light shadow information to the effect for the given mesh.
  9188. * @param light The light containing the generator
  9189. * @param scene The scene the lights belongs to
  9190. * @param mesh The mesh we are binding the information to render
  9191. * @param lightIndex The light index in the effect used to render the mesh
  9192. * @param effect The effect we are binding the data to
  9193. */
  9194. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9195. /**
  9196. * Binds the light information to the effect.
  9197. * @param light The light containing the generator
  9198. * @param effect The effect we are binding the data to
  9199. * @param lightIndex The light index in the effect used to render
  9200. */
  9201. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9202. /**
  9203. * Binds the lights information from the scene to the effect for the given mesh.
  9204. * @param scene The scene the lights belongs to
  9205. * @param mesh The mesh we are binding the information to render
  9206. * @param effect The effect we are binding the data to
  9207. * @param defines The generated defines for the effect
  9208. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9209. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9210. */
  9211. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9212. private static _tempFogColor;
  9213. /**
  9214. * Binds the fog information from the scene to the effect for the given mesh.
  9215. * @param scene The scene the lights belongs to
  9216. * @param mesh The mesh we are binding the information to render
  9217. * @param effect The effect we are binding the data to
  9218. * @param linearSpace Defines if the fog effect is applied in linear space
  9219. */
  9220. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9221. /**
  9222. * Binds the bones information from the mesh to the effect.
  9223. * @param mesh The mesh we are binding the information to render
  9224. * @param effect The effect we are binding the data to
  9225. */
  9226. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9227. /**
  9228. * Binds the morph targets information from the mesh to the effect.
  9229. * @param abstractMesh The mesh we are binding the information to render
  9230. * @param effect The effect we are binding the data to
  9231. */
  9232. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9233. /**
  9234. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9235. * @param defines The generated defines used in the effect
  9236. * @param effect The effect we are binding the data to
  9237. * @param scene The scene we are willing to render with logarithmic scale for
  9238. */
  9239. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9240. /**
  9241. * Binds the clip plane information from the scene to the effect.
  9242. * @param scene The scene the clip plane information are extracted from
  9243. * @param effect The effect we are binding the data to
  9244. */
  9245. static BindClipPlane(effect: Effect, scene: Scene): void;
  9246. }
  9247. }
  9248. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9249. /** @hidden */
  9250. export var kernelBlurVaryingDeclaration: {
  9251. name: string;
  9252. shader: string;
  9253. };
  9254. }
  9255. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9256. /** @hidden */
  9257. export var kernelBlurFragment: {
  9258. name: string;
  9259. shader: string;
  9260. };
  9261. }
  9262. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9263. /** @hidden */
  9264. export var kernelBlurFragment2: {
  9265. name: string;
  9266. shader: string;
  9267. };
  9268. }
  9269. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9270. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9271. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9272. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9273. /** @hidden */
  9274. export var kernelBlurPixelShader: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9280. /** @hidden */
  9281. export var kernelBlurVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9287. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9288. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9289. /** @hidden */
  9290. export var kernelBlurVertexShader: {
  9291. name: string;
  9292. shader: string;
  9293. };
  9294. }
  9295. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9296. import { Vector2 } from "babylonjs/Maths/math";
  9297. import { Nullable } from "babylonjs/types";
  9298. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9299. import { Camera } from "babylonjs/Cameras/camera";
  9300. import { Effect } from "babylonjs/Materials/effect";
  9301. import { Engine } from "babylonjs/Engines/engine";
  9302. import "babylonjs/Shaders/kernelBlur.fragment";
  9303. import "babylonjs/Shaders/kernelBlur.vertex";
  9304. /**
  9305. * The Blur Post Process which blurs an image based on a kernel and direction.
  9306. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9307. */
  9308. export class BlurPostProcess extends PostProcess {
  9309. /** The direction in which to blur the image. */
  9310. direction: Vector2;
  9311. private blockCompilation;
  9312. protected _kernel: number;
  9313. protected _idealKernel: number;
  9314. protected _packedFloat: boolean;
  9315. private _staticDefines;
  9316. /**
  9317. * Sets the length in pixels of the blur sample region
  9318. */
  9319. /**
  9320. * Gets the length in pixels of the blur sample region
  9321. */
  9322. kernel: number;
  9323. /**
  9324. * Sets wether or not the blur needs to unpack/repack floats
  9325. */
  9326. /**
  9327. * Gets wether or not the blur is unpacking/repacking floats
  9328. */
  9329. packedFloat: boolean;
  9330. /**
  9331. * Creates a new instance BlurPostProcess
  9332. * @param name The name of the effect.
  9333. * @param direction The direction in which to blur the image.
  9334. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  9335. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9336. * @param camera The camera to apply the render pass to.
  9337. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9338. * @param engine The engine which the post process will be applied. (default: current engine)
  9339. * @param reusable If the post process can be reused on the same frame. (default: false)
  9340. * @param textureType Type of textures used when performing the post process. (default: 0)
  9341. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  9342. */
  9343. constructor(name: string,
  9344. /** The direction in which to blur the image. */
  9345. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9346. /**
  9347. * Updates the effect with the current post process compile time values and recompiles the shader.
  9348. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9349. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9350. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9351. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  9352. * @param onCompiled Called when the shader has been compiled.
  9353. * @param onError Called if there is an error when compiling a shader.
  9354. */
  9355. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9356. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9357. /**
  9358. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9359. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9360. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9361. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9362. * The gaps between physical kernels are compensated for in the weighting of the samples
  9363. * @param idealKernel Ideal blur kernel.
  9364. * @return Nearest best kernel.
  9365. */
  9366. protected _nearestBestKernel(idealKernel: number): number;
  9367. /**
  9368. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9369. * @param x The point on the Gaussian distribution to sample.
  9370. * @return the value of the Gaussian function at x.
  9371. */
  9372. protected _gaussianWeight(x: number): number;
  9373. /**
  9374. * Generates a string that can be used as a floating point number in GLSL.
  9375. * @param x Value to print.
  9376. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9377. * @return GLSL float string.
  9378. */
  9379. protected _glslFloat(x: number, decimalFigures?: number): string;
  9380. }
  9381. }
  9382. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9383. /** @hidden */
  9384. export var shadowMapPixelShader: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9390. /** @hidden */
  9391. export var bonesDeclaration: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9397. /** @hidden */
  9398. export var morphTargetsVertexGlobalDeclaration: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9404. /** @hidden */
  9405. export var morphTargetsVertexDeclaration: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9411. /** @hidden */
  9412. export var instancesDeclaration: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9418. /** @hidden */
  9419. export var helperFunctions: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9425. /** @hidden */
  9426. export var morphTargetsVertex: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9432. /** @hidden */
  9433. export var instancesVertex: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9439. /** @hidden */
  9440. export var bonesVertex: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9446. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9448. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9449. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9450. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9451. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9452. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9453. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9454. /** @hidden */
  9455. export var shadowMapVertexShader: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9461. /** @hidden */
  9462. export var depthBoxBlurPixelShader: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9468. import { Nullable } from "babylonjs/types";
  9469. import { Scene } from "babylonjs/scene";
  9470. import { Matrix } from "babylonjs/Maths/math";
  9471. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9473. import { Mesh } from "babylonjs/Meshes/mesh";
  9474. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9475. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9476. import { Effect } from "babylonjs/Materials/effect";
  9477. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9478. import "babylonjs/Shaders/shadowMap.fragment";
  9479. import "babylonjs/Shaders/shadowMap.vertex";
  9480. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9481. import { Observable } from "babylonjs/Misc/observable";
  9482. /**
  9483. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9484. */
  9485. export interface ICustomShaderOptions {
  9486. /**
  9487. * Gets or sets the custom shader name to use
  9488. */
  9489. shaderName: string;
  9490. /**
  9491. * The list of attribute names used in the shader
  9492. */
  9493. attributes?: string[];
  9494. /**
  9495. * The list of unifrom names used in the shader
  9496. */
  9497. uniforms?: string[];
  9498. /**
  9499. * The list of sampler names used in the shader
  9500. */
  9501. samplers?: string[];
  9502. /**
  9503. * The list of defines used in the shader
  9504. */
  9505. defines?: string[];
  9506. }
  9507. /**
  9508. * Interface to implement to create a shadow generator compatible with BJS.
  9509. */
  9510. export interface IShadowGenerator {
  9511. /**
  9512. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9513. * @returns The render target texture if present otherwise, null
  9514. */
  9515. getShadowMap(): Nullable<RenderTargetTexture>;
  9516. /**
  9517. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9518. * @returns The render target texture if the shadow map is present otherwise, null
  9519. */
  9520. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9521. /**
  9522. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9523. * @param subMesh The submesh we want to render in the shadow map
  9524. * @param useInstances Defines wether will draw in the map using instances
  9525. * @returns true if ready otherwise, false
  9526. */
  9527. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9528. /**
  9529. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9530. * @param defines Defines of the material we want to update
  9531. * @param lightIndex Index of the light in the enabled light list of the material
  9532. */
  9533. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9534. /**
  9535. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9536. * defined in the generator but impacting the effect).
  9537. * It implies the unifroms available on the materials are the standard BJS ones.
  9538. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9539. * @param effect The effect we are binfing the information for
  9540. */
  9541. bindShadowLight(lightIndex: string, effect: Effect): void;
  9542. /**
  9543. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9544. * (eq to shadow prjection matrix * light transform matrix)
  9545. * @returns The transform matrix used to create the shadow map
  9546. */
  9547. getTransformMatrix(): Matrix;
  9548. /**
  9549. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9550. * Cube and 2D textures for instance.
  9551. */
  9552. recreateShadowMap(): void;
  9553. /**
  9554. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9555. * @param onCompiled Callback triggered at the and of the effects compilation
  9556. * @param options Sets of optional options forcing the compilation with different modes
  9557. */
  9558. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9559. useInstances: boolean;
  9560. }>): void;
  9561. /**
  9562. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9563. * @param options Sets of optional options forcing the compilation with different modes
  9564. * @returns A promise that resolves when the compilation completes
  9565. */
  9566. forceCompilationAsync(options?: Partial<{
  9567. useInstances: boolean;
  9568. }>): Promise<void>;
  9569. /**
  9570. * Serializes the shadow generator setup to a json object.
  9571. * @returns The serialized JSON object
  9572. */
  9573. serialize(): any;
  9574. /**
  9575. * Disposes the Shadow map and related Textures and effects.
  9576. */
  9577. dispose(): void;
  9578. }
  9579. /**
  9580. * Default implementation IShadowGenerator.
  9581. * This is the main object responsible of generating shadows in the framework.
  9582. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9583. */
  9584. export class ShadowGenerator implements IShadowGenerator {
  9585. /**
  9586. * Shadow generator mode None: no filtering applied.
  9587. */
  9588. static readonly FILTER_NONE: number;
  9589. /**
  9590. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9592. */
  9593. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9594. /**
  9595. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9596. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9597. */
  9598. static readonly FILTER_POISSONSAMPLING: number;
  9599. /**
  9600. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9601. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9602. */
  9603. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9604. /**
  9605. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9606. * edge artifacts on steep falloff.
  9607. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9608. */
  9609. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9610. /**
  9611. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9612. * edge artifacts on steep falloff.
  9613. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9614. */
  9615. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9616. /**
  9617. * Shadow generator mode PCF: Percentage Closer Filtering
  9618. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9619. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9620. */
  9621. static readonly FILTER_PCF: number;
  9622. /**
  9623. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9624. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9625. * Contact Hardening
  9626. */
  9627. static readonly FILTER_PCSS: number;
  9628. /**
  9629. * Reserved for PCF and PCSS
  9630. * Highest Quality.
  9631. *
  9632. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9633. *
  9634. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9635. */
  9636. static readonly QUALITY_HIGH: number;
  9637. /**
  9638. * Reserved for PCF and PCSS
  9639. * Good tradeoff for quality/perf cross devices
  9640. *
  9641. * Execute PCF on a 3*3 kernel.
  9642. *
  9643. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9644. */
  9645. static readonly QUALITY_MEDIUM: number;
  9646. /**
  9647. * Reserved for PCF and PCSS
  9648. * The lowest quality but the fastest.
  9649. *
  9650. * Execute PCF on a 1*1 kernel.
  9651. *
  9652. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9653. */
  9654. static readonly QUALITY_LOW: number;
  9655. /** Gets or sets the custom shader name to use */
  9656. customShaderOptions: ICustomShaderOptions;
  9657. /**
  9658. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9659. */
  9660. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9661. /**
  9662. * Observable triggered before a mesh is rendered in the shadow map.
  9663. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9664. */
  9665. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9666. private _bias;
  9667. /**
  9668. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9669. */
  9670. /**
  9671. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9672. */
  9673. bias: number;
  9674. private _normalBias;
  9675. /**
  9676. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9677. */
  9678. /**
  9679. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9680. */
  9681. normalBias: number;
  9682. private _blurBoxOffset;
  9683. /**
  9684. * Gets the blur box offset: offset applied during the blur pass.
  9685. * Only useful if useKernelBlur = false
  9686. */
  9687. /**
  9688. * Sets the blur box offset: offset applied during the blur pass.
  9689. * Only useful if useKernelBlur = false
  9690. */
  9691. blurBoxOffset: number;
  9692. private _blurScale;
  9693. /**
  9694. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9695. * 2 means half of the size.
  9696. */
  9697. /**
  9698. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9699. * 2 means half of the size.
  9700. */
  9701. blurScale: number;
  9702. private _blurKernel;
  9703. /**
  9704. * Gets the blur kernel: kernel size of the blur pass.
  9705. * Only useful if useKernelBlur = true
  9706. */
  9707. /**
  9708. * Sets the blur kernel: kernel size of the blur pass.
  9709. * Only useful if useKernelBlur = true
  9710. */
  9711. blurKernel: number;
  9712. private _useKernelBlur;
  9713. /**
  9714. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9715. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9716. */
  9717. /**
  9718. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9719. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9720. */
  9721. useKernelBlur: boolean;
  9722. private _depthScale;
  9723. /**
  9724. * Gets the depth scale used in ESM mode.
  9725. */
  9726. /**
  9727. * Sets the depth scale used in ESM mode.
  9728. * This can override the scale stored on the light.
  9729. */
  9730. depthScale: number;
  9731. private _filter;
  9732. /**
  9733. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9734. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9735. */
  9736. /**
  9737. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9738. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9739. */
  9740. filter: number;
  9741. /**
  9742. * Gets if the current filter is set to Poisson Sampling.
  9743. */
  9744. /**
  9745. * Sets the current filter to Poisson Sampling.
  9746. */
  9747. usePoissonSampling: boolean;
  9748. /**
  9749. * Gets if the current filter is set to ESM.
  9750. */
  9751. /**
  9752. * Sets the current filter is to ESM.
  9753. */
  9754. useExponentialShadowMap: boolean;
  9755. /**
  9756. * Gets if the current filter is set to filtered ESM.
  9757. */
  9758. /**
  9759. * Gets if the current filter is set to filtered ESM.
  9760. */
  9761. useBlurExponentialShadowMap: boolean;
  9762. /**
  9763. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9764. * exponential to prevent steep falloff artifacts).
  9765. */
  9766. /**
  9767. * Sets the current filter to "close ESM" (using the inverse of the
  9768. * exponential to prevent steep falloff artifacts).
  9769. */
  9770. useCloseExponentialShadowMap: boolean;
  9771. /**
  9772. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9773. * exponential to prevent steep falloff artifacts).
  9774. */
  9775. /**
  9776. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9777. * exponential to prevent steep falloff artifacts).
  9778. */
  9779. useBlurCloseExponentialShadowMap: boolean;
  9780. /**
  9781. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9782. */
  9783. /**
  9784. * Sets the current filter to "PCF" (percentage closer filtering).
  9785. */
  9786. usePercentageCloserFiltering: boolean;
  9787. private _filteringQuality;
  9788. /**
  9789. * Gets the PCF or PCSS Quality.
  9790. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9791. */
  9792. /**
  9793. * Sets the PCF or PCSS Quality.
  9794. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9795. */
  9796. filteringQuality: number;
  9797. /**
  9798. * Gets if the current filter is set to "PCSS" (contact hardening).
  9799. */
  9800. /**
  9801. * Sets the current filter to "PCSS" (contact hardening).
  9802. */
  9803. useContactHardeningShadow: boolean;
  9804. private _contactHardeningLightSizeUVRatio;
  9805. /**
  9806. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9807. * Using a ratio helps keeping shape stability independently of the map size.
  9808. *
  9809. * It does not account for the light projection as it was having too much
  9810. * instability during the light setup or during light position changes.
  9811. *
  9812. * Only valid if useContactHardeningShadow is true.
  9813. */
  9814. /**
  9815. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9816. * Using a ratio helps keeping shape stability independently of the map size.
  9817. *
  9818. * It does not account for the light projection as it was having too much
  9819. * instability during the light setup or during light position changes.
  9820. *
  9821. * Only valid if useContactHardeningShadow is true.
  9822. */
  9823. contactHardeningLightSizeUVRatio: number;
  9824. private _darkness;
  9825. /**
  9826. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9827. * 0 means strongest and 1 would means no shadow.
  9828. * @returns the darkness.
  9829. */
  9830. getDarkness(): number;
  9831. /**
  9832. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9833. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9834. * @returns the shadow generator allowing fluent coding.
  9835. */
  9836. setDarkness(darkness: number): ShadowGenerator;
  9837. private _transparencyShadow;
  9838. /**
  9839. * Sets the ability to have transparent shadow (boolean).
  9840. * @param transparent True if transparent else False
  9841. * @returns the shadow generator allowing fluent coding
  9842. */
  9843. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9844. private _shadowMap;
  9845. private _shadowMap2;
  9846. /**
  9847. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9848. * @returns The render target texture if present otherwise, null
  9849. */
  9850. getShadowMap(): Nullable<RenderTargetTexture>;
  9851. /**
  9852. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9853. * @returns The render target texture if the shadow map is present otherwise, null
  9854. */
  9855. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9856. /**
  9857. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9858. * @param mesh Mesh to add
  9859. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9860. * @returns the Shadow Generator itself
  9861. */
  9862. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9863. /**
  9864. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9865. * @param mesh Mesh to remove
  9866. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9867. * @returns the Shadow Generator itself
  9868. */
  9869. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9870. /**
  9871. * Controls the extent to which the shadows fade out at the edge of the frustum
  9872. * Used only by directionals and spots
  9873. */
  9874. frustumEdgeFalloff: number;
  9875. private _light;
  9876. /**
  9877. * Returns the associated light object.
  9878. * @returns the light generating the shadow
  9879. */
  9880. getLight(): IShadowLight;
  9881. /**
  9882. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9883. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9884. * It might on the other hand introduce peter panning.
  9885. */
  9886. forceBackFacesOnly: boolean;
  9887. private _scene;
  9888. private _lightDirection;
  9889. private _effect;
  9890. private _viewMatrix;
  9891. private _projectionMatrix;
  9892. private _transformMatrix;
  9893. private _cachedPosition;
  9894. private _cachedDirection;
  9895. private _cachedDefines;
  9896. private _currentRenderID;
  9897. private _boxBlurPostprocess;
  9898. private _kernelBlurXPostprocess;
  9899. private _kernelBlurYPostprocess;
  9900. private _blurPostProcesses;
  9901. private _mapSize;
  9902. private _currentFaceIndex;
  9903. private _currentFaceIndexCache;
  9904. private _textureType;
  9905. private _defaultTextureMatrix;
  9906. /** @hidden */
  9907. static _SceneComponentInitialization: (scene: Scene) => void;
  9908. /**
  9909. * Creates a ShadowGenerator object.
  9910. * A ShadowGenerator is the required tool to use the shadows.
  9911. * Each light casting shadows needs to use its own ShadowGenerator.
  9912. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9913. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9914. * @param light The light object generating the shadows.
  9915. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9916. */
  9917. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9918. private _initializeGenerator;
  9919. private _initializeShadowMap;
  9920. private _initializeBlurRTTAndPostProcesses;
  9921. private _renderForShadowMap;
  9922. private _renderSubMeshForShadowMap;
  9923. private _applyFilterValues;
  9924. /**
  9925. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9926. * @param onCompiled Callback triggered at the and of the effects compilation
  9927. * @param options Sets of optional options forcing the compilation with different modes
  9928. */
  9929. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9930. useInstances: boolean;
  9931. }>): void;
  9932. /**
  9933. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9934. * @param options Sets of optional options forcing the compilation with different modes
  9935. * @returns A promise that resolves when the compilation completes
  9936. */
  9937. forceCompilationAsync(options?: Partial<{
  9938. useInstances: boolean;
  9939. }>): Promise<void>;
  9940. /**
  9941. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9942. * @param subMesh The submesh we want to render in the shadow map
  9943. * @param useInstances Defines wether will draw in the map using instances
  9944. * @returns true if ready otherwise, false
  9945. */
  9946. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9947. /**
  9948. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9949. * @param defines Defines of the material we want to update
  9950. * @param lightIndex Index of the light in the enabled light list of the material
  9951. */
  9952. prepareDefines(defines: any, lightIndex: number): void;
  9953. /**
  9954. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9955. * defined in the generator but impacting the effect).
  9956. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9957. * @param effect The effect we are binfing the information for
  9958. */
  9959. bindShadowLight(lightIndex: string, effect: Effect): void;
  9960. /**
  9961. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9962. * (eq to shadow prjection matrix * light transform matrix)
  9963. * @returns The transform matrix used to create the shadow map
  9964. */
  9965. getTransformMatrix(): Matrix;
  9966. /**
  9967. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9968. * Cube and 2D textures for instance.
  9969. */
  9970. recreateShadowMap(): void;
  9971. private _disposeBlurPostProcesses;
  9972. private _disposeRTTandPostProcesses;
  9973. /**
  9974. * Disposes the ShadowGenerator.
  9975. * Returns nothing.
  9976. */
  9977. dispose(): void;
  9978. /**
  9979. * Serializes the shadow generator setup to a json object.
  9980. * @returns The serialized JSON object
  9981. */
  9982. serialize(): any;
  9983. /**
  9984. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9985. * @param parsedShadowGenerator The JSON object to parse
  9986. * @param scene The scene to create the shadow map for
  9987. * @returns The parsed shadow generator
  9988. */
  9989. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9990. }
  9991. }
  9992. declare module "babylonjs/Lights/light" {
  9993. import { Nullable } from "babylonjs/types";
  9994. import { Scene } from "babylonjs/scene";
  9995. import { Vector3, Color3 } from "babylonjs/Maths/math";
  9996. import { Node } from "babylonjs/node";
  9997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9998. import { Effect } from "babylonjs/Materials/effect";
  9999. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10000. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10001. /**
  10002. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10003. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10004. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  10005. */
  10006. export abstract class Light extends Node {
  10007. /**
  10008. * Falloff Default: light is falling off following the material specification:
  10009. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10010. */
  10011. static readonly FALLOFF_DEFAULT: number;
  10012. /**
  10013. * Falloff Physical: light is falling off following the inverse squared distance law.
  10014. */
  10015. static readonly FALLOFF_PHYSICAL: number;
  10016. /**
  10017. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10018. * to enhance interoperability with other engines.
  10019. */
  10020. static readonly FALLOFF_GLTF: number;
  10021. /**
  10022. * Falloff Standard: light is falling off like in the standard material
  10023. * to enhance interoperability with other materials.
  10024. */
  10025. static readonly FALLOFF_STANDARD: number;
  10026. /**
  10027. * If every light affecting the material is in this lightmapMode,
  10028. * material.lightmapTexture adds or multiplies
  10029. * (depends on material.useLightmapAsShadowmap)
  10030. * after every other light calculations.
  10031. */
  10032. static readonly LIGHTMAP_DEFAULT: number;
  10033. /**
  10034. * material.lightmapTexture as only diffuse lighting from this light
  10035. * adds only specular lighting from this light
  10036. * adds dynamic shadows
  10037. */
  10038. static readonly LIGHTMAP_SPECULAR: number;
  10039. /**
  10040. * material.lightmapTexture as only lighting
  10041. * no light calculation from this light
  10042. * only adds dynamic shadows from this light
  10043. */
  10044. static readonly LIGHTMAP_SHADOWSONLY: number;
  10045. /**
  10046. * Each light type uses the default quantity according to its type:
  10047. * point/spot lights use luminous intensity
  10048. * directional lights use illuminance
  10049. */
  10050. static readonly INTENSITYMODE_AUTOMATIC: number;
  10051. /**
  10052. * lumen (lm)
  10053. */
  10054. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10055. /**
  10056. * candela (lm/sr)
  10057. */
  10058. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10059. /**
  10060. * lux (lm/m^2)
  10061. */
  10062. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10063. /**
  10064. * nit (cd/m^2)
  10065. */
  10066. static readonly INTENSITYMODE_LUMINANCE: number;
  10067. /**
  10068. * Light type const id of the point light.
  10069. */
  10070. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10071. /**
  10072. * Light type const id of the directional light.
  10073. */
  10074. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10075. /**
  10076. * Light type const id of the spot light.
  10077. */
  10078. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10079. /**
  10080. * Light type const id of the hemispheric light.
  10081. */
  10082. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10083. /**
  10084. * Diffuse gives the basic color to an object.
  10085. */
  10086. diffuse: Color3;
  10087. /**
  10088. * Specular produces a highlight color on an object.
  10089. * Note: This is note affecting PBR materials.
  10090. */
  10091. specular: Color3;
  10092. /**
  10093. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10094. * falling off base on range or angle.
  10095. * This can be set to any values in Light.FALLOFF_x.
  10096. *
  10097. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10098. * other types of materials.
  10099. */
  10100. falloffType: number;
  10101. /**
  10102. * Strength of the light.
  10103. * Note: By default it is define in the framework own unit.
  10104. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10105. */
  10106. intensity: number;
  10107. private _range;
  10108. protected _inverseSquaredRange: number;
  10109. /**
  10110. * Defines how far from the source the light is impacting in scene units.
  10111. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10112. */
  10113. /**
  10114. * Defines how far from the source the light is impacting in scene units.
  10115. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10116. */
  10117. range: number;
  10118. /**
  10119. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10120. * of light.
  10121. */
  10122. private _photometricScale;
  10123. private _intensityMode;
  10124. /**
  10125. * Gets the photometric scale used to interpret the intensity.
  10126. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10127. */
  10128. /**
  10129. * Sets the photometric scale used to interpret the intensity.
  10130. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10131. */
  10132. intensityMode: number;
  10133. private _radius;
  10134. /**
  10135. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10136. */
  10137. /**
  10138. * sets the light radius used by PBR Materials to simulate soft area lights.
  10139. */
  10140. radius: number;
  10141. private _renderPriority;
  10142. /**
  10143. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10144. * exceeding the number allowed of the materials.
  10145. */
  10146. renderPriority: number;
  10147. private _shadowEnabled;
  10148. /**
  10149. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10150. * the current shadow generator.
  10151. */
  10152. /**
  10153. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10154. * the current shadow generator.
  10155. */
  10156. shadowEnabled: boolean;
  10157. private _includedOnlyMeshes;
  10158. /**
  10159. * Gets the only meshes impacted by this light.
  10160. */
  10161. /**
  10162. * Sets the only meshes impacted by this light.
  10163. */
  10164. includedOnlyMeshes: AbstractMesh[];
  10165. private _excludedMeshes;
  10166. /**
  10167. * Gets the meshes not impacted by this light.
  10168. */
  10169. /**
  10170. * Sets the meshes not impacted by this light.
  10171. */
  10172. excludedMeshes: AbstractMesh[];
  10173. private _excludeWithLayerMask;
  10174. /**
  10175. * Gets the layer id use to find what meshes are not impacted by the light.
  10176. * Inactive if 0
  10177. */
  10178. /**
  10179. * Sets the layer id use to find what meshes are not impacted by the light.
  10180. * Inactive if 0
  10181. */
  10182. excludeWithLayerMask: number;
  10183. private _includeOnlyWithLayerMask;
  10184. /**
  10185. * Gets the layer id use to find what meshes are impacted by the light.
  10186. * Inactive if 0
  10187. */
  10188. /**
  10189. * Sets the layer id use to find what meshes are impacted by the light.
  10190. * Inactive if 0
  10191. */
  10192. includeOnlyWithLayerMask: number;
  10193. private _lightmapMode;
  10194. /**
  10195. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10196. */
  10197. /**
  10198. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10199. */
  10200. lightmapMode: number;
  10201. /**
  10202. * Shadow generator associted to the light.
  10203. * @hidden Internal use only.
  10204. */
  10205. _shadowGenerator: Nullable<IShadowGenerator>;
  10206. /**
  10207. * @hidden Internal use only.
  10208. */
  10209. _excludedMeshesIds: string[];
  10210. /**
  10211. * @hidden Internal use only.
  10212. */
  10213. _includedOnlyMeshesIds: string[];
  10214. /**
  10215. * The current light unifom buffer.
  10216. * @hidden Internal use only.
  10217. */
  10218. _uniformBuffer: UniformBuffer;
  10219. /**
  10220. * Creates a Light object in the scene.
  10221. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10222. * @param name The firendly name of the light
  10223. * @param scene The scene the light belongs too
  10224. */
  10225. constructor(name: string, scene: Scene);
  10226. protected abstract _buildUniformLayout(): void;
  10227. /**
  10228. * Sets the passed Effect "effect" with the Light information.
  10229. * @param effect The effect to update
  10230. * @param lightIndex The index of the light in the effect to update
  10231. * @returns The light
  10232. */
  10233. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10234. /**
  10235. * Returns the string "Light".
  10236. * @returns the class name
  10237. */
  10238. getClassName(): string;
  10239. /** @hidden */
  10240. readonly _isLight: boolean;
  10241. /**
  10242. * Converts the light information to a readable string for debug purpose.
  10243. * @param fullDetails Supports for multiple levels of logging within scene loading
  10244. * @returns the human readable light info
  10245. */
  10246. toString(fullDetails?: boolean): string;
  10247. /** @hidden */
  10248. protected _syncParentEnabledState(): void;
  10249. /**
  10250. * Set the enabled state of this node.
  10251. * @param value - the new enabled state
  10252. */
  10253. setEnabled(value: boolean): void;
  10254. /**
  10255. * Returns the Light associated shadow generator if any.
  10256. * @return the associated shadow generator.
  10257. */
  10258. getShadowGenerator(): Nullable<IShadowGenerator>;
  10259. /**
  10260. * Returns a Vector3, the absolute light position in the World.
  10261. * @returns the world space position of the light
  10262. */
  10263. getAbsolutePosition(): Vector3;
  10264. /**
  10265. * Specifies if the light will affect the passed mesh.
  10266. * @param mesh The mesh to test against the light
  10267. * @return true the mesh is affected otherwise, false.
  10268. */
  10269. canAffectMesh(mesh: AbstractMesh): boolean;
  10270. /**
  10271. * Sort function to order lights for rendering.
  10272. * @param a First Light object to compare to second.
  10273. * @param b Second Light object to compare first.
  10274. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10275. */
  10276. static CompareLightsPriority(a: Light, b: Light): number;
  10277. /**
  10278. * Releases resources associated with this node.
  10279. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10280. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10281. */
  10282. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10283. /**
  10284. * Returns the light type ID (integer).
  10285. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10286. */
  10287. getTypeID(): number;
  10288. /**
  10289. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10290. * @returns the scaled intensity in intensity mode unit
  10291. */
  10292. getScaledIntensity(): number;
  10293. /**
  10294. * Returns a new Light object, named "name", from the current one.
  10295. * @param name The name of the cloned light
  10296. * @returns the new created light
  10297. */
  10298. clone(name: string): Nullable<Light>;
  10299. /**
  10300. * Serializes the current light into a Serialization object.
  10301. * @returns the serialized object.
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10306. * This new light is named "name" and added to the passed scene.
  10307. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10308. * @param name The friendly name of the light
  10309. * @param scene The scene the new light will belong to
  10310. * @returns the constructor function
  10311. */
  10312. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10313. /**
  10314. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10315. * @param parsedLight The JSON representation of the light
  10316. * @param scene The scene to create the parsed light in
  10317. * @returns the created light after parsing
  10318. */
  10319. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10320. private _hookArrayForExcluded;
  10321. private _hookArrayForIncludedOnly;
  10322. private _resyncMeshes;
  10323. /**
  10324. * Forces the meshes to update their light related information in their rendering used effects
  10325. * @hidden Internal Use Only
  10326. */
  10327. _markMeshesAsLightDirty(): void;
  10328. /**
  10329. * Recomputes the cached photometric scale if needed.
  10330. */
  10331. private _computePhotometricScale;
  10332. /**
  10333. * Returns the Photometric Scale according to the light type and intensity mode.
  10334. */
  10335. private _getPhotometricScale;
  10336. /**
  10337. * Reorder the light in the scene according to their defined priority.
  10338. * @hidden Internal Use Only
  10339. */
  10340. _reorderLightsInScene(): void;
  10341. /**
  10342. * Prepares the list of defines specific to the light type.
  10343. * @param defines the list of defines
  10344. * @param lightIndex defines the index of the light for the effect
  10345. */
  10346. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10347. }
  10348. }
  10349. declare module "babylonjs/Actions/action" {
  10350. import { Observable } from "babylonjs/Misc/observable";
  10351. import { Condition } from "babylonjs/Actions/condition";
  10352. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10353. import { ActionManager } from "babylonjs/Actions/actionManager";
  10354. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10355. /**
  10356. * Interface used to define Action
  10357. */
  10358. export interface IAction {
  10359. /**
  10360. * Trigger for the action
  10361. */
  10362. trigger: number;
  10363. /** Options of the trigger */
  10364. triggerOptions: any;
  10365. /**
  10366. * Gets the trigger parameters
  10367. * @returns the trigger parameters
  10368. */
  10369. getTriggerParameter(): any;
  10370. /**
  10371. * Internal only - executes current action event
  10372. * @hidden
  10373. */
  10374. _executeCurrent(evt?: ActionEvent): void;
  10375. /**
  10376. * Serialize placeholder for child classes
  10377. * @param parent of child
  10378. * @returns the serialized object
  10379. */
  10380. serialize(parent: any): any;
  10381. /**
  10382. * Internal only
  10383. * @hidden
  10384. */
  10385. _prepare(): void;
  10386. /**
  10387. * Internal only - manager for action
  10388. * @hidden
  10389. */
  10390. _actionManager: AbstractActionManager;
  10391. }
  10392. /**
  10393. * The action to be carried out following a trigger
  10394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10395. */
  10396. export class Action implements IAction {
  10397. /** the trigger, with or without parameters, for the action */
  10398. triggerOptions: any;
  10399. /**
  10400. * Trigger for the action
  10401. */
  10402. trigger: number;
  10403. /**
  10404. * Internal only - manager for action
  10405. * @hidden
  10406. */
  10407. _actionManager: ActionManager;
  10408. private _nextActiveAction;
  10409. private _child;
  10410. private _condition?;
  10411. private _triggerParameter;
  10412. /**
  10413. * An event triggered prior to action being executed.
  10414. */
  10415. onBeforeExecuteObservable: Observable<Action>;
  10416. /**
  10417. * Creates a new Action
  10418. * @param triggerOptions the trigger, with or without parameters, for the action
  10419. * @param condition an optional determinant of action
  10420. */
  10421. constructor(
  10422. /** the trigger, with or without parameters, for the action */
  10423. triggerOptions: any, condition?: Condition);
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. _prepare(): void;
  10429. /**
  10430. * Gets the trigger parameters
  10431. * @returns the trigger parameters
  10432. */
  10433. getTriggerParameter(): any;
  10434. /**
  10435. * Internal only - executes current action event
  10436. * @hidden
  10437. */
  10438. _executeCurrent(evt?: ActionEvent): void;
  10439. /**
  10440. * Execute placeholder for child classes
  10441. * @param evt optional action event
  10442. */
  10443. execute(evt?: ActionEvent): void;
  10444. /**
  10445. * Skips to next active action
  10446. */
  10447. skipToNextActiveAction(): void;
  10448. /**
  10449. * Adds action to chain of actions, may be a DoNothingAction
  10450. * @param action defines the next action to execute
  10451. * @returns The action passed in
  10452. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10453. */
  10454. then(action: Action): Action;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _getProperty(propertyPath: string): string;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _getEffectiveTarget(target: any, propertyPath: string): any;
  10465. /**
  10466. * Serialize placeholder for child classes
  10467. * @param parent of child
  10468. * @returns the serialized object
  10469. */
  10470. serialize(parent: any): any;
  10471. /**
  10472. * Internal only called by serialize
  10473. * @hidden
  10474. */
  10475. protected _serialize(serializedAction: any, parent?: any): any;
  10476. /**
  10477. * Internal only
  10478. * @hidden
  10479. */
  10480. static _SerializeValueAsString: (value: any) => string;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10486. name: string;
  10487. targetType: string;
  10488. value: string;
  10489. };
  10490. }
  10491. }
  10492. declare module "babylonjs/Actions/condition" {
  10493. import { ActionManager } from "babylonjs/Actions/actionManager";
  10494. /**
  10495. * A Condition applied to an Action
  10496. */
  10497. export class Condition {
  10498. /**
  10499. * Internal only - manager for action
  10500. * @hidden
  10501. */
  10502. _actionManager: ActionManager;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. _evaluationId: number;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _currentResult: boolean;
  10513. /**
  10514. * Creates a new Condition
  10515. * @param actionManager the manager of the action the condition is applied to
  10516. */
  10517. constructor(actionManager: ActionManager);
  10518. /**
  10519. * Check if the current condition is valid
  10520. * @returns a boolean
  10521. */
  10522. isValid(): boolean;
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. _getProperty(propertyPath: string): string;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. _getEffectiveTarget(target: any, propertyPath: string): any;
  10533. /**
  10534. * Serialize placeholder for child classes
  10535. * @returns the serialized object
  10536. */
  10537. serialize(): any;
  10538. /**
  10539. * Internal only
  10540. * @hidden
  10541. */
  10542. protected _serialize(serializedCondition: any): any;
  10543. }
  10544. /**
  10545. * Defines specific conditional operators as extensions of Condition
  10546. */
  10547. export class ValueCondition extends Condition {
  10548. /** path to specify the property of the target the conditional operator uses */
  10549. propertyPath: string;
  10550. /** the value compared by the conditional operator against the current value of the property */
  10551. value: any;
  10552. /** the conditional operator, default ValueCondition.IsEqual */
  10553. operator: number;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. private static _IsEqual;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. private static _IsDifferent;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. private static _IsGreater;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private static _IsLesser;
  10574. /**
  10575. * returns the number for IsEqual
  10576. */
  10577. static readonly IsEqual: number;
  10578. /**
  10579. * Returns the number for IsDifferent
  10580. */
  10581. static readonly IsDifferent: number;
  10582. /**
  10583. * Returns the number for IsGreater
  10584. */
  10585. static readonly IsGreater: number;
  10586. /**
  10587. * Returns the number for IsLesser
  10588. */
  10589. static readonly IsLesser: number;
  10590. /**
  10591. * Internal only The action manager for the condition
  10592. * @hidden
  10593. */
  10594. _actionManager: ActionManager;
  10595. /**
  10596. * Internal only
  10597. * @hidden
  10598. */
  10599. private _target;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. private _effectiveTarget;
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. private _property;
  10610. /**
  10611. * Creates a new ValueCondition
  10612. * @param actionManager manager for the action the condition applies to
  10613. * @param target for the action
  10614. * @param propertyPath path to specify the property of the target the conditional operator uses
  10615. * @param value the value compared by the conditional operator against the current value of the property
  10616. * @param operator the conditional operator, default ValueCondition.IsEqual
  10617. */
  10618. constructor(actionManager: ActionManager, target: any,
  10619. /** path to specify the property of the target the conditional operator uses */
  10620. propertyPath: string,
  10621. /** the value compared by the conditional operator against the current value of the property */
  10622. value: any,
  10623. /** the conditional operator, default ValueCondition.IsEqual */
  10624. operator?: number);
  10625. /**
  10626. * Compares the given value with the property value for the specified conditional operator
  10627. * @returns the result of the comparison
  10628. */
  10629. isValid(): boolean;
  10630. /**
  10631. * Serialize the ValueCondition into a JSON compatible object
  10632. * @returns serialization object
  10633. */
  10634. serialize(): any;
  10635. /**
  10636. * Gets the name of the conditional operator for the ValueCondition
  10637. * @param operator the conditional operator
  10638. * @returns the name
  10639. */
  10640. static GetOperatorName(operator: number): string;
  10641. }
  10642. /**
  10643. * Defines a predicate condition as an extension of Condition
  10644. */
  10645. export class PredicateCondition extends Condition {
  10646. /** defines the predicate function used to validate the condition */
  10647. predicate: () => boolean;
  10648. /**
  10649. * Internal only - manager for action
  10650. * @hidden
  10651. */
  10652. _actionManager: ActionManager;
  10653. /**
  10654. * Creates a new PredicateCondition
  10655. * @param actionManager manager for the action the condition applies to
  10656. * @param predicate defines the predicate function used to validate the condition
  10657. */
  10658. constructor(actionManager: ActionManager,
  10659. /** defines the predicate function used to validate the condition */
  10660. predicate: () => boolean);
  10661. /**
  10662. * @returns the validity of the predicate condition
  10663. */
  10664. isValid(): boolean;
  10665. }
  10666. /**
  10667. * Defines a state condition as an extension of Condition
  10668. */
  10669. export class StateCondition extends Condition {
  10670. /** Value to compare with target state */
  10671. value: string;
  10672. /**
  10673. * Internal only - manager for action
  10674. * @hidden
  10675. */
  10676. _actionManager: ActionManager;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. private _target;
  10682. /**
  10683. * Creates a new StateCondition
  10684. * @param actionManager manager for the action the condition applies to
  10685. * @param target of the condition
  10686. * @param value to compare with target state
  10687. */
  10688. constructor(actionManager: ActionManager, target: any,
  10689. /** Value to compare with target state */
  10690. value: string);
  10691. /**
  10692. * Gets a boolean indicating if the current condition is met
  10693. * @returns the validity of the state
  10694. */
  10695. isValid(): boolean;
  10696. /**
  10697. * Serialize the StateCondition into a JSON compatible object
  10698. * @returns serialization object
  10699. */
  10700. serialize(): any;
  10701. }
  10702. }
  10703. declare module "babylonjs/Actions/directActions" {
  10704. import { Action } from "babylonjs/Actions/action";
  10705. import { Condition } from "babylonjs/Actions/condition";
  10706. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10707. /**
  10708. * This defines an action responsible to toggle a boolean once triggered.
  10709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10710. */
  10711. export class SwitchBooleanAction extends Action {
  10712. /**
  10713. * The path to the boolean property in the target object
  10714. */
  10715. propertyPath: string;
  10716. private _target;
  10717. private _effectiveTarget;
  10718. private _property;
  10719. /**
  10720. * Instantiate the action
  10721. * @param triggerOptions defines the trigger options
  10722. * @param target defines the object containing the boolean
  10723. * @param propertyPath defines the path to the boolean property in the target object
  10724. * @param condition defines the trigger related conditions
  10725. */
  10726. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10727. /** @hidden */
  10728. _prepare(): void;
  10729. /**
  10730. * Execute the action toggle the boolean value.
  10731. */
  10732. execute(): void;
  10733. /**
  10734. * Serializes the actions and its related information.
  10735. * @param parent defines the object to serialize in
  10736. * @returns the serialized object
  10737. */
  10738. serialize(parent: any): any;
  10739. }
  10740. /**
  10741. * This defines an action responsible to set a the state field of the target
  10742. * to a desired value once triggered.
  10743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10744. */
  10745. export class SetStateAction extends Action {
  10746. /**
  10747. * The value to store in the state field.
  10748. */
  10749. value: string;
  10750. private _target;
  10751. /**
  10752. * Instantiate the action
  10753. * @param triggerOptions defines the trigger options
  10754. * @param target defines the object containing the state property
  10755. * @param value defines the value to store in the state field
  10756. * @param condition defines the trigger related conditions
  10757. */
  10758. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10759. /**
  10760. * Execute the action and store the value on the target state property.
  10761. */
  10762. execute(): void;
  10763. /**
  10764. * Serializes the actions and its related information.
  10765. * @param parent defines the object to serialize in
  10766. * @returns the serialized object
  10767. */
  10768. serialize(parent: any): any;
  10769. }
  10770. /**
  10771. * This defines an action responsible to set a property of the target
  10772. * to a desired value once triggered.
  10773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10774. */
  10775. export class SetValueAction extends Action {
  10776. /**
  10777. * The path of the property to set in the target.
  10778. */
  10779. propertyPath: string;
  10780. /**
  10781. * The value to set in the property
  10782. */
  10783. value: any;
  10784. private _target;
  10785. private _effectiveTarget;
  10786. private _property;
  10787. /**
  10788. * Instantiate the action
  10789. * @param triggerOptions defines the trigger options
  10790. * @param target defines the object containing the property
  10791. * @param propertyPath defines the path of the property to set in the target
  10792. * @param value defines the value to set in the property
  10793. * @param condition defines the trigger related conditions
  10794. */
  10795. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10796. /** @hidden */
  10797. _prepare(): void;
  10798. /**
  10799. * Execute the action and set the targetted property to the desired value.
  10800. */
  10801. execute(): void;
  10802. /**
  10803. * Serializes the actions and its related information.
  10804. * @param parent defines the object to serialize in
  10805. * @returns the serialized object
  10806. */
  10807. serialize(parent: any): any;
  10808. }
  10809. /**
  10810. * This defines an action responsible to increment the target value
  10811. * to a desired value once triggered.
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10813. */
  10814. export class IncrementValueAction extends Action {
  10815. /**
  10816. * The path of the property to increment in the target.
  10817. */
  10818. propertyPath: string;
  10819. /**
  10820. * The value we should increment the property by.
  10821. */
  10822. value: any;
  10823. private _target;
  10824. private _effectiveTarget;
  10825. private _property;
  10826. /**
  10827. * Instantiate the action
  10828. * @param triggerOptions defines the trigger options
  10829. * @param target defines the object containing the property
  10830. * @param propertyPath defines the path of the property to increment in the target
  10831. * @param value defines the value value we should increment the property by
  10832. * @param condition defines the trigger related conditions
  10833. */
  10834. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10835. /** @hidden */
  10836. _prepare(): void;
  10837. /**
  10838. * Execute the action and increment the target of the value amount.
  10839. */
  10840. execute(): void;
  10841. /**
  10842. * Serializes the actions and its related information.
  10843. * @param parent defines the object to serialize in
  10844. * @returns the serialized object
  10845. */
  10846. serialize(parent: any): any;
  10847. }
  10848. /**
  10849. * This defines an action responsible to start an animation once triggered.
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10851. */
  10852. export class PlayAnimationAction extends Action {
  10853. /**
  10854. * Where the animation should start (animation frame)
  10855. */
  10856. from: number;
  10857. /**
  10858. * Where the animation should stop (animation frame)
  10859. */
  10860. to: number;
  10861. /**
  10862. * Define if the animation should loop or stop after the first play.
  10863. */
  10864. loop?: boolean;
  10865. private _target;
  10866. /**
  10867. * Instantiate the action
  10868. * @param triggerOptions defines the trigger options
  10869. * @param target defines the target animation or animation name
  10870. * @param from defines from where the animation should start (animation frame)
  10871. * @param end defines where the animation should stop (animation frame)
  10872. * @param loop defines if the animation should loop or stop after the first play
  10873. * @param condition defines the trigger related conditions
  10874. */
  10875. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10876. /** @hidden */
  10877. _prepare(): void;
  10878. /**
  10879. * Execute the action and play the animation.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible to stop an animation once triggered.
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10892. */
  10893. export class StopAnimationAction extends Action {
  10894. private _target;
  10895. /**
  10896. * Instantiate the action
  10897. * @param triggerOptions defines the trigger options
  10898. * @param target defines the target animation or animation name
  10899. * @param condition defines the trigger related conditions
  10900. */
  10901. constructor(triggerOptions: any, target: any, condition?: Condition);
  10902. /** @hidden */
  10903. _prepare(): void;
  10904. /**
  10905. * Execute the action and stop the animation.
  10906. */
  10907. execute(): void;
  10908. /**
  10909. * Serializes the actions and its related information.
  10910. * @param parent defines the object to serialize in
  10911. * @returns the serialized object
  10912. */
  10913. serialize(parent: any): any;
  10914. }
  10915. /**
  10916. * This defines an action responsible that does nothing once triggered.
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10918. */
  10919. export class DoNothingAction extends Action {
  10920. /**
  10921. * Instantiate the action
  10922. * @param triggerOptions defines the trigger options
  10923. * @param condition defines the trigger related conditions
  10924. */
  10925. constructor(triggerOptions?: any, condition?: Condition);
  10926. /**
  10927. * Execute the action and do nothing.
  10928. */
  10929. execute(): void;
  10930. /**
  10931. * Serializes the actions and its related information.
  10932. * @param parent defines the object to serialize in
  10933. * @returns the serialized object
  10934. */
  10935. serialize(parent: any): any;
  10936. }
  10937. /**
  10938. * This defines an action responsible to trigger several actions once triggered.
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10940. */
  10941. export class CombineAction extends Action {
  10942. /**
  10943. * The list of aggregated animations to run.
  10944. */
  10945. children: Action[];
  10946. /**
  10947. * Instantiate the action
  10948. * @param triggerOptions defines the trigger options
  10949. * @param children defines the list of aggregated animations to run
  10950. * @param condition defines the trigger related conditions
  10951. */
  10952. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10953. /** @hidden */
  10954. _prepare(): void;
  10955. /**
  10956. * Execute the action and executes all the aggregated actions.
  10957. */
  10958. execute(evt: ActionEvent): void;
  10959. /**
  10960. * Serializes the actions and its related information.
  10961. * @param parent defines the object to serialize in
  10962. * @returns the serialized object
  10963. */
  10964. serialize(parent: any): any;
  10965. }
  10966. /**
  10967. * This defines an action responsible to run code (external event) once triggered.
  10968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10969. */
  10970. export class ExecuteCodeAction extends Action {
  10971. /**
  10972. * The callback function to run.
  10973. */
  10974. func: (evt: ActionEvent) => void;
  10975. /**
  10976. * Instantiate the action
  10977. * @param triggerOptions defines the trigger options
  10978. * @param func defines the callback function to run
  10979. * @param condition defines the trigger related conditions
  10980. */
  10981. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10982. /**
  10983. * Execute the action and run the attached code.
  10984. */
  10985. execute(evt: ActionEvent): void;
  10986. }
  10987. /**
  10988. * This defines an action responsible to set the parent property of the target once triggered.
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10990. */
  10991. export class SetParentAction extends Action {
  10992. private _parent;
  10993. private _target;
  10994. /**
  10995. * Instantiate the action
  10996. * @param triggerOptions defines the trigger options
  10997. * @param target defines the target containing the parent property
  10998. * @param parent defines from where the animation should start (animation frame)
  10999. * @param condition defines the trigger related conditions
  11000. */
  11001. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11002. /** @hidden */
  11003. _prepare(): void;
  11004. /**
  11005. * Execute the action and set the parent property.
  11006. */
  11007. execute(): void;
  11008. /**
  11009. * Serializes the actions and its related information.
  11010. * @param parent defines the object to serialize in
  11011. * @returns the serialized object
  11012. */
  11013. serialize(parent: any): any;
  11014. }
  11015. }
  11016. declare module "babylonjs/Actions/actionManager" {
  11017. import { Nullable } from "babylonjs/types";
  11018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11019. import { Scene } from "babylonjs/scene";
  11020. import { IAction } from "babylonjs/Actions/action";
  11021. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11022. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11023. /**
  11024. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11025. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11027. */
  11028. export class ActionManager extends AbstractActionManager {
  11029. /**
  11030. * Nothing
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11032. */
  11033. static readonly NothingTrigger: number;
  11034. /**
  11035. * On pick
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly OnPickTrigger: number;
  11039. /**
  11040. * On left pick
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnLeftPickTrigger: number;
  11044. /**
  11045. * On right pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnRightPickTrigger: number;
  11049. /**
  11050. * On center pick
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnCenterPickTrigger: number;
  11054. /**
  11055. * On pick down
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnPickDownTrigger: number;
  11059. /**
  11060. * On double pick
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnDoublePickTrigger: number;
  11064. /**
  11065. * On pick up
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnPickUpTrigger: number;
  11069. /**
  11070. * On pick out.
  11071. * This trigger will only be raised if you also declared a OnPickDown
  11072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11073. */
  11074. static readonly OnPickOutTrigger: number;
  11075. /**
  11076. * On long press
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnLongPressTrigger: number;
  11080. /**
  11081. * On pointer over
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnPointerOverTrigger: number;
  11085. /**
  11086. * On pointer out
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPointerOutTrigger: number;
  11090. /**
  11091. * On every frame
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnEveryFrameTrigger: number;
  11095. /**
  11096. * On intersection enter
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnIntersectionEnterTrigger: number;
  11100. /**
  11101. * On intersection exit
  11102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11103. */
  11104. static readonly OnIntersectionExitTrigger: number;
  11105. /**
  11106. * On key down
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11108. */
  11109. static readonly OnKeyDownTrigger: number;
  11110. /**
  11111. * On key up
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11113. */
  11114. static readonly OnKeyUpTrigger: number;
  11115. private _scene;
  11116. /**
  11117. * Creates a new action manager
  11118. * @param scene defines the hosting scene
  11119. */
  11120. constructor(scene: Scene);
  11121. /**
  11122. * Releases all associated resources
  11123. */
  11124. dispose(): void;
  11125. /**
  11126. * Gets hosting scene
  11127. * @returns the hosting scene
  11128. */
  11129. getScene(): Scene;
  11130. /**
  11131. * Does this action manager handles actions of any of the given triggers
  11132. * @param triggers defines the triggers to be tested
  11133. * @return a boolean indicating whether one (or more) of the triggers is handled
  11134. */
  11135. hasSpecificTriggers(triggers: number[]): boolean;
  11136. /**
  11137. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11138. * speed.
  11139. * @param triggerA defines the trigger to be tested
  11140. * @param triggerB defines the trigger to be tested
  11141. * @return a boolean indicating whether one (or more) of the triggers is handled
  11142. */
  11143. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11144. /**
  11145. * Does this action manager handles actions of a given trigger
  11146. * @param trigger defines the trigger to be tested
  11147. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11148. * @return whether the trigger is handled
  11149. */
  11150. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11151. /**
  11152. * Does this action manager has pointer triggers
  11153. */
  11154. readonly hasPointerTriggers: boolean;
  11155. /**
  11156. * Does this action manager has pick triggers
  11157. */
  11158. readonly hasPickTriggers: boolean;
  11159. /**
  11160. * Registers an action to this action manager
  11161. * @param action defines the action to be registered
  11162. * @return the action amended (prepared) after registration
  11163. */
  11164. registerAction(action: IAction): Nullable<IAction>;
  11165. /**
  11166. * Unregisters an action to this action manager
  11167. * @param action defines the action to be unregistered
  11168. * @return a boolean indicating whether the action has been unregistered
  11169. */
  11170. unregisterAction(action: IAction): Boolean;
  11171. /**
  11172. * Process a specific trigger
  11173. * @param trigger defines the trigger to process
  11174. * @param evt defines the event details to be processed
  11175. */
  11176. processTrigger(trigger: number, evt?: IActionEvent): void;
  11177. /** @hidden */
  11178. _getEffectiveTarget(target: any, propertyPath: string): any;
  11179. /** @hidden */
  11180. _getProperty(propertyPath: string): string;
  11181. /**
  11182. * Serialize this manager to a JSON object
  11183. * @param name defines the property name to store this manager
  11184. * @returns a JSON representation of this manager
  11185. */
  11186. serialize(name: string): any;
  11187. /**
  11188. * Creates a new ActionManager from a JSON data
  11189. * @param parsedActions defines the JSON data to read from
  11190. * @param object defines the hosting mesh
  11191. * @param scene defines the hosting scene
  11192. */
  11193. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11194. /**
  11195. * Get a trigger name by index
  11196. * @param trigger defines the trigger index
  11197. * @returns a trigger name
  11198. */
  11199. static GetTriggerName(trigger: number): string;
  11200. }
  11201. }
  11202. declare module "babylonjs/Culling/ray" {
  11203. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11204. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11206. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11207. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11208. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11209. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11210. /**
  11211. * Class representing a ray with position and direction
  11212. */
  11213. export class Ray {
  11214. /** origin point */
  11215. origin: Vector3;
  11216. /** direction */
  11217. direction: Vector3;
  11218. /** length of the ray */
  11219. length: number;
  11220. private static readonly TmpVector3;
  11221. private _tmpRay;
  11222. /**
  11223. * Creates a new ray
  11224. * @param origin origin point
  11225. * @param direction direction
  11226. * @param length length of the ray
  11227. */
  11228. constructor(
  11229. /** origin point */
  11230. origin: Vector3,
  11231. /** direction */
  11232. direction: Vector3,
  11233. /** length of the ray */
  11234. length?: number);
  11235. /**
  11236. * Checks if the ray intersects a box
  11237. * @param minimum bound of the box
  11238. * @param maximum bound of the box
  11239. * @param intersectionTreshold extra extend to be added to the box in all direction
  11240. * @returns if the box was hit
  11241. */
  11242. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11243. /**
  11244. * Checks if the ray intersects a box
  11245. * @param box the bounding box to check
  11246. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11247. * @returns if the box was hit
  11248. */
  11249. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11250. /**
  11251. * If the ray hits a sphere
  11252. * @param sphere the bounding sphere to check
  11253. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11254. * @returns true if it hits the sphere
  11255. */
  11256. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11257. /**
  11258. * If the ray hits a triange
  11259. * @param vertex0 triangle vertex
  11260. * @param vertex1 triangle vertex
  11261. * @param vertex2 triangle vertex
  11262. * @returns intersection information if hit
  11263. */
  11264. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11265. /**
  11266. * Checks if ray intersects a plane
  11267. * @param plane the plane to check
  11268. * @returns the distance away it was hit
  11269. */
  11270. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11271. /**
  11272. * Checks if ray intersects a mesh
  11273. * @param mesh the mesh to check
  11274. * @param fastCheck if only the bounding box should checked
  11275. * @returns picking info of the intersecton
  11276. */
  11277. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11278. /**
  11279. * Checks if ray intersects a mesh
  11280. * @param meshes the meshes to check
  11281. * @param fastCheck if only the bounding box should checked
  11282. * @param results array to store result in
  11283. * @returns Array of picking infos
  11284. */
  11285. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11286. private _comparePickingInfo;
  11287. private static smallnum;
  11288. private static rayl;
  11289. /**
  11290. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11291. * @param sega the first point of the segment to test the intersection against
  11292. * @param segb the second point of the segment to test the intersection against
  11293. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11294. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11295. */
  11296. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11297. /**
  11298. * Update the ray from viewport position
  11299. * @param x position
  11300. * @param y y position
  11301. * @param viewportWidth viewport width
  11302. * @param viewportHeight viewport height
  11303. * @param world world matrix
  11304. * @param view view matrix
  11305. * @param projection projection matrix
  11306. * @returns this ray updated
  11307. */
  11308. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11309. /**
  11310. * Creates a ray with origin and direction of 0,0,0
  11311. * @returns the new ray
  11312. */
  11313. static Zero(): Ray;
  11314. /**
  11315. * Creates a new ray from screen space and viewport
  11316. * @param x position
  11317. * @param y y position
  11318. * @param viewportWidth viewport width
  11319. * @param viewportHeight viewport height
  11320. * @param world world matrix
  11321. * @param view view matrix
  11322. * @param projection projection matrix
  11323. * @returns new ray
  11324. */
  11325. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11326. /**
  11327. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11328. * transformed to the given world matrix.
  11329. * @param origin The origin point
  11330. * @param end The end point
  11331. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11332. * @returns the new ray
  11333. */
  11334. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11335. /**
  11336. * Transforms a ray by a matrix
  11337. * @param ray ray to transform
  11338. * @param matrix matrix to apply
  11339. * @returns the resulting new ray
  11340. */
  11341. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11342. /**
  11343. * Transforms a ray by a matrix
  11344. * @param ray ray to transform
  11345. * @param matrix matrix to apply
  11346. * @param result ray to store result in
  11347. */
  11348. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11349. /**
  11350. * Unproject a ray from screen space to object space
  11351. * @param sourceX defines the screen space x coordinate to use
  11352. * @param sourceY defines the screen space y coordinate to use
  11353. * @param viewportWidth defines the current width of the viewport
  11354. * @param viewportHeight defines the current height of the viewport
  11355. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11356. * @param view defines the view matrix to use
  11357. * @param projection defines the projection matrix to use
  11358. */
  11359. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11360. }
  11361. /**
  11362. * Type used to define predicate used to select faces when a mesh intersection is detected
  11363. */
  11364. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11365. module "babylonjs/scene" {
  11366. interface Scene {
  11367. /** @hidden */
  11368. _tempPickingRay: Nullable<Ray>;
  11369. /** @hidden */
  11370. _cachedRayForTransform: Ray;
  11371. /** @hidden */
  11372. _pickWithRayInverseMatrix: Matrix;
  11373. /** @hidden */
  11374. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11375. /** @hidden */
  11376. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11377. }
  11378. }
  11379. }
  11380. declare module "babylonjs/sceneComponent" {
  11381. import { Scene } from "babylonjs/scene";
  11382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11384. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11385. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11386. import { Nullable } from "babylonjs/types";
  11387. import { Camera } from "babylonjs/Cameras/camera";
  11388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11389. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11390. import { AbstractScene } from "babylonjs/abstractScene";
  11391. /**
  11392. * Groups all the scene component constants in one place to ease maintenance.
  11393. * @hidden
  11394. */
  11395. export class SceneComponentConstants {
  11396. static readonly NAME_EFFECTLAYER: string;
  11397. static readonly NAME_LAYER: string;
  11398. static readonly NAME_LENSFLARESYSTEM: string;
  11399. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11400. static readonly NAME_PARTICLESYSTEM: string;
  11401. static readonly NAME_GAMEPAD: string;
  11402. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11403. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11404. static readonly NAME_DEPTHRENDERER: string;
  11405. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11406. static readonly NAME_SPRITE: string;
  11407. static readonly NAME_OUTLINERENDERER: string;
  11408. static readonly NAME_PROCEDURALTEXTURE: string;
  11409. static readonly NAME_SHADOWGENERATOR: string;
  11410. static readonly NAME_OCTREE: string;
  11411. static readonly NAME_PHYSICSENGINE: string;
  11412. static readonly NAME_AUDIO: string;
  11413. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11414. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11415. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11416. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11417. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11418. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11419. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11420. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11421. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11422. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11423. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11424. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11425. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11426. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11427. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11428. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11429. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11430. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11431. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11432. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11433. static readonly STEP_AFTERRENDER_AUDIO: number;
  11434. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11435. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11436. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11437. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11438. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11439. static readonly STEP_POINTERMOVE_SPRITE: number;
  11440. static readonly STEP_POINTERDOWN_SPRITE: number;
  11441. static readonly STEP_POINTERUP_SPRITE: number;
  11442. }
  11443. /**
  11444. * This represents a scene component.
  11445. *
  11446. * This is used to decouple the dependency the scene is having on the different workloads like
  11447. * layers, post processes...
  11448. */
  11449. export interface ISceneComponent {
  11450. /**
  11451. * The name of the component. Each component must have a unique name.
  11452. */
  11453. name: string;
  11454. /**
  11455. * The scene the component belongs to.
  11456. */
  11457. scene: Scene;
  11458. /**
  11459. * Register the component to one instance of a scene.
  11460. */
  11461. register(): void;
  11462. /**
  11463. * Rebuilds the elements related to this component in case of
  11464. * context lost for instance.
  11465. */
  11466. rebuild(): void;
  11467. /**
  11468. * Disposes the component and the associated ressources.
  11469. */
  11470. dispose(): void;
  11471. }
  11472. /**
  11473. * This represents a SERIALIZABLE scene component.
  11474. *
  11475. * This extends Scene Component to add Serialization methods on top.
  11476. */
  11477. export interface ISceneSerializableComponent extends ISceneComponent {
  11478. /**
  11479. * Adds all the element from the container to the scene
  11480. * @param container the container holding the elements
  11481. */
  11482. addFromContainer(container: AbstractScene): void;
  11483. /**
  11484. * Removes all the elements in the container from the scene
  11485. * @param container contains the elements to remove
  11486. */
  11487. removeFromContainer(container: AbstractScene): void;
  11488. /**
  11489. * Serializes the component data to the specified json object
  11490. * @param serializationObject The object to serialize to
  11491. */
  11492. serialize(serializationObject: any): void;
  11493. }
  11494. /**
  11495. * Strong typing of a Mesh related stage step action
  11496. */
  11497. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11498. /**
  11499. * Strong typing of a Evaluate Sub Mesh related stage step action
  11500. */
  11501. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11502. /**
  11503. * Strong typing of a Active Mesh related stage step action
  11504. */
  11505. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11506. /**
  11507. * Strong typing of a Camera related stage step action
  11508. */
  11509. export type CameraStageAction = (camera: Camera) => void;
  11510. /**
  11511. * Strong typing of a Render Target related stage step action
  11512. */
  11513. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11514. /**
  11515. * Strong typing of a RenderingGroup related stage step action
  11516. */
  11517. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11518. /**
  11519. * Strong typing of a Mesh Render related stage step action
  11520. */
  11521. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11522. /**
  11523. * Strong typing of a simple stage step action
  11524. */
  11525. export type SimpleStageAction = () => void;
  11526. /**
  11527. * Strong typing of a render target action.
  11528. */
  11529. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11530. /**
  11531. * Strong typing of a pointer move action.
  11532. */
  11533. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11534. /**
  11535. * Strong typing of a pointer up/down action.
  11536. */
  11537. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11538. /**
  11539. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11540. * @hidden
  11541. */
  11542. export class Stage<T extends Function> extends Array<{
  11543. index: number;
  11544. component: ISceneComponent;
  11545. action: T;
  11546. }> {
  11547. /**
  11548. * Hide ctor from the rest of the world.
  11549. * @param items The items to add.
  11550. */
  11551. private constructor();
  11552. /**
  11553. * Creates a new Stage.
  11554. * @returns A new instance of a Stage
  11555. */
  11556. static Create<T extends Function>(): Stage<T>;
  11557. /**
  11558. * Registers a step in an ordered way in the targeted stage.
  11559. * @param index Defines the position to register the step in
  11560. * @param component Defines the component attached to the step
  11561. * @param action Defines the action to launch during the step
  11562. */
  11563. registerStep(index: number, component: ISceneComponent, action: T): void;
  11564. /**
  11565. * Clears all the steps from the stage.
  11566. */
  11567. clear(): void;
  11568. }
  11569. }
  11570. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11571. import { Nullable } from "babylonjs/types";
  11572. import { Observable } from "babylonjs/Misc/observable";
  11573. import { Scene } from "babylonjs/scene";
  11574. import { Sprite } from "babylonjs/Sprites/sprite";
  11575. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11576. import { Ray } from "babylonjs/Culling/ray";
  11577. import { Camera } from "babylonjs/Cameras/camera";
  11578. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11579. import { ISceneComponent } from "babylonjs/sceneComponent";
  11580. module "babylonjs/scene" {
  11581. interface Scene {
  11582. /** @hidden */
  11583. _pointerOverSprite: Nullable<Sprite>;
  11584. /** @hidden */
  11585. _pickedDownSprite: Nullable<Sprite>;
  11586. /** @hidden */
  11587. _tempSpritePickingRay: Nullable<Ray>;
  11588. /**
  11589. * All of the sprite managers added to this scene
  11590. * @see http://doc.babylonjs.com/babylon101/sprites
  11591. */
  11592. spriteManagers: Array<ISpriteManager>;
  11593. /**
  11594. * An event triggered when sprites rendering is about to start
  11595. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11596. */
  11597. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11598. /**
  11599. * An event triggered when sprites rendering is done
  11600. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11601. */
  11602. onAfterSpritesRenderingObservable: Observable<Scene>;
  11603. /** @hidden */
  11604. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11605. /** Launch a ray to try to pick a sprite in the scene
  11606. * @param x position on screen
  11607. * @param y position on screen
  11608. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11609. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11610. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11611. * @returns a PickingInfo
  11612. */
  11613. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11614. /** Use the given ray to pick a sprite in the scene
  11615. * @param ray The ray (in world space) to use to pick meshes
  11616. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11617. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11618. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11619. * @returns a PickingInfo
  11620. */
  11621. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11622. /**
  11623. * Force the sprite under the pointer
  11624. * @param sprite defines the sprite to use
  11625. */
  11626. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11627. /**
  11628. * Gets the sprite under the pointer
  11629. * @returns a Sprite or null if no sprite is under the pointer
  11630. */
  11631. getPointerOverSprite(): Nullable<Sprite>;
  11632. }
  11633. }
  11634. /**
  11635. * Defines the sprite scene component responsible to manage sprites
  11636. * in a given scene.
  11637. */
  11638. export class SpriteSceneComponent implements ISceneComponent {
  11639. /**
  11640. * The component name helpfull to identify the component in the list of scene components.
  11641. */
  11642. readonly name: string;
  11643. /**
  11644. * The scene the component belongs to.
  11645. */
  11646. scene: Scene;
  11647. /** @hidden */
  11648. private _spritePredicate;
  11649. /**
  11650. * Creates a new instance of the component for the given scene
  11651. * @param scene Defines the scene to register the component in
  11652. */
  11653. constructor(scene: Scene);
  11654. /**
  11655. * Registers the component in a given scene
  11656. */
  11657. register(): void;
  11658. /**
  11659. * Rebuilds the elements related to this component in case of
  11660. * context lost for instance.
  11661. */
  11662. rebuild(): void;
  11663. /**
  11664. * Disposes the component and the associated ressources.
  11665. */
  11666. dispose(): void;
  11667. private _pickSpriteButKeepRay;
  11668. private _pointerMove;
  11669. private _pointerDown;
  11670. private _pointerUp;
  11671. }
  11672. }
  11673. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11674. /** @hidden */
  11675. export var fogFragmentDeclaration: {
  11676. name: string;
  11677. shader: string;
  11678. };
  11679. }
  11680. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11681. /** @hidden */
  11682. export var fogFragment: {
  11683. name: string;
  11684. shader: string;
  11685. };
  11686. }
  11687. declare module "babylonjs/Shaders/sprites.fragment" {
  11688. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11689. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11690. /** @hidden */
  11691. export var spritesPixelShader: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11697. /** @hidden */
  11698. export var fogVertexDeclaration: {
  11699. name: string;
  11700. shader: string;
  11701. };
  11702. }
  11703. declare module "babylonjs/Shaders/sprites.vertex" {
  11704. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11705. /** @hidden */
  11706. export var spritesVertexShader: {
  11707. name: string;
  11708. shader: string;
  11709. };
  11710. }
  11711. declare module "babylonjs/Sprites/spriteManager" {
  11712. import { IDisposable, Scene } from "babylonjs/scene";
  11713. import { Nullable } from "babylonjs/types";
  11714. import { Observable } from "babylonjs/Misc/observable";
  11715. import { Sprite } from "babylonjs/Sprites/sprite";
  11716. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11717. import { Camera } from "babylonjs/Cameras/camera";
  11718. import { Texture } from "babylonjs/Materials/Textures/texture";
  11719. import "babylonjs/Shaders/sprites.fragment";
  11720. import "babylonjs/Shaders/sprites.vertex";
  11721. import { Ray } from "babylonjs/Culling/ray";
  11722. /**
  11723. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11724. */
  11725. export interface ISpriteManager extends IDisposable {
  11726. /**
  11727. * Restricts the camera to viewing objects with the same layerMask.
  11728. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11729. */
  11730. layerMask: number;
  11731. /**
  11732. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11733. */
  11734. isPickable: boolean;
  11735. /**
  11736. * Specifies the rendering group id for this mesh (0 by default)
  11737. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11738. */
  11739. renderingGroupId: number;
  11740. /**
  11741. * Defines the list of sprites managed by the manager.
  11742. */
  11743. sprites: Array<Sprite>;
  11744. /**
  11745. * Tests the intersection of a sprite with a specific ray.
  11746. * @param ray The ray we are sending to test the collision
  11747. * @param camera The camera space we are sending rays in
  11748. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11749. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11750. * @returns picking info or null.
  11751. */
  11752. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11753. /**
  11754. * Renders the list of sprites on screen.
  11755. */
  11756. render(): void;
  11757. }
  11758. /**
  11759. * Class used to manage multiple sprites on the same spritesheet
  11760. * @see http://doc.babylonjs.com/babylon101/sprites
  11761. */
  11762. export class SpriteManager implements ISpriteManager {
  11763. /** defines the manager's name */
  11764. name: string;
  11765. /** Gets the list of sprites */
  11766. sprites: Sprite[];
  11767. /** Gets or sets the rendering group id (0 by default) */
  11768. renderingGroupId: number;
  11769. /** Gets or sets camera layer mask */
  11770. layerMask: number;
  11771. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11772. fogEnabled: boolean;
  11773. /** Gets or sets a boolean indicating if the sprites are pickable */
  11774. isPickable: boolean;
  11775. /** Defines the default width of a cell in the spritesheet */
  11776. cellWidth: number;
  11777. /** Defines the default height of a cell in the spritesheet */
  11778. cellHeight: number;
  11779. /**
  11780. * An event triggered when the manager is disposed.
  11781. */
  11782. onDisposeObservable: Observable<SpriteManager>;
  11783. private _onDisposeObserver;
  11784. /**
  11785. * Callback called when the manager is disposed
  11786. */
  11787. onDispose: () => void;
  11788. private _capacity;
  11789. private _spriteTexture;
  11790. private _epsilon;
  11791. private _scene;
  11792. private _vertexData;
  11793. private _buffer;
  11794. private _vertexBuffers;
  11795. private _indexBuffer;
  11796. private _effectBase;
  11797. private _effectFog;
  11798. /**
  11799. * Gets or sets the spritesheet texture
  11800. */
  11801. texture: Texture;
  11802. /**
  11803. * Creates a new sprite manager
  11804. * @param name defines the manager's name
  11805. * @param imgUrl defines the sprite sheet url
  11806. * @param capacity defines the maximum allowed number of sprites
  11807. * @param cellSize defines the size of a sprite cell
  11808. * @param scene defines the hosting scene
  11809. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11810. * @param samplingMode defines the smapling mode to use with spritesheet
  11811. */
  11812. constructor(
  11813. /** defines the manager's name */
  11814. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11815. private _appendSpriteVertex;
  11816. /**
  11817. * Intersects the sprites with a ray
  11818. * @param ray defines the ray to intersect with
  11819. * @param camera defines the current active camera
  11820. * @param predicate defines a predicate used to select candidate sprites
  11821. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11822. * @returns null if no hit or a PickingInfo
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Render all child sprites
  11827. */
  11828. render(): void;
  11829. /**
  11830. * Release associated resources
  11831. */
  11832. dispose(): void;
  11833. }
  11834. }
  11835. declare module "babylonjs/Sprites/sprite" {
  11836. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11837. import { Nullable } from "babylonjs/types";
  11838. import { ActionManager } from "babylonjs/Actions/actionManager";
  11839. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11840. /**
  11841. * Class used to represent a sprite
  11842. * @see http://doc.babylonjs.com/babylon101/sprites
  11843. */
  11844. export class Sprite {
  11845. /** defines the name */
  11846. name: string;
  11847. /** Gets or sets the current world position */
  11848. position: Vector3;
  11849. /** Gets or sets the main color */
  11850. color: Color4;
  11851. /** Gets or sets the width */
  11852. width: number;
  11853. /** Gets or sets the height */
  11854. height: number;
  11855. /** Gets or sets rotation angle */
  11856. angle: number;
  11857. /** Gets or sets the cell index in the sprite sheet */
  11858. cellIndex: number;
  11859. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11860. invertU: number;
  11861. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11862. invertV: number;
  11863. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11864. disposeWhenFinishedAnimating: boolean;
  11865. /** Gets the list of attached animations */
  11866. animations: Animation[];
  11867. /** Gets or sets a boolean indicating if the sprite can be picked */
  11868. isPickable: boolean;
  11869. /**
  11870. * Gets or sets the associated action manager
  11871. */
  11872. actionManager: Nullable<ActionManager>;
  11873. private _animationStarted;
  11874. private _loopAnimation;
  11875. private _fromIndex;
  11876. private _toIndex;
  11877. private _delay;
  11878. private _direction;
  11879. private _manager;
  11880. private _time;
  11881. private _onAnimationEnd;
  11882. /**
  11883. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11884. */
  11885. isVisible: boolean;
  11886. /**
  11887. * Gets or sets the sprite size
  11888. */
  11889. size: number;
  11890. /**
  11891. * Creates a new Sprite
  11892. * @param name defines the name
  11893. * @param manager defines the manager
  11894. */
  11895. constructor(
  11896. /** defines the name */
  11897. name: string, manager: ISpriteManager);
  11898. /**
  11899. * Starts an animation
  11900. * @param from defines the initial key
  11901. * @param to defines the end key
  11902. * @param loop defines if the animation must loop
  11903. * @param delay defines the start delay (in ms)
  11904. * @param onAnimationEnd defines a callback to call when animation ends
  11905. */
  11906. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11907. /** Stops current animation (if any) */
  11908. stopAnimation(): void;
  11909. /** @hidden */
  11910. _animate(deltaTime: number): void;
  11911. /** Release associated resources */
  11912. dispose(): void;
  11913. }
  11914. }
  11915. declare module "babylonjs/Collisions/pickingInfo" {
  11916. import { Nullable } from "babylonjs/types";
  11917. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  11918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11919. import { Sprite } from "babylonjs/Sprites/sprite";
  11920. import { Ray } from "babylonjs/Culling/ray";
  11921. /**
  11922. * Information about the result of picking within a scene
  11923. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11924. */
  11925. export class PickingInfo {
  11926. /** @hidden */
  11927. _pickingUnavailable: boolean;
  11928. /**
  11929. * If the pick collided with an object
  11930. */
  11931. hit: boolean;
  11932. /**
  11933. * Distance away where the pick collided
  11934. */
  11935. distance: number;
  11936. /**
  11937. * The location of pick collision
  11938. */
  11939. pickedPoint: Nullable<Vector3>;
  11940. /**
  11941. * The mesh corresponding the the pick collision
  11942. */
  11943. pickedMesh: Nullable<AbstractMesh>;
  11944. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11945. bu: number;
  11946. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11947. bv: number;
  11948. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11949. faceId: number;
  11950. /** Id of the the submesh that was picked */
  11951. subMeshId: number;
  11952. /** If a sprite was picked, this will be the sprite the pick collided with */
  11953. pickedSprite: Nullable<Sprite>;
  11954. /**
  11955. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11956. */
  11957. originMesh: Nullable<AbstractMesh>;
  11958. /**
  11959. * The ray that was used to perform the picking.
  11960. */
  11961. ray: Nullable<Ray>;
  11962. /**
  11963. * Gets the normal correspodning to the face the pick collided with
  11964. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11965. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11966. * @returns The normal correspodning to the face the pick collided with
  11967. */
  11968. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11969. /**
  11970. * Gets the texture coordinates of where the pick occured
  11971. * @returns the vector containing the coordnates of the texture
  11972. */
  11973. getTextureCoordinates(): Nullable<Vector2>;
  11974. }
  11975. }
  11976. declare module "babylonjs/Events/pointerEvents" {
  11977. import { Nullable } from "babylonjs/types";
  11978. import { Vector2 } from "babylonjs/Maths/math";
  11979. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11980. import { Ray } from "babylonjs/Culling/ray";
  11981. /**
  11982. * Gather the list of pointer event types as constants.
  11983. */
  11984. export class PointerEventTypes {
  11985. /**
  11986. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11987. */
  11988. static readonly POINTERDOWN: number;
  11989. /**
  11990. * The pointerup event is fired when a pointer is no longer active.
  11991. */
  11992. static readonly POINTERUP: number;
  11993. /**
  11994. * The pointermove event is fired when a pointer changes coordinates.
  11995. */
  11996. static readonly POINTERMOVE: number;
  11997. /**
  11998. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11999. */
  12000. static readonly POINTERWHEEL: number;
  12001. /**
  12002. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12003. */
  12004. static readonly POINTERPICK: number;
  12005. /**
  12006. * The pointertap event is fired when a the object has been touched and released without drag.
  12007. */
  12008. static readonly POINTERTAP: number;
  12009. /**
  12010. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12011. */
  12012. static readonly POINTERDOUBLETAP: number;
  12013. }
  12014. /**
  12015. * Base class of pointer info types.
  12016. */
  12017. export class PointerInfoBase {
  12018. /**
  12019. * Defines the type of event (PointerEventTypes)
  12020. */
  12021. type: number;
  12022. /**
  12023. * Defines the related dom event
  12024. */
  12025. event: PointerEvent | MouseWheelEvent;
  12026. /**
  12027. * Instantiates the base class of pointers info.
  12028. * @param type Defines the type of event (PointerEventTypes)
  12029. * @param event Defines the related dom event
  12030. */
  12031. constructor(
  12032. /**
  12033. * Defines the type of event (PointerEventTypes)
  12034. */
  12035. type: number,
  12036. /**
  12037. * Defines the related dom event
  12038. */
  12039. event: PointerEvent | MouseWheelEvent);
  12040. }
  12041. /**
  12042. * This class is used to store pointer related info for the onPrePointerObservable event.
  12043. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12044. */
  12045. export class PointerInfoPre extends PointerInfoBase {
  12046. /**
  12047. * Ray from a pointer if availible (eg. 6dof controller)
  12048. */
  12049. ray: Nullable<Ray>;
  12050. /**
  12051. * Defines the local position of the pointer on the canvas.
  12052. */
  12053. localPosition: Vector2;
  12054. /**
  12055. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12056. */
  12057. skipOnPointerObservable: boolean;
  12058. /**
  12059. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12060. * @param type Defines the type of event (PointerEventTypes)
  12061. * @param event Defines the related dom event
  12062. * @param localX Defines the local x coordinates of the pointer when the event occured
  12063. * @param localY Defines the local y coordinates of the pointer when the event occured
  12064. */
  12065. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12066. }
  12067. /**
  12068. * This type contains all the data related to a pointer event in Babylon.js.
  12069. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  12070. */
  12071. export class PointerInfo extends PointerInfoBase {
  12072. /**
  12073. * Defines the picking info associated to the info (if any)\
  12074. */
  12075. pickInfo: Nullable<PickingInfo>;
  12076. /**
  12077. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12078. * @param type Defines the type of event (PointerEventTypes)
  12079. * @param event Defines the related dom event
  12080. * @param pickInfo Defines the picking info associated to the info (if any)\
  12081. */
  12082. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12083. /**
  12084. * Defines the picking info associated to the info (if any)\
  12085. */
  12086. pickInfo: Nullable<PickingInfo>);
  12087. }
  12088. /**
  12089. * Data relating to a touch event on the screen.
  12090. */
  12091. export interface PointerTouch {
  12092. /**
  12093. * X coordinate of touch.
  12094. */
  12095. x: number;
  12096. /**
  12097. * Y coordinate of touch.
  12098. */
  12099. y: number;
  12100. /**
  12101. * Id of touch. Unique for each finger.
  12102. */
  12103. pointerId: number;
  12104. /**
  12105. * Event type passed from DOM.
  12106. */
  12107. type: any;
  12108. }
  12109. }
  12110. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12111. import { Nullable } from "babylonjs/types";
  12112. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12113. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12114. /**
  12115. * Manage the mouse inputs to control the movement of a free camera.
  12116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12117. */
  12118. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12119. /**
  12120. * Define if touch is enabled in the mouse input
  12121. */
  12122. touchEnabled: boolean;
  12123. /**
  12124. * Defines the camera the input is attached to.
  12125. */
  12126. camera: FreeCamera;
  12127. /**
  12128. * Defines the buttons associated with the input to handle camera move.
  12129. */
  12130. buttons: number[];
  12131. /**
  12132. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12133. */
  12134. angularSensibility: number;
  12135. private _pointerInput;
  12136. private _onMouseMove;
  12137. private _observer;
  12138. private previousPosition;
  12139. /**
  12140. * Manage the mouse inputs to control the movement of a free camera.
  12141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12142. * @param touchEnabled Defines if touch is enabled or not
  12143. */
  12144. constructor(
  12145. /**
  12146. * Define if touch is enabled in the mouse input
  12147. */
  12148. touchEnabled?: boolean);
  12149. /**
  12150. * Attach the input controls to a specific dom element to get the input from.
  12151. * @param element Defines the element the controls should be listened from
  12152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12153. */
  12154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12155. /**
  12156. * Called on JS contextmenu event.
  12157. * Override this method to provide functionality.
  12158. */
  12159. protected onContextMenu(evt: PointerEvent): void;
  12160. /**
  12161. * Detach the current controls from the specified dom element.
  12162. * @param element Defines the element to stop listening the inputs from
  12163. */
  12164. detachControl(element: Nullable<HTMLElement>): void;
  12165. /**
  12166. * Gets the class name of the current intput.
  12167. * @returns the class name
  12168. */
  12169. getClassName(): string;
  12170. /**
  12171. * Get the friendly name associated with the input class.
  12172. * @returns the input friendly name
  12173. */
  12174. getSimpleName(): string;
  12175. }
  12176. }
  12177. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12178. import { Nullable } from "babylonjs/types";
  12179. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12180. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12181. /**
  12182. * Manage the touch inputs to control the movement of a free camera.
  12183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12184. */
  12185. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12186. /**
  12187. * Defines the camera the input is attached to.
  12188. */
  12189. camera: FreeCamera;
  12190. /**
  12191. * Defines the touch sensibility for rotation.
  12192. * The higher the faster.
  12193. */
  12194. touchAngularSensibility: number;
  12195. /**
  12196. * Defines the touch sensibility for move.
  12197. * The higher the faster.
  12198. */
  12199. touchMoveSensibility: number;
  12200. private _offsetX;
  12201. private _offsetY;
  12202. private _pointerPressed;
  12203. private _pointerInput;
  12204. private _observer;
  12205. private _onLostFocus;
  12206. /**
  12207. * Attach the input controls to a specific dom element to get the input from.
  12208. * @param element Defines the element the controls should be listened from
  12209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12210. */
  12211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12212. /**
  12213. * Detach the current controls from the specified dom element.
  12214. * @param element Defines the element to stop listening the inputs from
  12215. */
  12216. detachControl(element: Nullable<HTMLElement>): void;
  12217. /**
  12218. * Update the current camera state depending on the inputs that have been used this frame.
  12219. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12220. */
  12221. checkInputs(): void;
  12222. /**
  12223. * Gets the class name of the current intput.
  12224. * @returns the class name
  12225. */
  12226. getClassName(): string;
  12227. /**
  12228. * Get the friendly name associated with the input class.
  12229. * @returns the input friendly name
  12230. */
  12231. getSimpleName(): string;
  12232. }
  12233. }
  12234. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12235. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12236. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12237. /**
  12238. * Default Inputs manager for the FreeCamera.
  12239. * It groups all the default supported inputs for ease of use.
  12240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12241. */
  12242. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12243. /**
  12244. * Instantiates a new FreeCameraInputsManager.
  12245. * @param camera Defines the camera the inputs belong to
  12246. */
  12247. constructor(camera: FreeCamera);
  12248. /**
  12249. * Add keyboard input support to the input manager.
  12250. * @returns the current input manager
  12251. */
  12252. addKeyboard(): FreeCameraInputsManager;
  12253. /**
  12254. * Add mouse input support to the input manager.
  12255. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12256. * @returns the current input manager
  12257. */
  12258. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12259. /**
  12260. * Add touch input support to the input manager.
  12261. * @returns the current input manager
  12262. */
  12263. addTouch(): FreeCameraInputsManager;
  12264. }
  12265. }
  12266. declare module "babylonjs/Cameras/freeCamera" {
  12267. import { Vector3 } from "babylonjs/Maths/math";
  12268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12269. import { Scene } from "babylonjs/scene";
  12270. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12271. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12272. /**
  12273. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12274. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12275. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12276. */
  12277. export class FreeCamera extends TargetCamera {
  12278. /**
  12279. * Define the collision ellipsoid of the camera.
  12280. * This is helpful to simulate a camera body like the player body around the camera
  12281. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12282. */
  12283. ellipsoid: Vector3;
  12284. /**
  12285. * Define an offset for the position of the ellipsoid around the camera.
  12286. * This can be helpful to determine the center of the body near the gravity center of the body
  12287. * instead of its head.
  12288. */
  12289. ellipsoidOffset: Vector3;
  12290. /**
  12291. * Enable or disable collisions of the camera with the rest of the scene objects.
  12292. */
  12293. checkCollisions: boolean;
  12294. /**
  12295. * Enable or disable gravity on the camera.
  12296. */
  12297. applyGravity: boolean;
  12298. /**
  12299. * Define the input manager associated to the camera.
  12300. */
  12301. inputs: FreeCameraInputsManager;
  12302. /**
  12303. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12304. * Higher values reduce sensitivity.
  12305. */
  12306. /**
  12307. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12308. * Higher values reduce sensitivity.
  12309. */
  12310. angularSensibility: number;
  12311. /**
  12312. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12313. */
  12314. keysUp: number[];
  12315. /**
  12316. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12317. */
  12318. keysDown: number[];
  12319. /**
  12320. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12321. */
  12322. keysLeft: number[];
  12323. /**
  12324. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12325. */
  12326. keysRight: number[];
  12327. /**
  12328. * Event raised when the camera collide with a mesh in the scene.
  12329. */
  12330. onCollide: (collidedMesh: AbstractMesh) => void;
  12331. private _collider;
  12332. private _needMoveForGravity;
  12333. private _oldPosition;
  12334. private _diffPosition;
  12335. private _newPosition;
  12336. /** @hidden */
  12337. _localDirection: Vector3;
  12338. /** @hidden */
  12339. _transformedDirection: Vector3;
  12340. /**
  12341. * Instantiates a Free Camera.
  12342. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12343. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12344. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12345. * @param name Define the name of the camera in the scene
  12346. * @param position Define the start position of the camera in the scene
  12347. * @param scene Define the scene the camera belongs to
  12348. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12349. */
  12350. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12351. /**
  12352. * Attached controls to the current camera.
  12353. * @param element Defines the element the controls should be listened from
  12354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12355. */
  12356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12357. /**
  12358. * Detach the current controls from the camera.
  12359. * The camera will stop reacting to inputs.
  12360. * @param element Defines the element to stop listening the inputs from
  12361. */
  12362. detachControl(element: HTMLElement): void;
  12363. private _collisionMask;
  12364. /**
  12365. * Define a collision mask to limit the list of object the camera can collide with
  12366. */
  12367. collisionMask: number;
  12368. /** @hidden */
  12369. _collideWithWorld(displacement: Vector3): void;
  12370. private _onCollisionPositionChange;
  12371. /** @hidden */
  12372. _checkInputs(): void;
  12373. /** @hidden */
  12374. _decideIfNeedsToMove(): boolean;
  12375. /** @hidden */
  12376. _updatePosition(): void;
  12377. /**
  12378. * Destroy the camera and release the current resources hold by it.
  12379. */
  12380. dispose(): void;
  12381. /**
  12382. * Gets the current object class name.
  12383. * @return the class name
  12384. */
  12385. getClassName(): string;
  12386. }
  12387. }
  12388. declare module "babylonjs/Gamepads/gamepad" {
  12389. import { Observable } from "babylonjs/Misc/observable";
  12390. /**
  12391. * Represents a gamepad control stick position
  12392. */
  12393. export class StickValues {
  12394. /**
  12395. * The x component of the control stick
  12396. */
  12397. x: number;
  12398. /**
  12399. * The y component of the control stick
  12400. */
  12401. y: number;
  12402. /**
  12403. * Initializes the gamepad x and y control stick values
  12404. * @param x The x component of the gamepad control stick value
  12405. * @param y The y component of the gamepad control stick value
  12406. */
  12407. constructor(
  12408. /**
  12409. * The x component of the control stick
  12410. */
  12411. x: number,
  12412. /**
  12413. * The y component of the control stick
  12414. */
  12415. y: number);
  12416. }
  12417. /**
  12418. * An interface which manages callbacks for gamepad button changes
  12419. */
  12420. export interface GamepadButtonChanges {
  12421. /**
  12422. * Called when a gamepad has been changed
  12423. */
  12424. changed: boolean;
  12425. /**
  12426. * Called when a gamepad press event has been triggered
  12427. */
  12428. pressChanged: boolean;
  12429. /**
  12430. * Called when a touch event has been triggered
  12431. */
  12432. touchChanged: boolean;
  12433. /**
  12434. * Called when a value has changed
  12435. */
  12436. valueChanged: boolean;
  12437. }
  12438. /**
  12439. * Represents a gamepad
  12440. */
  12441. export class Gamepad {
  12442. /**
  12443. * The id of the gamepad
  12444. */
  12445. id: string;
  12446. /**
  12447. * The index of the gamepad
  12448. */
  12449. index: number;
  12450. /**
  12451. * The browser gamepad
  12452. */
  12453. browserGamepad: any;
  12454. /**
  12455. * Specifies what type of gamepad this represents
  12456. */
  12457. type: number;
  12458. private _leftStick;
  12459. private _rightStick;
  12460. /** @hidden */
  12461. _isConnected: boolean;
  12462. private _leftStickAxisX;
  12463. private _leftStickAxisY;
  12464. private _rightStickAxisX;
  12465. private _rightStickAxisY;
  12466. /**
  12467. * Triggered when the left control stick has been changed
  12468. */
  12469. private _onleftstickchanged;
  12470. /**
  12471. * Triggered when the right control stick has been changed
  12472. */
  12473. private _onrightstickchanged;
  12474. /**
  12475. * Represents a gamepad controller
  12476. */
  12477. static GAMEPAD: number;
  12478. /**
  12479. * Represents a generic controller
  12480. */
  12481. static GENERIC: number;
  12482. /**
  12483. * Represents an XBox controller
  12484. */
  12485. static XBOX: number;
  12486. /**
  12487. * Represents a pose-enabled controller
  12488. */
  12489. static POSE_ENABLED: number;
  12490. /**
  12491. * Specifies whether the left control stick should be Y-inverted
  12492. */
  12493. protected _invertLeftStickY: boolean;
  12494. /**
  12495. * Specifies if the gamepad has been connected
  12496. */
  12497. readonly isConnected: boolean;
  12498. /**
  12499. * Initializes the gamepad
  12500. * @param id The id of the gamepad
  12501. * @param index The index of the gamepad
  12502. * @param browserGamepad The browser gamepad
  12503. * @param leftStickX The x component of the left joystick
  12504. * @param leftStickY The y component of the left joystick
  12505. * @param rightStickX The x component of the right joystick
  12506. * @param rightStickY The y component of the right joystick
  12507. */
  12508. constructor(
  12509. /**
  12510. * The id of the gamepad
  12511. */
  12512. id: string,
  12513. /**
  12514. * The index of the gamepad
  12515. */
  12516. index: number,
  12517. /**
  12518. * The browser gamepad
  12519. */
  12520. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12521. /**
  12522. * Callback triggered when the left joystick has changed
  12523. * @param callback
  12524. */
  12525. onleftstickchanged(callback: (values: StickValues) => void): void;
  12526. /**
  12527. * Callback triggered when the right joystick has changed
  12528. * @param callback
  12529. */
  12530. onrightstickchanged(callback: (values: StickValues) => void): void;
  12531. /**
  12532. * Gets the left joystick
  12533. */
  12534. /**
  12535. * Sets the left joystick values
  12536. */
  12537. leftStick: StickValues;
  12538. /**
  12539. * Gets the right joystick
  12540. */
  12541. /**
  12542. * Sets the right joystick value
  12543. */
  12544. rightStick: StickValues;
  12545. /**
  12546. * Updates the gamepad joystick positions
  12547. */
  12548. update(): void;
  12549. /**
  12550. * Disposes the gamepad
  12551. */
  12552. dispose(): void;
  12553. }
  12554. /**
  12555. * Represents a generic gamepad
  12556. */
  12557. export class GenericPad extends Gamepad {
  12558. private _buttons;
  12559. private _onbuttondown;
  12560. private _onbuttonup;
  12561. /**
  12562. * Observable triggered when a button has been pressed
  12563. */
  12564. onButtonDownObservable: Observable<number>;
  12565. /**
  12566. * Observable triggered when a button has been released
  12567. */
  12568. onButtonUpObservable: Observable<number>;
  12569. /**
  12570. * Callback triggered when a button has been pressed
  12571. * @param callback Called when a button has been pressed
  12572. */
  12573. onbuttondown(callback: (buttonPressed: number) => void): void;
  12574. /**
  12575. * Callback triggered when a button has been released
  12576. * @param callback Called when a button has been released
  12577. */
  12578. onbuttonup(callback: (buttonReleased: number) => void): void;
  12579. /**
  12580. * Initializes the generic gamepad
  12581. * @param id The id of the generic gamepad
  12582. * @param index The index of the generic gamepad
  12583. * @param browserGamepad The browser gamepad
  12584. */
  12585. constructor(id: string, index: number, browserGamepad: any);
  12586. private _setButtonValue;
  12587. /**
  12588. * Updates the generic gamepad
  12589. */
  12590. update(): void;
  12591. /**
  12592. * Disposes the generic gamepad
  12593. */
  12594. dispose(): void;
  12595. }
  12596. }
  12597. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12598. import { Observable } from "babylonjs/Misc/observable";
  12599. import { Nullable } from "babylonjs/types";
  12600. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12601. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12603. import { Ray } from "babylonjs/Culling/ray";
  12604. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12605. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12606. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12607. /**
  12608. * Defines the types of pose enabled controllers that are supported
  12609. */
  12610. export enum PoseEnabledControllerType {
  12611. /**
  12612. * HTC Vive
  12613. */
  12614. VIVE = 0,
  12615. /**
  12616. * Oculus Rift
  12617. */
  12618. OCULUS = 1,
  12619. /**
  12620. * Windows mixed reality
  12621. */
  12622. WINDOWS = 2,
  12623. /**
  12624. * Samsung gear VR
  12625. */
  12626. GEAR_VR = 3,
  12627. /**
  12628. * Google Daydream
  12629. */
  12630. DAYDREAM = 4,
  12631. /**
  12632. * Generic
  12633. */
  12634. GENERIC = 5
  12635. }
  12636. /**
  12637. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12638. */
  12639. export interface MutableGamepadButton {
  12640. /**
  12641. * Value of the button/trigger
  12642. */
  12643. value: number;
  12644. /**
  12645. * If the button/trigger is currently touched
  12646. */
  12647. touched: boolean;
  12648. /**
  12649. * If the button/trigger is currently pressed
  12650. */
  12651. pressed: boolean;
  12652. }
  12653. /**
  12654. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12655. * @hidden
  12656. */
  12657. export interface ExtendedGamepadButton extends GamepadButton {
  12658. /**
  12659. * If the button/trigger is currently pressed
  12660. */
  12661. readonly pressed: boolean;
  12662. /**
  12663. * If the button/trigger is currently touched
  12664. */
  12665. readonly touched: boolean;
  12666. /**
  12667. * Value of the button/trigger
  12668. */
  12669. readonly value: number;
  12670. }
  12671. /** @hidden */
  12672. export interface _GamePadFactory {
  12673. /**
  12674. * Returns wether or not the current gamepad can be created for this type of controller.
  12675. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12676. * @returns true if it can be created, otherwise false
  12677. */
  12678. canCreate(gamepadInfo: any): boolean;
  12679. /**
  12680. * Creates a new instance of the Gamepad.
  12681. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12682. * @returns the new gamepad instance
  12683. */
  12684. create(gamepadInfo: any): Gamepad;
  12685. }
  12686. /**
  12687. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12688. */
  12689. export class PoseEnabledControllerHelper {
  12690. /** @hidden */
  12691. static _ControllerFactories: _GamePadFactory[];
  12692. /** @hidden */
  12693. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12694. /**
  12695. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12696. * @param vrGamepad the gamepad to initialized
  12697. * @returns a vr controller of the type the gamepad identified as
  12698. */
  12699. static InitiateController(vrGamepad: any): Gamepad;
  12700. }
  12701. /**
  12702. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12703. */
  12704. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12705. private _deviceRoomPosition;
  12706. private _deviceRoomRotationQuaternion;
  12707. /**
  12708. * The device position in babylon space
  12709. */
  12710. devicePosition: Vector3;
  12711. /**
  12712. * The device rotation in babylon space
  12713. */
  12714. deviceRotationQuaternion: Quaternion;
  12715. /**
  12716. * The scale factor of the device in babylon space
  12717. */
  12718. deviceScaleFactor: number;
  12719. /**
  12720. * (Likely devicePosition should be used instead) The device position in its room space
  12721. */
  12722. position: Vector3;
  12723. /**
  12724. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12725. */
  12726. rotationQuaternion: Quaternion;
  12727. /**
  12728. * The type of controller (Eg. Windows mixed reality)
  12729. */
  12730. controllerType: PoseEnabledControllerType;
  12731. protected _calculatedPosition: Vector3;
  12732. private _calculatedRotation;
  12733. /**
  12734. * The raw pose from the device
  12735. */
  12736. rawPose: DevicePose;
  12737. private _trackPosition;
  12738. private _maxRotationDistFromHeadset;
  12739. private _draggedRoomRotation;
  12740. /**
  12741. * @hidden
  12742. */
  12743. _disableTrackPosition(fixedPosition: Vector3): void;
  12744. /**
  12745. * Internal, the mesh attached to the controller
  12746. * @hidden
  12747. */
  12748. _mesh: Nullable<AbstractMesh>;
  12749. private _poseControlledCamera;
  12750. private _leftHandSystemQuaternion;
  12751. /**
  12752. * Internal, matrix used to convert room space to babylon space
  12753. * @hidden
  12754. */
  12755. _deviceToWorld: Matrix;
  12756. /**
  12757. * Node to be used when casting a ray from the controller
  12758. * @hidden
  12759. */
  12760. _pointingPoseNode: Nullable<TransformNode>;
  12761. /**
  12762. * Name of the child mesh that can be used to cast a ray from the controller
  12763. */
  12764. static readonly POINTING_POSE: string;
  12765. /**
  12766. * Creates a new PoseEnabledController from a gamepad
  12767. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12768. */
  12769. constructor(browserGamepad: any);
  12770. private _workingMatrix;
  12771. /**
  12772. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12773. */
  12774. update(): void;
  12775. /**
  12776. * Updates only the pose device and mesh without doing any button event checking
  12777. */
  12778. protected _updatePoseAndMesh(): void;
  12779. /**
  12780. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12781. * @param poseData raw pose fromthe device
  12782. */
  12783. updateFromDevice(poseData: DevicePose): void;
  12784. /**
  12785. * @hidden
  12786. */
  12787. _meshAttachedObservable: Observable<AbstractMesh>;
  12788. /**
  12789. * Attaches a mesh to the controller
  12790. * @param mesh the mesh to be attached
  12791. */
  12792. attachToMesh(mesh: AbstractMesh): void;
  12793. /**
  12794. * Attaches the controllers mesh to a camera
  12795. * @param camera the camera the mesh should be attached to
  12796. */
  12797. attachToPoseControlledCamera(camera: TargetCamera): void;
  12798. /**
  12799. * Disposes of the controller
  12800. */
  12801. dispose(): void;
  12802. /**
  12803. * The mesh that is attached to the controller
  12804. */
  12805. readonly mesh: Nullable<AbstractMesh>;
  12806. /**
  12807. * Gets the ray of the controller in the direction the controller is pointing
  12808. * @param length the length the resulting ray should be
  12809. * @returns a ray in the direction the controller is pointing
  12810. */
  12811. getForwardRay(length?: number): Ray;
  12812. }
  12813. }
  12814. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12815. import { Observable } from "babylonjs/Misc/observable";
  12816. import { Scene } from "babylonjs/scene";
  12817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12818. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12819. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12820. /**
  12821. * Defines the WebVRController object that represents controllers tracked in 3D space
  12822. */
  12823. export abstract class WebVRController extends PoseEnabledController {
  12824. /**
  12825. * Internal, the default controller model for the controller
  12826. */
  12827. protected _defaultModel: AbstractMesh;
  12828. /**
  12829. * Fired when the trigger state has changed
  12830. */
  12831. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12832. /**
  12833. * Fired when the main button state has changed
  12834. */
  12835. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12836. /**
  12837. * Fired when the secondary button state has changed
  12838. */
  12839. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12840. /**
  12841. * Fired when the pad state has changed
  12842. */
  12843. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12844. /**
  12845. * Fired when controllers stick values have changed
  12846. */
  12847. onPadValuesChangedObservable: Observable<StickValues>;
  12848. /**
  12849. * Array of button availible on the controller
  12850. */
  12851. protected _buttons: Array<MutableGamepadButton>;
  12852. private _onButtonStateChange;
  12853. /**
  12854. * Fired when a controller button's state has changed
  12855. * @param callback the callback containing the button that was modified
  12856. */
  12857. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12858. /**
  12859. * X and Y axis corrisponding to the controllers joystick
  12860. */
  12861. pad: StickValues;
  12862. /**
  12863. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12864. */
  12865. hand: string;
  12866. /**
  12867. * The default controller model for the controller
  12868. */
  12869. readonly defaultModel: AbstractMesh;
  12870. /**
  12871. * Creates a new WebVRController from a gamepad
  12872. * @param vrGamepad the gamepad that the WebVRController should be created from
  12873. */
  12874. constructor(vrGamepad: any);
  12875. /**
  12876. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12877. */
  12878. update(): void;
  12879. /**
  12880. * Function to be called when a button is modified
  12881. */
  12882. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12883. /**
  12884. * Loads a mesh and attaches it to the controller
  12885. * @param scene the scene the mesh should be added to
  12886. * @param meshLoaded callback for when the mesh has been loaded
  12887. */
  12888. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12889. private _setButtonValue;
  12890. private _changes;
  12891. private _checkChanges;
  12892. /**
  12893. * Disposes of th webVRCOntroller
  12894. */
  12895. dispose(): void;
  12896. }
  12897. }
  12898. declare module "babylonjs/Lights/hemisphericLight" {
  12899. import { Nullable } from "babylonjs/types";
  12900. import { Scene } from "babylonjs/scene";
  12901. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  12902. import { Effect } from "babylonjs/Materials/effect";
  12903. import { Light } from "babylonjs/Lights/light";
  12904. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  12905. /**
  12906. * The HemisphericLight simulates the ambient environment light,
  12907. * so the passed direction is the light reflection direction, not the incoming direction.
  12908. */
  12909. export class HemisphericLight extends Light {
  12910. /**
  12911. * The groundColor is the light in the opposite direction to the one specified during creation.
  12912. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  12913. */
  12914. groundColor: Color3;
  12915. /**
  12916. * The light reflection direction, not the incoming direction.
  12917. */
  12918. direction: Vector3;
  12919. /**
  12920. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12921. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12922. * The HemisphericLight can't cast shadows.
  12923. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12924. * @param name The friendly name of the light
  12925. * @param direction The direction of the light reflection
  12926. * @param scene The scene the light belongs to
  12927. */
  12928. constructor(name: string, direction: Vector3, scene: Scene);
  12929. protected _buildUniformLayout(): void;
  12930. /**
  12931. * Returns the string "HemisphericLight".
  12932. * @return The class name
  12933. */
  12934. getClassName(): string;
  12935. /**
  12936. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12937. * Returns the updated direction.
  12938. * @param target The target the direction should point to
  12939. * @return The computed direction
  12940. */
  12941. setDirectionToTarget(target: Vector3): Vector3;
  12942. /**
  12943. * Returns the shadow generator associated to the light.
  12944. * @returns Always null for hemispheric lights because it does not support shadows.
  12945. */
  12946. getShadowGenerator(): Nullable<IShadowGenerator>;
  12947. /**
  12948. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12949. * @param effect The effect to update
  12950. * @param lightIndex The index of the light in the effect to update
  12951. * @returns The hemispheric light
  12952. */
  12953. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12954. /**
  12955. * Computes the world matrix of the node
  12956. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12957. * @param useWasUpdatedFlag defines a reserved property
  12958. * @returns the world matrix
  12959. */
  12960. computeWorldMatrix(): Matrix;
  12961. /**
  12962. * Returns the integer 3.
  12963. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12964. */
  12965. getTypeID(): number;
  12966. /**
  12967. * Prepares the list of defines specific to the light type.
  12968. * @param defines the list of defines
  12969. * @param lightIndex defines the index of the light for the effect
  12970. */
  12971. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12972. }
  12973. }
  12974. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  12975. declare module "babylonjs/Cameras/VR/webVRCamera" {
  12976. import { Nullable } from "babylonjs/types";
  12977. import { Observable } from "babylonjs/Misc/observable";
  12978. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12979. import { Scene } from "babylonjs/scene";
  12980. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12981. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  12982. import { Node } from "babylonjs/node";
  12983. import { Ray } from "babylonjs/Culling/ray";
  12984. import "babylonjs/Cameras/RigModes/webVRRigMode";
  12985. /**
  12986. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12987. * IMPORTANT!! The data is right-hand data.
  12988. * @export
  12989. * @interface DevicePose
  12990. */
  12991. export interface DevicePose {
  12992. /**
  12993. * The position of the device, values in array are [x,y,z].
  12994. */
  12995. readonly position: Nullable<Float32Array>;
  12996. /**
  12997. * The linearVelocity of the device, values in array are [x,y,z].
  12998. */
  12999. readonly linearVelocity: Nullable<Float32Array>;
  13000. /**
  13001. * The linearAcceleration of the device, values in array are [x,y,z].
  13002. */
  13003. readonly linearAcceleration: Nullable<Float32Array>;
  13004. /**
  13005. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13006. */
  13007. readonly orientation: Nullable<Float32Array>;
  13008. /**
  13009. * The angularVelocity of the device, values in array are [x,y,z].
  13010. */
  13011. readonly angularVelocity: Nullable<Float32Array>;
  13012. /**
  13013. * The angularAcceleration of the device, values in array are [x,y,z].
  13014. */
  13015. readonly angularAcceleration: Nullable<Float32Array>;
  13016. }
  13017. /**
  13018. * Interface representing a pose controlled object in Babylon.
  13019. * A pose controlled object has both regular pose values as well as pose values
  13020. * from an external device such as a VR head mounted display
  13021. */
  13022. export interface PoseControlled {
  13023. /**
  13024. * The position of the object in babylon space.
  13025. */
  13026. position: Vector3;
  13027. /**
  13028. * The rotation quaternion of the object in babylon space.
  13029. */
  13030. rotationQuaternion: Quaternion;
  13031. /**
  13032. * The position of the device in babylon space.
  13033. */
  13034. devicePosition?: Vector3;
  13035. /**
  13036. * The rotation quaternion of the device in babylon space.
  13037. */
  13038. deviceRotationQuaternion: Quaternion;
  13039. /**
  13040. * The raw pose coming from the device.
  13041. */
  13042. rawPose: Nullable<DevicePose>;
  13043. /**
  13044. * The scale of the device to be used when translating from device space to babylon space.
  13045. */
  13046. deviceScaleFactor: number;
  13047. /**
  13048. * Updates the poseControlled values based on the input device pose.
  13049. * @param poseData the pose data to update the object with
  13050. */
  13051. updateFromDevice(poseData: DevicePose): void;
  13052. }
  13053. /**
  13054. * Set of options to customize the webVRCamera
  13055. */
  13056. export interface WebVROptions {
  13057. /**
  13058. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13059. */
  13060. trackPosition?: boolean;
  13061. /**
  13062. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13063. */
  13064. positionScale?: number;
  13065. /**
  13066. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13067. */
  13068. displayName?: string;
  13069. /**
  13070. * Should the native controller meshes be initialized. (default: true)
  13071. */
  13072. controllerMeshes?: boolean;
  13073. /**
  13074. * Creating a default HemiLight only on controllers. (default: true)
  13075. */
  13076. defaultLightingOnControllers?: boolean;
  13077. /**
  13078. * If you don't want to use the default VR button of the helper. (default: false)
  13079. */
  13080. useCustomVRButton?: boolean;
  13081. /**
  13082. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13083. */
  13084. customVRButton?: HTMLButtonElement;
  13085. /**
  13086. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13087. */
  13088. rayLength?: number;
  13089. /**
  13090. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13091. */
  13092. defaultHeight?: number;
  13093. }
  13094. /**
  13095. * This represents a WebVR camera.
  13096. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13097. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13098. */
  13099. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13100. private webVROptions;
  13101. /**
  13102. * @hidden
  13103. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13104. */
  13105. _vrDevice: any;
  13106. /**
  13107. * The rawPose of the vrDevice.
  13108. */
  13109. rawPose: Nullable<DevicePose>;
  13110. private _onVREnabled;
  13111. private _specsVersion;
  13112. private _attached;
  13113. private _frameData;
  13114. protected _descendants: Array<Node>;
  13115. private _deviceRoomPosition;
  13116. /** @hidden */
  13117. _deviceRoomRotationQuaternion: Quaternion;
  13118. private _standingMatrix;
  13119. /**
  13120. * Represents device position in babylon space.
  13121. */
  13122. devicePosition: Vector3;
  13123. /**
  13124. * Represents device rotation in babylon space.
  13125. */
  13126. deviceRotationQuaternion: Quaternion;
  13127. /**
  13128. * The scale of the device to be used when translating from device space to babylon space.
  13129. */
  13130. deviceScaleFactor: number;
  13131. private _deviceToWorld;
  13132. private _worldToDevice;
  13133. /**
  13134. * References to the webVR controllers for the vrDevice.
  13135. */
  13136. controllers: Array<WebVRController>;
  13137. /**
  13138. * Emits an event when a controller is attached.
  13139. */
  13140. onControllersAttachedObservable: Observable<WebVRController[]>;
  13141. /**
  13142. * Emits an event when a controller's mesh has been loaded;
  13143. */
  13144. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13145. /**
  13146. * Emits an event when the HMD's pose has been updated.
  13147. */
  13148. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13149. private _poseSet;
  13150. /**
  13151. * If the rig cameras be used as parent instead of this camera.
  13152. */
  13153. rigParenting: boolean;
  13154. private _lightOnControllers;
  13155. private _defaultHeight?;
  13156. /**
  13157. * Instantiates a WebVRFreeCamera.
  13158. * @param name The name of the WebVRFreeCamera
  13159. * @param position The starting anchor position for the camera
  13160. * @param scene The scene the camera belongs to
  13161. * @param webVROptions a set of customizable options for the webVRCamera
  13162. */
  13163. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13164. /**
  13165. * Gets the device distance from the ground in meters.
  13166. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  13167. */
  13168. deviceDistanceToRoomGround(): number;
  13169. /**
  13170. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13171. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13172. */
  13173. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13174. /**
  13175. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13176. * @returns A promise with a boolean set to if the standing matrix is supported.
  13177. */
  13178. useStandingMatrixAsync(): Promise<boolean>;
  13179. /**
  13180. * Disposes the camera
  13181. */
  13182. dispose(): void;
  13183. /**
  13184. * Gets a vrController by name.
  13185. * @param name The name of the controller to retreive
  13186. * @returns the controller matching the name specified or null if not found
  13187. */
  13188. getControllerByName(name: string): Nullable<WebVRController>;
  13189. private _leftController;
  13190. /**
  13191. * The controller corrisponding to the users left hand.
  13192. */
  13193. readonly leftController: Nullable<WebVRController>;
  13194. private _rightController;
  13195. /**
  13196. * The controller corrisponding to the users right hand.
  13197. */
  13198. readonly rightController: Nullable<WebVRController>;
  13199. /**
  13200. * Casts a ray forward from the vrCamera's gaze.
  13201. * @param length Length of the ray (default: 100)
  13202. * @returns the ray corrisponding to the gaze
  13203. */
  13204. getForwardRay(length?: number): Ray;
  13205. /**
  13206. * @hidden
  13207. * Updates the camera based on device's frame data
  13208. */
  13209. _checkInputs(): void;
  13210. /**
  13211. * Updates the poseControlled values based on the input device pose.
  13212. * @param poseData Pose coming from the device
  13213. */
  13214. updateFromDevice(poseData: DevicePose): void;
  13215. private _htmlElementAttached;
  13216. private _detachIfAttached;
  13217. /**
  13218. * WebVR's attach control will start broadcasting frames to the device.
  13219. * Note that in certain browsers (chrome for example) this function must be called
  13220. * within a user-interaction callback. Example:
  13221. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13222. *
  13223. * @param element html element to attach the vrDevice to
  13224. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13225. */
  13226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13227. /**
  13228. * Detaches the camera from the html element and disables VR
  13229. *
  13230. * @param element html element to detach from
  13231. */
  13232. detachControl(element: HTMLElement): void;
  13233. /**
  13234. * @returns the name of this class
  13235. */
  13236. getClassName(): string;
  13237. /**
  13238. * Calls resetPose on the vrDisplay
  13239. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13240. */
  13241. resetToCurrentRotation(): void;
  13242. /**
  13243. * @hidden
  13244. * Updates the rig cameras (left and right eye)
  13245. */
  13246. _updateRigCameras(): void;
  13247. private _workingVector;
  13248. private _oneVector;
  13249. private _workingMatrix;
  13250. private updateCacheCalled;
  13251. private _correctPositionIfNotTrackPosition;
  13252. /**
  13253. * @hidden
  13254. * Updates the cached values of the camera
  13255. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13256. */
  13257. _updateCache(ignoreParentClass?: boolean): void;
  13258. /**
  13259. * @hidden
  13260. * Get current device position in babylon world
  13261. */
  13262. _computeDevicePosition(): void;
  13263. /**
  13264. * Updates the current device position and rotation in the babylon world
  13265. */
  13266. update(): void;
  13267. /**
  13268. * @hidden
  13269. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13270. * @returns an identity matrix
  13271. */
  13272. _getViewMatrix(): Matrix;
  13273. private _tmpMatrix;
  13274. /**
  13275. * This function is called by the two RIG cameras.
  13276. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13277. * @hidden
  13278. */
  13279. _getWebVRViewMatrix(): Matrix;
  13280. /** @hidden */
  13281. _getWebVRProjectionMatrix(): Matrix;
  13282. private _onGamepadConnectedObserver;
  13283. private _onGamepadDisconnectedObserver;
  13284. private _updateCacheWhenTrackingDisabledObserver;
  13285. /**
  13286. * Initializes the controllers and their meshes
  13287. */
  13288. initControllers(): void;
  13289. }
  13290. }
  13291. declare module "babylonjs/PostProcesses/postProcess" {
  13292. import { Nullable } from "babylonjs/types";
  13293. import { SmartArray } from "babylonjs/Misc/smartArray";
  13294. import { Observable } from "babylonjs/Misc/observable";
  13295. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13296. import { Camera } from "babylonjs/Cameras/camera";
  13297. import { Effect } from "babylonjs/Materials/effect";
  13298. import "babylonjs/Shaders/postprocess.vertex";
  13299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13300. import { Engine } from "babylonjs/Engines/engine";
  13301. /**
  13302. * Size options for a post process
  13303. */
  13304. export type PostProcessOptions = {
  13305. width: number;
  13306. height: number;
  13307. };
  13308. /**
  13309. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13310. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13311. */
  13312. export class PostProcess {
  13313. /** Name of the PostProcess. */
  13314. name: string;
  13315. /**
  13316. * Gets or sets the unique id of the post process
  13317. */
  13318. uniqueId: number;
  13319. /**
  13320. * Width of the texture to apply the post process on
  13321. */
  13322. width: number;
  13323. /**
  13324. * Height of the texture to apply the post process on
  13325. */
  13326. height: number;
  13327. /**
  13328. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13329. * @hidden
  13330. */
  13331. _outputTexture: Nullable<InternalTexture>;
  13332. /**
  13333. * Sampling mode used by the shader
  13334. * See https://doc.babylonjs.com/classes/3.1/texture
  13335. */
  13336. renderTargetSamplingMode: number;
  13337. /**
  13338. * Clear color to use when screen clearing
  13339. */
  13340. clearColor: Color4;
  13341. /**
  13342. * If the buffer needs to be cleared before applying the post process. (default: true)
  13343. * Should be set to false if shader will overwrite all previous pixels.
  13344. */
  13345. autoClear: boolean;
  13346. /**
  13347. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13348. */
  13349. alphaMode: number;
  13350. /**
  13351. * Sets the setAlphaBlendConstants of the babylon engine
  13352. */
  13353. alphaConstants: Color4;
  13354. /**
  13355. * Animations to be used for the post processing
  13356. */
  13357. animations: import("babylonjs/Animations/animation").Animation[];
  13358. /**
  13359. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13360. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13361. */
  13362. enablePixelPerfectMode: boolean;
  13363. /**
  13364. * Force the postprocess to be applied without taking in account viewport
  13365. */
  13366. forceFullscreenViewport: boolean;
  13367. /**
  13368. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13369. *
  13370. * | Value | Type | Description |
  13371. * | ----- | ----------------------------------- | ----------- |
  13372. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13373. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13374. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13375. *
  13376. */
  13377. scaleMode: number;
  13378. /**
  13379. * Force textures to be a power of two (default: false)
  13380. */
  13381. alwaysForcePOT: boolean;
  13382. private _samples;
  13383. /**
  13384. * Number of sample textures (default: 1)
  13385. */
  13386. samples: number;
  13387. /**
  13388. * Modify the scale of the post process to be the same as the viewport (default: false)
  13389. */
  13390. adaptScaleToCurrentViewport: boolean;
  13391. private _camera;
  13392. private _scene;
  13393. private _engine;
  13394. private _options;
  13395. private _reusable;
  13396. private _textureType;
  13397. /**
  13398. * Smart array of input and output textures for the post process.
  13399. * @hidden
  13400. */
  13401. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13402. /**
  13403. * The index in _textures that corresponds to the output texture.
  13404. * @hidden
  13405. */
  13406. _currentRenderTextureInd: number;
  13407. private _effect;
  13408. private _samplers;
  13409. private _fragmentUrl;
  13410. private _vertexUrl;
  13411. private _parameters;
  13412. private _scaleRatio;
  13413. protected _indexParameters: any;
  13414. private _shareOutputWithPostProcess;
  13415. private _texelSize;
  13416. private _forcedOutputTexture;
  13417. /**
  13418. * Returns the fragment url or shader name used in the post process.
  13419. * @returns the fragment url or name in the shader store.
  13420. */
  13421. getEffectName(): string;
  13422. /**
  13423. * An event triggered when the postprocess is activated.
  13424. */
  13425. onActivateObservable: Observable<Camera>;
  13426. private _onActivateObserver;
  13427. /**
  13428. * A function that is added to the onActivateObservable
  13429. */
  13430. onActivate: Nullable<(camera: Camera) => void>;
  13431. /**
  13432. * An event triggered when the postprocess changes its size.
  13433. */
  13434. onSizeChangedObservable: Observable<PostProcess>;
  13435. private _onSizeChangedObserver;
  13436. /**
  13437. * A function that is added to the onSizeChangedObservable
  13438. */
  13439. onSizeChanged: (postProcess: PostProcess) => void;
  13440. /**
  13441. * An event triggered when the postprocess applies its effect.
  13442. */
  13443. onApplyObservable: Observable<Effect>;
  13444. private _onApplyObserver;
  13445. /**
  13446. * A function that is added to the onApplyObservable
  13447. */
  13448. onApply: (effect: Effect) => void;
  13449. /**
  13450. * An event triggered before rendering the postprocess
  13451. */
  13452. onBeforeRenderObservable: Observable<Effect>;
  13453. private _onBeforeRenderObserver;
  13454. /**
  13455. * A function that is added to the onBeforeRenderObservable
  13456. */
  13457. onBeforeRender: (effect: Effect) => void;
  13458. /**
  13459. * An event triggered after rendering the postprocess
  13460. */
  13461. onAfterRenderObservable: Observable<Effect>;
  13462. private _onAfterRenderObserver;
  13463. /**
  13464. * A function that is added to the onAfterRenderObservable
  13465. */
  13466. onAfterRender: (efect: Effect) => void;
  13467. /**
  13468. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  13469. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13470. */
  13471. inputTexture: InternalTexture;
  13472. /**
  13473. * Gets the camera which post process is applied to.
  13474. * @returns The camera the post process is applied to.
  13475. */
  13476. getCamera(): Camera;
  13477. /**
  13478. * Gets the texel size of the postprocess.
  13479. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13480. */
  13481. readonly texelSize: Vector2;
  13482. /**
  13483. * Creates a new instance PostProcess
  13484. * @param name The name of the PostProcess.
  13485. * @param fragmentUrl The url of the fragment shader to be used.
  13486. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13487. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13488. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13489. * @param camera The camera to apply the render pass to.
  13490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13491. * @param engine The engine which the post process will be applied. (default: current engine)
  13492. * @param reusable If the post process can be reused on the same frame. (default: false)
  13493. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13494. * @param textureType Type of textures used when performing the post process. (default: 0)
  13495. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13496. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  13497. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13498. */
  13499. constructor(
  13500. /** Name of the PostProcess. */
  13501. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  13502. /**
  13503. * Gets a string idenfifying the name of the class
  13504. * @returns "PostProcess" string
  13505. */
  13506. getClassName(): string;
  13507. /**
  13508. * Gets the engine which this post process belongs to.
  13509. * @returns The engine the post process was enabled with.
  13510. */
  13511. getEngine(): Engine;
  13512. /**
  13513. * The effect that is created when initializing the post process.
  13514. * @returns The created effect corrisponding the the postprocess.
  13515. */
  13516. getEffect(): Effect;
  13517. /**
  13518. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13519. * @param postProcess The post process to share the output with.
  13520. * @returns This post process.
  13521. */
  13522. shareOutputWith(postProcess: PostProcess): PostProcess;
  13523. /**
  13524. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13525. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13526. */
  13527. useOwnOutput(): void;
  13528. /**
  13529. * Updates the effect with the current post process compile time values and recompiles the shader.
  13530. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13531. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13532. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13533. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  13534. * @param onCompiled Called when the shader has been compiled.
  13535. * @param onError Called if there is an error when compiling a shader.
  13536. */
  13537. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13538. /**
  13539. * The post process is reusable if it can be used multiple times within one frame.
  13540. * @returns If the post process is reusable
  13541. */
  13542. isReusable(): boolean;
  13543. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13544. markTextureDirty(): void;
  13545. /**
  13546. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13547. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  13548. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13549. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13550. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13551. * @returns The target texture that was bound to be written to.
  13552. */
  13553. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13554. /**
  13555. * If the post process is supported.
  13556. */
  13557. readonly isSupported: boolean;
  13558. /**
  13559. * The aspect ratio of the output texture.
  13560. */
  13561. readonly aspectRatio: number;
  13562. /**
  13563. * Get a value indicating if the post-process is ready to be used
  13564. * @returns true if the post-process is ready (shader is compiled)
  13565. */
  13566. isReady(): boolean;
  13567. /**
  13568. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13569. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13570. */
  13571. apply(): Nullable<Effect>;
  13572. private _disposeTextures;
  13573. /**
  13574. * Disposes the post process.
  13575. * @param camera The camera to dispose the post process on.
  13576. */
  13577. dispose(camera?: Camera): void;
  13578. }
  13579. }
  13580. declare module "babylonjs/PostProcesses/postProcessManager" {
  13581. import { Nullable } from "babylonjs/types";
  13582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13583. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13584. import { Scene } from "babylonjs/scene";
  13585. /**
  13586. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13587. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13588. */
  13589. export class PostProcessManager {
  13590. private _scene;
  13591. private _indexBuffer;
  13592. private _vertexBuffers;
  13593. /**
  13594. * Creates a new instance PostProcess
  13595. * @param scene The scene that the post process is associated with.
  13596. */
  13597. constructor(scene: Scene);
  13598. private _prepareBuffers;
  13599. private _buildIndexBuffer;
  13600. /**
  13601. * Rebuilds the vertex buffers of the manager.
  13602. * @hidden
  13603. */
  13604. _rebuild(): void;
  13605. /**
  13606. * Prepares a frame to be run through a post process.
  13607. * @param sourceTexture The input texture to the post procesess. (default: null)
  13608. * @param postProcesses An array of post processes to be run. (default: null)
  13609. * @returns True if the post processes were able to be run.
  13610. * @hidden
  13611. */
  13612. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13613. /**
  13614. * Manually render a set of post processes to a texture.
  13615. * @param postProcesses An array of post processes to be run.
  13616. * @param targetTexture The target texture to render to.
  13617. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13618. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13619. * @param lodLevel defines which lod of the texture to render to
  13620. */
  13621. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13622. /**
  13623. * Finalize the result of the output of the postprocesses.
  13624. * @param doNotPresent If true the result will not be displayed to the screen.
  13625. * @param targetTexture The target texture to render to.
  13626. * @param faceIndex The index of the face to bind the target texture to.
  13627. * @param postProcesses The array of post processes to render.
  13628. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13629. * @hidden
  13630. */
  13631. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13632. /**
  13633. * Disposes of the post process manager.
  13634. */
  13635. dispose(): void;
  13636. }
  13637. }
  13638. declare module "babylonjs/Layers/layerSceneComponent" {
  13639. import { Scene } from "babylonjs/scene";
  13640. import { ISceneComponent } from "babylonjs/sceneComponent";
  13641. import { Layer } from "babylonjs/Layers/layer";
  13642. module "babylonjs/abstractScene" {
  13643. interface AbstractScene {
  13644. /**
  13645. * The list of layers (background and foreground) of the scene
  13646. */
  13647. layers: Array<Layer>;
  13648. }
  13649. }
  13650. /**
  13651. * Defines the layer scene component responsible to manage any layers
  13652. * in a given scene.
  13653. */
  13654. export class LayerSceneComponent implements ISceneComponent {
  13655. /**
  13656. * The component name helpfull to identify the component in the list of scene components.
  13657. */
  13658. readonly name: string;
  13659. /**
  13660. * The scene the component belongs to.
  13661. */
  13662. scene: Scene;
  13663. private _engine;
  13664. /**
  13665. * Creates a new instance of the component for the given scene
  13666. * @param scene Defines the scene to register the component in
  13667. */
  13668. constructor(scene: Scene);
  13669. /**
  13670. * Registers the component in a given scene
  13671. */
  13672. register(): void;
  13673. /**
  13674. * Rebuilds the elements related to this component in case of
  13675. * context lost for instance.
  13676. */
  13677. rebuild(): void;
  13678. /**
  13679. * Disposes the component and the associated ressources.
  13680. */
  13681. dispose(): void;
  13682. private _draw;
  13683. private _drawCameraPredicate;
  13684. private _drawCameraBackground;
  13685. private _drawCameraForeground;
  13686. private _drawRenderTargetPredicate;
  13687. private _drawRenderTargetBackground;
  13688. private _drawRenderTargetForeground;
  13689. }
  13690. }
  13691. declare module "babylonjs/Shaders/layer.fragment" {
  13692. /** @hidden */
  13693. export var layerPixelShader: {
  13694. name: string;
  13695. shader: string;
  13696. };
  13697. }
  13698. declare module "babylonjs/Shaders/layer.vertex" {
  13699. /** @hidden */
  13700. export var layerVertexShader: {
  13701. name: string;
  13702. shader: string;
  13703. };
  13704. }
  13705. declare module "babylonjs/Layers/layer" {
  13706. import { Observable } from "babylonjs/Misc/observable";
  13707. import { Nullable } from "babylonjs/types";
  13708. import { Scene } from "babylonjs/scene";
  13709. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13710. import { Texture } from "babylonjs/Materials/Textures/texture";
  13711. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13712. import "babylonjs/Shaders/layer.fragment";
  13713. import "babylonjs/Shaders/layer.vertex";
  13714. /**
  13715. * This represents a full screen 2d layer.
  13716. * This can be useful to display a picture in the background of your scene for instance.
  13717. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13718. */
  13719. export class Layer {
  13720. /**
  13721. * Define the name of the layer.
  13722. */
  13723. name: string;
  13724. /**
  13725. * Define the texture the layer should display.
  13726. */
  13727. texture: Nullable<Texture>;
  13728. /**
  13729. * Is the layer in background or foreground.
  13730. */
  13731. isBackground: boolean;
  13732. /**
  13733. * Define the color of the layer (instead of texture).
  13734. */
  13735. color: Color4;
  13736. /**
  13737. * Define the scale of the layer in order to zoom in out of the texture.
  13738. */
  13739. scale: Vector2;
  13740. /**
  13741. * Define an offset for the layer in order to shift the texture.
  13742. */
  13743. offset: Vector2;
  13744. /**
  13745. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13746. */
  13747. alphaBlendingMode: number;
  13748. /**
  13749. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13750. * Alpha test will not mix with the background color in case of transparency.
  13751. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13752. */
  13753. alphaTest: boolean;
  13754. /**
  13755. * Define a mask to restrict the layer to only some of the scene cameras.
  13756. */
  13757. layerMask: number;
  13758. /**
  13759. * Define the list of render target the layer is visible into.
  13760. */
  13761. renderTargetTextures: RenderTargetTexture[];
  13762. /**
  13763. * Define if the layer is only used in renderTarget or if it also
  13764. * renders in the main frame buffer of the canvas.
  13765. */
  13766. renderOnlyInRenderTargetTextures: boolean;
  13767. private _scene;
  13768. private _vertexBuffers;
  13769. private _indexBuffer;
  13770. private _effect;
  13771. private _alphaTestEffect;
  13772. /**
  13773. * An event triggered when the layer is disposed.
  13774. */
  13775. onDisposeObservable: Observable<Layer>;
  13776. private _onDisposeObserver;
  13777. /**
  13778. * Back compatibility with callback before the onDisposeObservable existed.
  13779. * The set callback will be triggered when the layer has been disposed.
  13780. */
  13781. onDispose: () => void;
  13782. /**
  13783. * An event triggered before rendering the scene
  13784. */
  13785. onBeforeRenderObservable: Observable<Layer>;
  13786. private _onBeforeRenderObserver;
  13787. /**
  13788. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13789. * The set callback will be triggered just before rendering the layer.
  13790. */
  13791. onBeforeRender: () => void;
  13792. /**
  13793. * An event triggered after rendering the scene
  13794. */
  13795. onAfterRenderObservable: Observable<Layer>;
  13796. private _onAfterRenderObserver;
  13797. /**
  13798. * Back compatibility with callback before the onAfterRenderObservable existed.
  13799. * The set callback will be triggered just after rendering the layer.
  13800. */
  13801. onAfterRender: () => void;
  13802. /**
  13803. * Instantiates a new layer.
  13804. * This represents a full screen 2d layer.
  13805. * This can be useful to display a picture in the background of your scene for instance.
  13806. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13807. * @param name Define the name of the layer in the scene
  13808. * @param imgUrl Define the url of the texture to display in the layer
  13809. * @param scene Define the scene the layer belongs to
  13810. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13811. * @param color Defines a color for the layer
  13812. */
  13813. constructor(
  13814. /**
  13815. * Define the name of the layer.
  13816. */
  13817. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13818. private _createIndexBuffer;
  13819. /** @hidden */
  13820. _rebuild(): void;
  13821. /**
  13822. * Renders the layer in the scene.
  13823. */
  13824. render(): void;
  13825. /**
  13826. * Disposes and releases the associated ressources.
  13827. */
  13828. dispose(): void;
  13829. }
  13830. }
  13831. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13832. import { Scene } from "babylonjs/scene";
  13833. import { ISceneComponent } from "babylonjs/sceneComponent";
  13834. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13835. module "babylonjs/abstractScene" {
  13836. interface AbstractScene {
  13837. /**
  13838. * The list of procedural textures added to the scene
  13839. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13840. */
  13841. proceduralTextures: Array<ProceduralTexture>;
  13842. }
  13843. }
  13844. /**
  13845. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13846. * in a given scene.
  13847. */
  13848. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13849. /**
  13850. * The component name helpfull to identify the component in the list of scene components.
  13851. */
  13852. readonly name: string;
  13853. /**
  13854. * The scene the component belongs to.
  13855. */
  13856. scene: Scene;
  13857. /**
  13858. * Creates a new instance of the component for the given scene
  13859. * @param scene Defines the scene to register the component in
  13860. */
  13861. constructor(scene: Scene);
  13862. /**
  13863. * Registers the component in a given scene
  13864. */
  13865. register(): void;
  13866. /**
  13867. * Rebuilds the elements related to this component in case of
  13868. * context lost for instance.
  13869. */
  13870. rebuild(): void;
  13871. /**
  13872. * Disposes the component and the associated ressources.
  13873. */
  13874. dispose(): void;
  13875. private _beforeClear;
  13876. }
  13877. }
  13878. declare module "babylonjs/Shaders/procedural.vertex" {
  13879. /** @hidden */
  13880. export var proceduralVertexShader: {
  13881. name: string;
  13882. shader: string;
  13883. };
  13884. }
  13885. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  13886. import { Observable } from "babylonjs/Misc/observable";
  13887. import { Nullable } from "babylonjs/types";
  13888. import { Scene } from "babylonjs/scene";
  13889. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  13890. import { Effect } from "babylonjs/Materials/effect";
  13891. import { Texture } from "babylonjs/Materials/Textures/texture";
  13892. import "babylonjs/Shaders/procedural.vertex";
  13893. /**
  13894. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  13895. * This is the base class of any Procedural texture and contains most of the shareable code.
  13896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13897. */
  13898. export class ProceduralTexture extends Texture {
  13899. isCube: boolean;
  13900. /**
  13901. * Define if the texture is enabled or not (disabled texture will not render)
  13902. */
  13903. isEnabled: boolean;
  13904. /**
  13905. * Define if the texture must be cleared before rendering (default is true)
  13906. */
  13907. autoClear: boolean;
  13908. /**
  13909. * Callback called when the texture is generated
  13910. */
  13911. onGenerated: () => void;
  13912. /**
  13913. * Event raised when the texture is generated
  13914. */
  13915. onGeneratedObservable: Observable<ProceduralTexture>;
  13916. /** @hidden */
  13917. _generateMipMaps: boolean;
  13918. /** @hidden **/
  13919. _effect: Effect;
  13920. /** @hidden */
  13921. _textures: {
  13922. [key: string]: Texture;
  13923. };
  13924. private _size;
  13925. private _currentRefreshId;
  13926. private _refreshRate;
  13927. private _vertexBuffers;
  13928. private _indexBuffer;
  13929. private _uniforms;
  13930. private _samplers;
  13931. private _fragment;
  13932. private _floats;
  13933. private _ints;
  13934. private _floatsArrays;
  13935. private _colors3;
  13936. private _colors4;
  13937. private _vectors2;
  13938. private _vectors3;
  13939. private _matrices;
  13940. private _fallbackTexture;
  13941. private _fallbackTextureUsed;
  13942. private _engine;
  13943. private _cachedDefines;
  13944. private _contentUpdateId;
  13945. private _contentData;
  13946. /**
  13947. * Instantiates a new procedural texture.
  13948. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  13949. * This is the base class of any Procedural texture and contains most of the shareable code.
  13950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13951. * @param name Define the name of the texture
  13952. * @param size Define the size of the texture to create
  13953. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13954. * @param scene Define the scene the texture belongs to
  13955. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13956. * @param generateMipMaps Define if the texture should creates mip maps or not
  13957. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13958. */
  13959. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13960. /**
  13961. * The effect that is created when initializing the post process.
  13962. * @returns The created effect corrisponding the the postprocess.
  13963. */
  13964. getEffect(): Effect;
  13965. /**
  13966. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13967. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13968. */
  13969. getContent(): Nullable<ArrayBufferView>;
  13970. private _createIndexBuffer;
  13971. /** @hidden */
  13972. _rebuild(): void;
  13973. /**
  13974. * Resets the texture in order to recreate its associated resources.
  13975. * This can be called in case of context loss
  13976. */
  13977. reset(): void;
  13978. protected _getDefines(): string;
  13979. /**
  13980. * Is the texture ready to be used ? (rendered at least once)
  13981. * @returns true if ready, otherwise, false.
  13982. */
  13983. isReady(): boolean;
  13984. /**
  13985. * Resets the refresh counter of the texture and start bak from scratch.
  13986. * Could be useful to regenerate the texture if it is setup to render only once.
  13987. */
  13988. resetRefreshCounter(): void;
  13989. /**
  13990. * Set the fragment shader to use in order to render the texture.
  13991. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13992. */
  13993. setFragment(fragment: any): void;
  13994. /**
  13995. * Define the refresh rate of the texture or the rendering frequency.
  13996. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13997. */
  13998. refreshRate: number;
  13999. /** @hidden */
  14000. _shouldRender(): boolean;
  14001. /**
  14002. * Get the size the texture is rendering at.
  14003. * @returns the size (texture is always squared)
  14004. */
  14005. getRenderSize(): number;
  14006. /**
  14007. * Resize the texture to new value.
  14008. * @param size Define the new size the texture should have
  14009. * @param generateMipMaps Define whether the new texture should create mip maps
  14010. */
  14011. resize(size: number, generateMipMaps: boolean): void;
  14012. private _checkUniform;
  14013. /**
  14014. * Set a texture in the shader program used to render.
  14015. * @param name Define the name of the uniform samplers as defined in the shader
  14016. * @param texture Define the texture to bind to this sampler
  14017. * @return the texture itself allowing "fluent" like uniform updates
  14018. */
  14019. setTexture(name: string, texture: Texture): ProceduralTexture;
  14020. /**
  14021. * Set a float in the shader.
  14022. * @param name Define the name of the uniform as defined in the shader
  14023. * @param value Define the value to give to the uniform
  14024. * @return the texture itself allowing "fluent" like uniform updates
  14025. */
  14026. setFloat(name: string, value: number): ProceduralTexture;
  14027. /**
  14028. * Set a int in the shader.
  14029. * @param name Define the name of the uniform as defined in the shader
  14030. * @param value Define the value to give to the uniform
  14031. * @return the texture itself allowing "fluent" like uniform updates
  14032. */
  14033. setInt(name: string, value: number): ProceduralTexture;
  14034. /**
  14035. * Set an array of floats in the shader.
  14036. * @param name Define the name of the uniform as defined in the shader
  14037. * @param value Define the value to give to the uniform
  14038. * @return the texture itself allowing "fluent" like uniform updates
  14039. */
  14040. setFloats(name: string, value: number[]): ProceduralTexture;
  14041. /**
  14042. * Set a vec3 in the shader from a Color3.
  14043. * @param name Define the name of the uniform as defined in the shader
  14044. * @param value Define the value to give to the uniform
  14045. * @return the texture itself allowing "fluent" like uniform updates
  14046. */
  14047. setColor3(name: string, value: Color3): ProceduralTexture;
  14048. /**
  14049. * Set a vec4 in the shader from a Color4.
  14050. * @param name Define the name of the uniform as defined in the shader
  14051. * @param value Define the value to give to the uniform
  14052. * @return the texture itself allowing "fluent" like uniform updates
  14053. */
  14054. setColor4(name: string, value: Color4): ProceduralTexture;
  14055. /**
  14056. * Set a vec2 in the shader from a Vector2.
  14057. * @param name Define the name of the uniform as defined in the shader
  14058. * @param value Define the value to give to the uniform
  14059. * @return the texture itself allowing "fluent" like uniform updates
  14060. */
  14061. setVector2(name: string, value: Vector2): ProceduralTexture;
  14062. /**
  14063. * Set a vec3 in the shader from a Vector3.
  14064. * @param name Define the name of the uniform as defined in the shader
  14065. * @param value Define the value to give to the uniform
  14066. * @return the texture itself allowing "fluent" like uniform updates
  14067. */
  14068. setVector3(name: string, value: Vector3): ProceduralTexture;
  14069. /**
  14070. * Set a mat4 in the shader from a MAtrix.
  14071. * @param name Define the name of the uniform as defined in the shader
  14072. * @param value Define the value to give to the uniform
  14073. * @return the texture itself allowing "fluent" like uniform updates
  14074. */
  14075. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14076. /**
  14077. * Render the texture to its associated render target.
  14078. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14079. */
  14080. render(useCameraPostProcess?: boolean): void;
  14081. /**
  14082. * Clone the texture.
  14083. * @returns the cloned texture
  14084. */
  14085. clone(): ProceduralTexture;
  14086. /**
  14087. * Dispose the texture and release its asoociated resources.
  14088. */
  14089. dispose(): void;
  14090. }
  14091. }
  14092. declare module "babylonjs/Particles/baseParticleSystem" {
  14093. import { Nullable } from "babylonjs/types";
  14094. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14096. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14097. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14098. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14099. import { Scene } from "babylonjs/scene";
  14100. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14101. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14102. import { Texture } from "babylonjs/Materials/Textures/texture";
  14103. import { Animation } from "babylonjs/Animations/animation";
  14104. /**
  14105. * This represents the base class for particle system in Babylon.
  14106. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14107. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14108. * @example https://doc.babylonjs.com/babylon101/particles
  14109. */
  14110. export class BaseParticleSystem {
  14111. /**
  14112. * Source color is added to the destination color without alpha affecting the result
  14113. */
  14114. static BLENDMODE_ONEONE: number;
  14115. /**
  14116. * Blend current color and particle color using particle’s alpha
  14117. */
  14118. static BLENDMODE_STANDARD: number;
  14119. /**
  14120. * Add current color and particle color multiplied by particle’s alpha
  14121. */
  14122. static BLENDMODE_ADD: number;
  14123. /**
  14124. * Multiply current color with particle color
  14125. */
  14126. static BLENDMODE_MULTIPLY: number;
  14127. /**
  14128. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14129. */
  14130. static BLENDMODE_MULTIPLYADD: number;
  14131. /**
  14132. * List of animations used by the particle system.
  14133. */
  14134. animations: Animation[];
  14135. /**
  14136. * The id of the Particle system.
  14137. */
  14138. id: string;
  14139. /**
  14140. * The friendly name of the Particle system.
  14141. */
  14142. name: string;
  14143. /**
  14144. * The rendering group used by the Particle system to chose when to render.
  14145. */
  14146. renderingGroupId: number;
  14147. /**
  14148. * The emitter represents the Mesh or position we are attaching the particle system to.
  14149. */
  14150. emitter: Nullable<AbstractMesh | Vector3>;
  14151. /**
  14152. * The maximum number of particles to emit per frame
  14153. */
  14154. emitRate: number;
  14155. /**
  14156. * If you want to launch only a few particles at once, that can be done, as well.
  14157. */
  14158. manualEmitCount: number;
  14159. /**
  14160. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14161. */
  14162. updateSpeed: number;
  14163. /**
  14164. * The amount of time the particle system is running (depends of the overall update speed).
  14165. */
  14166. targetStopDuration: number;
  14167. /**
  14168. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14169. */
  14170. disposeOnStop: boolean;
  14171. /**
  14172. * Minimum power of emitting particles.
  14173. */
  14174. minEmitPower: number;
  14175. /**
  14176. * Maximum power of emitting particles.
  14177. */
  14178. maxEmitPower: number;
  14179. /**
  14180. * Minimum life time of emitting particles.
  14181. */
  14182. minLifeTime: number;
  14183. /**
  14184. * Maximum life time of emitting particles.
  14185. */
  14186. maxLifeTime: number;
  14187. /**
  14188. * Minimum Size of emitting particles.
  14189. */
  14190. minSize: number;
  14191. /**
  14192. * Maximum Size of emitting particles.
  14193. */
  14194. maxSize: number;
  14195. /**
  14196. * Minimum scale of emitting particles on X axis.
  14197. */
  14198. minScaleX: number;
  14199. /**
  14200. * Maximum scale of emitting particles on X axis.
  14201. */
  14202. maxScaleX: number;
  14203. /**
  14204. * Minimum scale of emitting particles on Y axis.
  14205. */
  14206. minScaleY: number;
  14207. /**
  14208. * Maximum scale of emitting particles on Y axis.
  14209. */
  14210. maxScaleY: number;
  14211. /**
  14212. * Gets or sets the minimal initial rotation in radians.
  14213. */
  14214. minInitialRotation: number;
  14215. /**
  14216. * Gets or sets the maximal initial rotation in radians.
  14217. */
  14218. maxInitialRotation: number;
  14219. /**
  14220. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14221. */
  14222. minAngularSpeed: number;
  14223. /**
  14224. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14225. */
  14226. maxAngularSpeed: number;
  14227. /**
  14228. * The texture used to render each particle. (this can be a spritesheet)
  14229. */
  14230. particleTexture: Nullable<Texture>;
  14231. /**
  14232. * The layer mask we are rendering the particles through.
  14233. */
  14234. layerMask: number;
  14235. /**
  14236. * This can help using your own shader to render the particle system.
  14237. * The according effect will be created
  14238. */
  14239. customShader: any;
  14240. /**
  14241. * By default particle system starts as soon as they are created. This prevents the
  14242. * automatic start to happen and let you decide when to start emitting particles.
  14243. */
  14244. preventAutoStart: boolean;
  14245. private _noiseTexture;
  14246. /**
  14247. * Gets or sets a texture used to add random noise to particle positions
  14248. */
  14249. noiseTexture: Nullable<ProceduralTexture>;
  14250. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14251. noiseStrength: Vector3;
  14252. /**
  14253. * Callback triggered when the particle animation is ending.
  14254. */
  14255. onAnimationEnd: Nullable<() => void>;
  14256. /**
  14257. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14258. */
  14259. blendMode: number;
  14260. /**
  14261. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14262. * to override the particles.
  14263. */
  14264. forceDepthWrite: boolean;
  14265. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  14266. preWarmCycles: number;
  14267. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14268. preWarmStepOffset: number;
  14269. /**
  14270. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14271. */
  14272. spriteCellChangeSpeed: number;
  14273. /**
  14274. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14275. */
  14276. startSpriteCellID: number;
  14277. /**
  14278. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14279. */
  14280. endSpriteCellID: number;
  14281. /**
  14282. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14283. */
  14284. spriteCellWidth: number;
  14285. /**
  14286. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14287. */
  14288. spriteCellHeight: number;
  14289. /**
  14290. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14291. */
  14292. spriteRandomStartCell: boolean;
  14293. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14294. translationPivot: Vector2;
  14295. /** @hidden */
  14296. protected _isAnimationSheetEnabled: boolean;
  14297. /**
  14298. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14299. */
  14300. beginAnimationOnStart: boolean;
  14301. /**
  14302. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14303. */
  14304. beginAnimationFrom: number;
  14305. /**
  14306. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14307. */
  14308. beginAnimationTo: number;
  14309. /**
  14310. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14311. */
  14312. beginAnimationLoop: boolean;
  14313. /**
  14314. * Gets or sets a world offset applied to all particles
  14315. */
  14316. worldOffset: Vector3;
  14317. /**
  14318. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14319. */
  14320. isAnimationSheetEnabled: boolean;
  14321. /**
  14322. * Get hosting scene
  14323. * @returns the scene
  14324. */
  14325. getScene(): Scene;
  14326. /**
  14327. * You can use gravity if you want to give an orientation to your particles.
  14328. */
  14329. gravity: Vector3;
  14330. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14331. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14332. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14333. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14334. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14335. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14336. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14337. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14338. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14339. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14340. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14341. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14342. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14343. /**
  14344. * Defines the delay in milliseconds before starting the system (0 by default)
  14345. */
  14346. startDelay: number;
  14347. /**
  14348. * Gets the current list of drag gradients.
  14349. * You must use addDragGradient and removeDragGradient to udpate this list
  14350. * @returns the list of drag gradients
  14351. */
  14352. getDragGradients(): Nullable<Array<FactorGradient>>;
  14353. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14354. limitVelocityDamping: number;
  14355. /**
  14356. * Gets the current list of limit velocity gradients.
  14357. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14358. * @returns the list of limit velocity gradients
  14359. */
  14360. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14361. /**
  14362. * Gets the current list of color gradients.
  14363. * You must use addColorGradient and removeColorGradient to udpate this list
  14364. * @returns the list of color gradients
  14365. */
  14366. getColorGradients(): Nullable<Array<ColorGradient>>;
  14367. /**
  14368. * Gets the current list of size gradients.
  14369. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14370. * @returns the list of size gradients
  14371. */
  14372. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Gets the current list of color remap gradients.
  14375. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14376. * @returns the list of color remap gradients
  14377. */
  14378. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14379. /**
  14380. * Gets the current list of alpha remap gradients.
  14381. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14382. * @returns the list of alpha remap gradients
  14383. */
  14384. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14385. /**
  14386. * Gets the current list of life time gradients.
  14387. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14388. * @returns the list of life time gradients
  14389. */
  14390. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Gets the current list of angular speed gradients.
  14393. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14394. * @returns the list of angular speed gradients
  14395. */
  14396. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14397. /**
  14398. * Gets the current list of velocity gradients.
  14399. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14400. * @returns the list of velocity gradients
  14401. */
  14402. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14403. /**
  14404. * Gets the current list of start size gradients.
  14405. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14406. * @returns the list of start size gradients
  14407. */
  14408. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14409. /**
  14410. * Gets the current list of emit rate gradients.
  14411. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14412. * @returns the list of emit rate gradients
  14413. */
  14414. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14415. /**
  14416. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14417. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14418. */
  14419. direction1: Vector3;
  14420. /**
  14421. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14422. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14423. */
  14424. direction2: Vector3;
  14425. /**
  14426. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  14427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14428. */
  14429. minEmitBox: Vector3;
  14430. /**
  14431. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  14432. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14433. */
  14434. maxEmitBox: Vector3;
  14435. /**
  14436. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14437. */
  14438. color1: Color4;
  14439. /**
  14440. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14441. */
  14442. color2: Color4;
  14443. /**
  14444. * Color the particle will have at the end of its lifetime
  14445. */
  14446. colorDead: Color4;
  14447. /**
  14448. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14449. */
  14450. textureMask: Color4;
  14451. /**
  14452. * The particle emitter type defines the emitter used by the particle system.
  14453. * It can be for example box, sphere, or cone...
  14454. */
  14455. particleEmitterType: IParticleEmitterType;
  14456. /** @hidden */
  14457. _isSubEmitter: boolean;
  14458. /**
  14459. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14460. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14461. */
  14462. billboardMode: number;
  14463. protected _isBillboardBased: boolean;
  14464. /**
  14465. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14466. */
  14467. isBillboardBased: boolean;
  14468. /**
  14469. * The scene the particle system belongs to.
  14470. */
  14471. protected _scene: Scene;
  14472. /**
  14473. * Local cache of defines for image processing.
  14474. */
  14475. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14476. /**
  14477. * Default configuration related to image processing available in the standard Material.
  14478. */
  14479. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14480. /**
  14481. * Gets the image processing configuration used either in this material.
  14482. */
  14483. /**
  14484. * Sets the Default image processing configuration used either in the this material.
  14485. *
  14486. * If sets to null, the scene one is in use.
  14487. */
  14488. imageProcessingConfiguration: ImageProcessingConfiguration;
  14489. /**
  14490. * Attaches a new image processing configuration to the Standard Material.
  14491. * @param configuration
  14492. */
  14493. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14494. /** @hidden */
  14495. protected _reset(): void;
  14496. /** @hidden */
  14497. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14498. /**
  14499. * Instantiates a particle system.
  14500. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14501. * @param name The name of the particle system
  14502. */
  14503. constructor(name: string);
  14504. /**
  14505. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14506. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14507. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14508. * @returns the emitter
  14509. */
  14510. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14511. /**
  14512. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14513. * @param radius The radius of the hemisphere to emit from
  14514. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14515. * @returns the emitter
  14516. */
  14517. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14518. /**
  14519. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14520. * @param radius The radius of the sphere to emit from
  14521. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14522. * @returns the emitter
  14523. */
  14524. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14525. /**
  14526. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14527. * @param radius The radius of the sphere to emit from
  14528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14530. * @returns the emitter
  14531. */
  14532. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14533. /**
  14534. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14535. * @param radius The radius of the emission cylinder
  14536. * @param height The height of the emission cylinder
  14537. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14538. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14539. * @returns the emitter
  14540. */
  14541. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14542. /**
  14543. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14544. * @param radius The radius of the cylinder to emit from
  14545. * @param height The height of the emission cylinder
  14546. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14547. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14548. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14549. * @returns the emitter
  14550. */
  14551. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14552. /**
  14553. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14554. * @param radius The radius of the cone to emit from
  14555. * @param angle The base angle of the cone
  14556. * @returns the emitter
  14557. */
  14558. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14559. /**
  14560. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14561. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14562. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14563. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14564. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14565. * @returns the emitter
  14566. */
  14567. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14568. }
  14569. }
  14570. declare module "babylonjs/Particles/subEmitter" {
  14571. import { Scene } from "babylonjs/scene";
  14572. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14573. /**
  14574. * Type of sub emitter
  14575. */
  14576. export enum SubEmitterType {
  14577. /**
  14578. * Attached to the particle over it's lifetime
  14579. */
  14580. ATTACHED = 0,
  14581. /**
  14582. * Created when the particle dies
  14583. */
  14584. END = 1
  14585. }
  14586. /**
  14587. * Sub emitter class used to emit particles from an existing particle
  14588. */
  14589. export class SubEmitter {
  14590. /**
  14591. * the particle system to be used by the sub emitter
  14592. */
  14593. particleSystem: ParticleSystem;
  14594. /**
  14595. * Type of the submitter (Default: END)
  14596. */
  14597. type: SubEmitterType;
  14598. /**
  14599. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  14600. * Note: This only is supported when using an emitter of type Mesh
  14601. */
  14602. inheritDirection: boolean;
  14603. /**
  14604. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14605. */
  14606. inheritedVelocityAmount: number;
  14607. /**
  14608. * Creates a sub emitter
  14609. * @param particleSystem the particle system to be used by the sub emitter
  14610. */
  14611. constructor(
  14612. /**
  14613. * the particle system to be used by the sub emitter
  14614. */
  14615. particleSystem: ParticleSystem);
  14616. /**
  14617. * Clones the sub emitter
  14618. * @returns the cloned sub emitter
  14619. */
  14620. clone(): SubEmitter;
  14621. /**
  14622. * Serialize current object to a JSON object
  14623. * @returns the serialized object
  14624. */
  14625. serialize(): any;
  14626. /** @hidden */
  14627. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14628. /**
  14629. * Creates a new SubEmitter from a serialized JSON version
  14630. * @param serializationObject defines the JSON object to read from
  14631. * @param scene defines the hosting scene
  14632. * @param rootUrl defines the rootUrl for data loading
  14633. * @returns a new SubEmitter
  14634. */
  14635. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14636. /** Release associated resources */
  14637. dispose(): void;
  14638. }
  14639. }
  14640. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14641. /** @hidden */
  14642. export var clipPlaneFragmentDeclaration: {
  14643. name: string;
  14644. shader: string;
  14645. };
  14646. }
  14647. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14648. /** @hidden */
  14649. export var imageProcessingDeclaration: {
  14650. name: string;
  14651. shader: string;
  14652. };
  14653. }
  14654. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14655. /** @hidden */
  14656. export var imageProcessingFunctions: {
  14657. name: string;
  14658. shader: string;
  14659. };
  14660. }
  14661. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14662. /** @hidden */
  14663. export var clipPlaneFragment: {
  14664. name: string;
  14665. shader: string;
  14666. };
  14667. }
  14668. declare module "babylonjs/Shaders/particles.fragment" {
  14669. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14670. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14671. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14672. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14673. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14674. /** @hidden */
  14675. export var particlesPixelShader: {
  14676. name: string;
  14677. shader: string;
  14678. };
  14679. }
  14680. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14681. /** @hidden */
  14682. export var clipPlaneVertexDeclaration: {
  14683. name: string;
  14684. shader: string;
  14685. };
  14686. }
  14687. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14688. /** @hidden */
  14689. export var clipPlaneVertex: {
  14690. name: string;
  14691. shader: string;
  14692. };
  14693. }
  14694. declare module "babylonjs/Shaders/particles.vertex" {
  14695. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14696. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14697. /** @hidden */
  14698. export var particlesVertexShader: {
  14699. name: string;
  14700. shader: string;
  14701. };
  14702. }
  14703. declare module "babylonjs/Particles/particleSystem" {
  14704. import { Nullable } from "babylonjs/types";
  14705. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14706. import { Observable } from "babylonjs/Misc/observable";
  14707. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14708. import { Effect } from "babylonjs/Materials/effect";
  14709. import { Scene, IDisposable } from "babylonjs/scene";
  14710. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14711. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14712. import { Particle } from "babylonjs/Particles/particle";
  14713. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14714. import "babylonjs/Shaders/particles.fragment";
  14715. import "babylonjs/Shaders/particles.vertex";
  14716. /**
  14717. * This represents a particle system in Babylon.
  14718. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14719. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14720. * @example https://doc.babylonjs.com/babylon101/particles
  14721. */
  14722. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14723. /**
  14724. * Billboard mode will only apply to Y axis
  14725. */
  14726. static readonly BILLBOARDMODE_Y: number;
  14727. /**
  14728. * Billboard mode will apply to all axes
  14729. */
  14730. static readonly BILLBOARDMODE_ALL: number;
  14731. /**
  14732. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14733. */
  14734. static readonly BILLBOARDMODE_STRETCHED: number;
  14735. /**
  14736. * This function can be defined to provide custom update for active particles.
  14737. * This function will be called instead of regular update (age, position, color, etc.).
  14738. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14739. */
  14740. updateFunction: (particles: Particle[]) => void;
  14741. private _emitterWorldMatrix;
  14742. /**
  14743. * This function can be defined to specify initial direction for every new particle.
  14744. * It by default use the emitterType defined function
  14745. */
  14746. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14747. /**
  14748. * This function can be defined to specify initial position for every new particle.
  14749. * It by default use the emitterType defined function
  14750. */
  14751. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14752. /**
  14753. * @hidden
  14754. */
  14755. _inheritedVelocityOffset: Vector3;
  14756. /**
  14757. * An event triggered when the system is disposed
  14758. */
  14759. onDisposeObservable: Observable<ParticleSystem>;
  14760. private _onDisposeObserver;
  14761. /**
  14762. * Sets a callback that will be triggered when the system is disposed
  14763. */
  14764. onDispose: () => void;
  14765. private _particles;
  14766. private _epsilon;
  14767. private _capacity;
  14768. private _stockParticles;
  14769. private _newPartsExcess;
  14770. private _vertexData;
  14771. private _vertexBuffer;
  14772. private _vertexBuffers;
  14773. private _spriteBuffer;
  14774. private _indexBuffer;
  14775. private _effect;
  14776. private _customEffect;
  14777. private _cachedDefines;
  14778. private _scaledColorStep;
  14779. private _colorDiff;
  14780. private _scaledDirection;
  14781. private _scaledGravity;
  14782. private _currentRenderId;
  14783. private _alive;
  14784. private _useInstancing;
  14785. private _started;
  14786. private _stopped;
  14787. private _actualFrame;
  14788. private _scaledUpdateSpeed;
  14789. private _vertexBufferSize;
  14790. /** @hidden */
  14791. _currentEmitRateGradient: Nullable<FactorGradient>;
  14792. /** @hidden */
  14793. _currentEmitRate1: number;
  14794. /** @hidden */
  14795. _currentEmitRate2: number;
  14796. /** @hidden */
  14797. _currentStartSizeGradient: Nullable<FactorGradient>;
  14798. /** @hidden */
  14799. _currentStartSize1: number;
  14800. /** @hidden */
  14801. _currentStartSize2: number;
  14802. private readonly _rawTextureWidth;
  14803. private _rampGradientsTexture;
  14804. private _useRampGradients;
  14805. /** Gets or sets a boolean indicating that ramp gradients must be used
  14806. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14807. */
  14808. useRampGradients: boolean;
  14809. /**
  14810. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  14811. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  14812. */
  14813. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14814. private _subEmitters;
  14815. /**
  14816. * @hidden
  14817. * If the particle systems emitter should be disposed when the particle system is disposed
  14818. */
  14819. _disposeEmitterOnDispose: boolean;
  14820. /**
  14821. * The current active Sub-systems, this property is used by the root particle system only.
  14822. */
  14823. activeSubSystems: Array<ParticleSystem>;
  14824. private _rootParticleSystem;
  14825. /**
  14826. * Gets the current list of active particles
  14827. */
  14828. readonly particles: Particle[];
  14829. /**
  14830. * Returns the string "ParticleSystem"
  14831. * @returns a string containing the class name
  14832. */
  14833. getClassName(): string;
  14834. /**
  14835. * Instantiates a particle system.
  14836. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14837. * @param name The name of the particle system
  14838. * @param capacity The max number of particles alive at the same time
  14839. * @param scene The scene the particle system belongs to
  14840. * @param customEffect a custom effect used to change the way particles are rendered by default
  14841. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14842. * @param epsilon Offset used to render the particles
  14843. */
  14844. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14845. private _addFactorGradient;
  14846. private _removeFactorGradient;
  14847. /**
  14848. * Adds a new life time gradient
  14849. * @param gradient defines the gradient to use (between 0 and 1)
  14850. * @param factor defines the life time factor to affect to the specified gradient
  14851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14852. * @returns the current particle system
  14853. */
  14854. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14855. /**
  14856. * Remove a specific life time gradient
  14857. * @param gradient defines the gradient to remove
  14858. * @returns the current particle system
  14859. */
  14860. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14861. /**
  14862. * Adds a new size gradient
  14863. * @param gradient defines the gradient to use (between 0 and 1)
  14864. * @param factor defines the size factor to affect to the specified gradient
  14865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14866. * @returns the current particle system
  14867. */
  14868. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14869. /**
  14870. * Remove a specific size gradient
  14871. * @param gradient defines the gradient to remove
  14872. * @returns the current particle system
  14873. */
  14874. removeSizeGradient(gradient: number): IParticleSystem;
  14875. /**
  14876. * Adds a new color remap gradient
  14877. * @param gradient defines the gradient to use (between 0 and 1)
  14878. * @param min defines the color remap minimal range
  14879. * @param max defines the color remap maximal range
  14880. * @returns the current particle system
  14881. */
  14882. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14883. /**
  14884. * Remove a specific color remap gradient
  14885. * @param gradient defines the gradient to remove
  14886. * @returns the current particle system
  14887. */
  14888. removeColorRemapGradient(gradient: number): IParticleSystem;
  14889. /**
  14890. * Adds a new alpha remap gradient
  14891. * @param gradient defines the gradient to use (between 0 and 1)
  14892. * @param min defines the alpha remap minimal range
  14893. * @param max defines the alpha remap maximal range
  14894. * @returns the current particle system
  14895. */
  14896. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14897. /**
  14898. * Remove a specific alpha remap gradient
  14899. * @param gradient defines the gradient to remove
  14900. * @returns the current particle system
  14901. */
  14902. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14903. /**
  14904. * Adds a new angular speed gradient
  14905. * @param gradient defines the gradient to use (between 0 and 1)
  14906. * @param factor defines the angular speed to affect to the specified gradient
  14907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14908. * @returns the current particle system
  14909. */
  14910. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14911. /**
  14912. * Remove a specific angular speed gradient
  14913. * @param gradient defines the gradient to remove
  14914. * @returns the current particle system
  14915. */
  14916. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14917. /**
  14918. * Adds a new velocity gradient
  14919. * @param gradient defines the gradient to use (between 0 and 1)
  14920. * @param factor defines the velocity to affect to the specified gradient
  14921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14922. * @returns the current particle system
  14923. */
  14924. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14925. /**
  14926. * Remove a specific velocity gradient
  14927. * @param gradient defines the gradient to remove
  14928. * @returns the current particle system
  14929. */
  14930. removeVelocityGradient(gradient: number): IParticleSystem;
  14931. /**
  14932. * Adds a new limit velocity gradient
  14933. * @param gradient defines the gradient to use (between 0 and 1)
  14934. * @param factor defines the limit velocity value to affect to the specified gradient
  14935. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14936. * @returns the current particle system
  14937. */
  14938. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14939. /**
  14940. * Remove a specific limit velocity gradient
  14941. * @param gradient defines the gradient to remove
  14942. * @returns the current particle system
  14943. */
  14944. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14945. /**
  14946. * Adds a new drag gradient
  14947. * @param gradient defines the gradient to use (between 0 and 1)
  14948. * @param factor defines the drag value to affect to the specified gradient
  14949. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14950. * @returns the current particle system
  14951. */
  14952. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14953. /**
  14954. * Remove a specific drag gradient
  14955. * @param gradient defines the gradient to remove
  14956. * @returns the current particle system
  14957. */
  14958. removeDragGradient(gradient: number): IParticleSystem;
  14959. /**
  14960. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14961. * @param gradient defines the gradient to use (between 0 and 1)
  14962. * @param factor defines the emit rate value to affect to the specified gradient
  14963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14964. * @returns the current particle system
  14965. */
  14966. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14967. /**
  14968. * Remove a specific emit rate gradient
  14969. * @param gradient defines the gradient to remove
  14970. * @returns the current particle system
  14971. */
  14972. removeEmitRateGradient(gradient: number): IParticleSystem;
  14973. /**
  14974. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14975. * @param gradient defines the gradient to use (between 0 and 1)
  14976. * @param factor defines the start size value to affect to the specified gradient
  14977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14978. * @returns the current particle system
  14979. */
  14980. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14981. /**
  14982. * Remove a specific start size gradient
  14983. * @param gradient defines the gradient to remove
  14984. * @returns the current particle system
  14985. */
  14986. removeStartSizeGradient(gradient: number): IParticleSystem;
  14987. private _createRampGradientTexture;
  14988. /**
  14989. * Gets the current list of ramp gradients.
  14990. * You must use addRampGradient and removeRampGradient to udpate this list
  14991. * @returns the list of ramp gradients
  14992. */
  14993. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14994. /**
  14995. * Adds a new ramp gradient used to remap particle colors
  14996. * @param gradient defines the gradient to use (between 0 and 1)
  14997. * @param color defines the color to affect to the specified gradient
  14998. * @returns the current particle system
  14999. */
  15000. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15001. /**
  15002. * Remove a specific ramp gradient
  15003. * @param gradient defines the gradient to remove
  15004. * @returns the current particle system
  15005. */
  15006. removeRampGradient(gradient: number): ParticleSystem;
  15007. /**
  15008. * Adds a new color gradient
  15009. * @param gradient defines the gradient to use (between 0 and 1)
  15010. * @param color1 defines the color to affect to the specified gradient
  15011. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15012. * @returns this particle system
  15013. */
  15014. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15015. /**
  15016. * Remove a specific color gradient
  15017. * @param gradient defines the gradient to remove
  15018. * @returns this particle system
  15019. */
  15020. removeColorGradient(gradient: number): IParticleSystem;
  15021. private _fetchR;
  15022. protected _reset(): void;
  15023. private _resetEffect;
  15024. private _createVertexBuffers;
  15025. private _createIndexBuffer;
  15026. /**
  15027. * Gets the maximum number of particles active at the same time.
  15028. * @returns The max number of active particles.
  15029. */
  15030. getCapacity(): number;
  15031. /**
  15032. * Gets whether there are still active particles in the system.
  15033. * @returns True if it is alive, otherwise false.
  15034. */
  15035. isAlive(): boolean;
  15036. /**
  15037. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15038. * @returns True if it has been started, otherwise false.
  15039. */
  15040. isStarted(): boolean;
  15041. private _prepareSubEmitterInternalArray;
  15042. /**
  15043. * Starts the particle system and begins to emit
  15044. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15045. */
  15046. start(delay?: number): void;
  15047. /**
  15048. * Stops the particle system.
  15049. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  15050. */
  15051. stop(stopSubEmitters?: boolean): void;
  15052. /**
  15053. * Remove all active particles
  15054. */
  15055. reset(): void;
  15056. /**
  15057. * @hidden (for internal use only)
  15058. */
  15059. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15060. /**
  15061. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15062. * Its lifetime will start back at 0.
  15063. */
  15064. recycleParticle: (particle: Particle) => void;
  15065. private _stopSubEmitters;
  15066. private _createParticle;
  15067. private _removeFromRoot;
  15068. private _emitFromParticle;
  15069. private _update;
  15070. /** @hidden */
  15071. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15072. /** @hidden */
  15073. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15074. /** @hidden */
  15075. private _getEffect;
  15076. /**
  15077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15078. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15079. */
  15080. animate(preWarmOnly?: boolean): void;
  15081. private _appendParticleVertices;
  15082. /**
  15083. * Rebuilds the particle system.
  15084. */
  15085. rebuild(): void;
  15086. /**
  15087. * Is this system ready to be used/rendered
  15088. * @return true if the system is ready
  15089. */
  15090. isReady(): boolean;
  15091. private _render;
  15092. /**
  15093. * Renders the particle system in its current state.
  15094. * @returns the current number of particles
  15095. */
  15096. render(): number;
  15097. /**
  15098. * Disposes the particle system and free the associated resources
  15099. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15100. */
  15101. dispose(disposeTexture?: boolean): void;
  15102. /**
  15103. * Clones the particle system.
  15104. * @param name The name of the cloned object
  15105. * @param newEmitter The new emitter to use
  15106. * @returns the cloned particle system
  15107. */
  15108. clone(name: string, newEmitter: any): ParticleSystem;
  15109. /**
  15110. * Serializes the particle system to a JSON object.
  15111. * @returns the JSON object
  15112. */
  15113. serialize(): any;
  15114. /** @hidden */
  15115. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15116. /** @hidden */
  15117. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15118. /**
  15119. * Parses a JSON object to create a particle system.
  15120. * @param parsedParticleSystem The JSON object to parse
  15121. * @param scene The scene to create the particle system in
  15122. * @param rootUrl The root url to use to load external dependencies like texture
  15123. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15124. * @returns the Parsed particle system
  15125. */
  15126. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15127. }
  15128. }
  15129. declare module "babylonjs/Particles/particle" {
  15130. import { Nullable } from "babylonjs/types";
  15131. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15132. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15133. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15134. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15135. /**
  15136. * A particle represents one of the element emitted by a particle system.
  15137. * This is mainly define by its coordinates, direction, velocity and age.
  15138. */
  15139. export class Particle {
  15140. /**
  15141. * The particle system the particle belongs to.
  15142. */
  15143. particleSystem: ParticleSystem;
  15144. private static _Count;
  15145. /**
  15146. * Unique ID of the particle
  15147. */
  15148. id: number;
  15149. /**
  15150. * The world position of the particle in the scene.
  15151. */
  15152. position: Vector3;
  15153. /**
  15154. * The world direction of the particle in the scene.
  15155. */
  15156. direction: Vector3;
  15157. /**
  15158. * The color of the particle.
  15159. */
  15160. color: Color4;
  15161. /**
  15162. * The color change of the particle per step.
  15163. */
  15164. colorStep: Color4;
  15165. /**
  15166. * Defines how long will the life of the particle be.
  15167. */
  15168. lifeTime: number;
  15169. /**
  15170. * The current age of the particle.
  15171. */
  15172. age: number;
  15173. /**
  15174. * The current size of the particle.
  15175. */
  15176. size: number;
  15177. /**
  15178. * The current scale of the particle.
  15179. */
  15180. scale: Vector2;
  15181. /**
  15182. * The current angle of the particle.
  15183. */
  15184. angle: number;
  15185. /**
  15186. * Defines how fast is the angle changing.
  15187. */
  15188. angularSpeed: number;
  15189. /**
  15190. * Defines the cell index used by the particle to be rendered from a sprite.
  15191. */
  15192. cellIndex: number;
  15193. /**
  15194. * The information required to support color remapping
  15195. */
  15196. remapData: Vector4;
  15197. /** @hidden */
  15198. _randomCellOffset?: number;
  15199. /** @hidden */
  15200. _initialDirection: Nullable<Vector3>;
  15201. /** @hidden */
  15202. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15203. /** @hidden */
  15204. _initialStartSpriteCellID: number;
  15205. /** @hidden */
  15206. _initialEndSpriteCellID: number;
  15207. /** @hidden */
  15208. _currentColorGradient: Nullable<ColorGradient>;
  15209. /** @hidden */
  15210. _currentColor1: Color4;
  15211. /** @hidden */
  15212. _currentColor2: Color4;
  15213. /** @hidden */
  15214. _currentSizeGradient: Nullable<FactorGradient>;
  15215. /** @hidden */
  15216. _currentSize1: number;
  15217. /** @hidden */
  15218. _currentSize2: number;
  15219. /** @hidden */
  15220. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15221. /** @hidden */
  15222. _currentAngularSpeed1: number;
  15223. /** @hidden */
  15224. _currentAngularSpeed2: number;
  15225. /** @hidden */
  15226. _currentVelocityGradient: Nullable<FactorGradient>;
  15227. /** @hidden */
  15228. _currentVelocity1: number;
  15229. /** @hidden */
  15230. _currentVelocity2: number;
  15231. /** @hidden */
  15232. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15233. /** @hidden */
  15234. _currentLimitVelocity1: number;
  15235. /** @hidden */
  15236. _currentLimitVelocity2: number;
  15237. /** @hidden */
  15238. _currentDragGradient: Nullable<FactorGradient>;
  15239. /** @hidden */
  15240. _currentDrag1: number;
  15241. /** @hidden */
  15242. _currentDrag2: number;
  15243. /** @hidden */
  15244. _randomNoiseCoordinates1: Vector3;
  15245. /** @hidden */
  15246. _randomNoiseCoordinates2: Vector3;
  15247. /**
  15248. * Creates a new instance Particle
  15249. * @param particleSystem the particle system the particle belongs to
  15250. */
  15251. constructor(
  15252. /**
  15253. * The particle system the particle belongs to.
  15254. */
  15255. particleSystem: ParticleSystem);
  15256. private updateCellInfoFromSystem;
  15257. /**
  15258. * Defines how the sprite cell index is updated for the particle
  15259. */
  15260. updateCellIndex(): void;
  15261. /** @hidden */
  15262. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15263. /** @hidden */
  15264. _inheritParticleInfoToSubEmitters(): void;
  15265. /** @hidden */
  15266. _reset(): void;
  15267. /**
  15268. * Copy the properties of particle to another one.
  15269. * @param other the particle to copy the information to.
  15270. */
  15271. copyTo(other: Particle): void;
  15272. }
  15273. }
  15274. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15275. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15276. import { Effect } from "babylonjs/Materials/effect";
  15277. import { Particle } from "babylonjs/Particles/particle";
  15278. /**
  15279. * Particle emitter represents a volume emitting particles.
  15280. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15281. */
  15282. export interface IParticleEmitterType {
  15283. /**
  15284. * Called by the particle System when the direction is computed for the created particle.
  15285. * @param worldMatrix is the world matrix of the particle system
  15286. * @param directionToUpdate is the direction vector to update with the result
  15287. * @param particle is the particle we are computed the direction for
  15288. */
  15289. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15290. /**
  15291. * Called by the particle System when the position is computed for the created particle.
  15292. * @param worldMatrix is the world matrix of the particle system
  15293. * @param positionToUpdate is the position vector to update with the result
  15294. * @param particle is the particle we are computed the position for
  15295. */
  15296. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15297. /**
  15298. * Clones the current emitter and returns a copy of it
  15299. * @returns the new emitter
  15300. */
  15301. clone(): IParticleEmitterType;
  15302. /**
  15303. * Called by the GPUParticleSystem to setup the update shader
  15304. * @param effect defines the update shader
  15305. */
  15306. applyToShader(effect: Effect): void;
  15307. /**
  15308. * Returns a string to use to update the GPU particles update shader
  15309. * @returns the effect defines string
  15310. */
  15311. getEffectDefines(): string;
  15312. /**
  15313. * Returns a string representing the class name
  15314. * @returns a string containing the class name
  15315. */
  15316. getClassName(): string;
  15317. /**
  15318. * Serializes the particle system to a JSON object.
  15319. * @returns the JSON object
  15320. */
  15321. serialize(): any;
  15322. /**
  15323. * Parse properties from a JSON object
  15324. * @param serializationObject defines the JSON object
  15325. */
  15326. parse(serializationObject: any): void;
  15327. }
  15328. }
  15329. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15330. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15331. import { Effect } from "babylonjs/Materials/effect";
  15332. import { Particle } from "babylonjs/Particles/particle";
  15333. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15334. /**
  15335. * Particle emitter emitting particles from the inside of a box.
  15336. * It emits the particles randomly between 2 given directions.
  15337. */
  15338. export class BoxParticleEmitter implements IParticleEmitterType {
  15339. /**
  15340. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15341. */
  15342. direction1: Vector3;
  15343. /**
  15344. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15345. */
  15346. direction2: Vector3;
  15347. /**
  15348. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15349. */
  15350. minEmitBox: Vector3;
  15351. /**
  15352. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15353. */
  15354. maxEmitBox: Vector3;
  15355. /**
  15356. * Creates a new instance BoxParticleEmitter
  15357. */
  15358. constructor();
  15359. /**
  15360. * Called by the particle System when the direction is computed for the created particle.
  15361. * @param worldMatrix is the world matrix of the particle system
  15362. * @param directionToUpdate is the direction vector to update with the result
  15363. * @param particle is the particle we are computed the direction for
  15364. */
  15365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15366. /**
  15367. * Called by the particle System when the position is computed for the created particle.
  15368. * @param worldMatrix is the world matrix of the particle system
  15369. * @param positionToUpdate is the position vector to update with the result
  15370. * @param particle is the particle we are computed the position for
  15371. */
  15372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15373. /**
  15374. * Clones the current emitter and returns a copy of it
  15375. * @returns the new emitter
  15376. */
  15377. clone(): BoxParticleEmitter;
  15378. /**
  15379. * Called by the GPUParticleSystem to setup the update shader
  15380. * @param effect defines the update shader
  15381. */
  15382. applyToShader(effect: Effect): void;
  15383. /**
  15384. * Returns a string to use to update the GPU particles update shader
  15385. * @returns a string containng the defines string
  15386. */
  15387. getEffectDefines(): string;
  15388. /**
  15389. * Returns the string "BoxParticleEmitter"
  15390. * @returns a string containing the class name
  15391. */
  15392. getClassName(): string;
  15393. /**
  15394. * Serializes the particle system to a JSON object.
  15395. * @returns the JSON object
  15396. */
  15397. serialize(): any;
  15398. /**
  15399. * Parse properties from a JSON object
  15400. * @param serializationObject defines the JSON object
  15401. */
  15402. parse(serializationObject: any): void;
  15403. }
  15404. }
  15405. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15406. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15407. import { Effect } from "babylonjs/Materials/effect";
  15408. import { Particle } from "babylonjs/Particles/particle";
  15409. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15410. /**
  15411. * Particle emitter emitting particles from the inside of a cone.
  15412. * It emits the particles alongside the cone volume from the base to the particle.
  15413. * The emission direction might be randomized.
  15414. */
  15415. export class ConeParticleEmitter implements IParticleEmitterType {
  15416. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15417. directionRandomizer: number;
  15418. private _radius;
  15419. private _angle;
  15420. private _height;
  15421. /**
  15422. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15423. */
  15424. radiusRange: number;
  15425. /**
  15426. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15427. */
  15428. heightRange: number;
  15429. /**
  15430. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15431. */
  15432. emitFromSpawnPointOnly: boolean;
  15433. /**
  15434. * Gets or sets the radius of the emission cone
  15435. */
  15436. radius: number;
  15437. /**
  15438. * Gets or sets the angle of the emission cone
  15439. */
  15440. angle: number;
  15441. private _buildHeight;
  15442. /**
  15443. * Creates a new instance ConeParticleEmitter
  15444. * @param radius the radius of the emission cone (1 by default)
  15445. * @param angle the cone base angle (PI by default)
  15446. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15447. */
  15448. constructor(radius?: number, angle?: number,
  15449. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15450. directionRandomizer?: number);
  15451. /**
  15452. * Called by the particle System when the direction is computed for the created particle.
  15453. * @param worldMatrix is the world matrix of the particle system
  15454. * @param directionToUpdate is the direction vector to update with the result
  15455. * @param particle is the particle we are computed the direction for
  15456. */
  15457. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15458. /**
  15459. * Called by the particle System when the position is computed for the created particle.
  15460. * @param worldMatrix is the world matrix of the particle system
  15461. * @param positionToUpdate is the position vector to update with the result
  15462. * @param particle is the particle we are computed the position for
  15463. */
  15464. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15465. /**
  15466. * Clones the current emitter and returns a copy of it
  15467. * @returns the new emitter
  15468. */
  15469. clone(): ConeParticleEmitter;
  15470. /**
  15471. * Called by the GPUParticleSystem to setup the update shader
  15472. * @param effect defines the update shader
  15473. */
  15474. applyToShader(effect: Effect): void;
  15475. /**
  15476. * Returns a string to use to update the GPU particles update shader
  15477. * @returns a string containng the defines string
  15478. */
  15479. getEffectDefines(): string;
  15480. /**
  15481. * Returns the string "ConeParticleEmitter"
  15482. * @returns a string containing the class name
  15483. */
  15484. getClassName(): string;
  15485. /**
  15486. * Serializes the particle system to a JSON object.
  15487. * @returns the JSON object
  15488. */
  15489. serialize(): any;
  15490. /**
  15491. * Parse properties from a JSON object
  15492. * @param serializationObject defines the JSON object
  15493. */
  15494. parse(serializationObject: any): void;
  15495. }
  15496. }
  15497. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15498. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15499. import { Effect } from "babylonjs/Materials/effect";
  15500. import { Particle } from "babylonjs/Particles/particle";
  15501. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15502. /**
  15503. * Particle emitter emitting particles from the inside of a cylinder.
  15504. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15505. */
  15506. export class CylinderParticleEmitter implements IParticleEmitterType {
  15507. /**
  15508. * The radius of the emission cylinder.
  15509. */
  15510. radius: number;
  15511. /**
  15512. * The height of the emission cylinder.
  15513. */
  15514. height: number;
  15515. /**
  15516. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15517. */
  15518. radiusRange: number;
  15519. /**
  15520. * How much to randomize the particle direction [0-1].
  15521. */
  15522. directionRandomizer: number;
  15523. /**
  15524. * Creates a new instance CylinderParticleEmitter
  15525. * @param radius the radius of the emission cylinder (1 by default)
  15526. * @param height the height of the emission cylinder (1 by default)
  15527. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15528. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15529. */
  15530. constructor(
  15531. /**
  15532. * The radius of the emission cylinder.
  15533. */
  15534. radius?: number,
  15535. /**
  15536. * The height of the emission cylinder.
  15537. */
  15538. height?: number,
  15539. /**
  15540. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15541. */
  15542. radiusRange?: number,
  15543. /**
  15544. * How much to randomize the particle direction [0-1].
  15545. */
  15546. directionRandomizer?: number);
  15547. /**
  15548. * Called by the particle System when the direction is computed for the created particle.
  15549. * @param worldMatrix is the world matrix of the particle system
  15550. * @param directionToUpdate is the direction vector to update with the result
  15551. * @param particle is the particle we are computed the direction for
  15552. */
  15553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15554. /**
  15555. * Called by the particle System when the position is computed for the created particle.
  15556. * @param worldMatrix is the world matrix of the particle system
  15557. * @param positionToUpdate is the position vector to update with the result
  15558. * @param particle is the particle we are computed the position for
  15559. */
  15560. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15561. /**
  15562. * Clones the current emitter and returns a copy of it
  15563. * @returns the new emitter
  15564. */
  15565. clone(): CylinderParticleEmitter;
  15566. /**
  15567. * Called by the GPUParticleSystem to setup the update shader
  15568. * @param effect defines the update shader
  15569. */
  15570. applyToShader(effect: Effect): void;
  15571. /**
  15572. * Returns a string to use to update the GPU particles update shader
  15573. * @returns a string containng the defines string
  15574. */
  15575. getEffectDefines(): string;
  15576. /**
  15577. * Returns the string "CylinderParticleEmitter"
  15578. * @returns a string containing the class name
  15579. */
  15580. getClassName(): string;
  15581. /**
  15582. * Serializes the particle system to a JSON object.
  15583. * @returns the JSON object
  15584. */
  15585. serialize(): any;
  15586. /**
  15587. * Parse properties from a JSON object
  15588. * @param serializationObject defines the JSON object
  15589. */
  15590. parse(serializationObject: any): void;
  15591. }
  15592. /**
  15593. * Particle emitter emitting particles from the inside of a cylinder.
  15594. * It emits the particles randomly between two vectors.
  15595. */
  15596. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15597. /**
  15598. * The min limit of the emission direction.
  15599. */
  15600. direction1: Vector3;
  15601. /**
  15602. * The max limit of the emission direction.
  15603. */
  15604. direction2: Vector3;
  15605. /**
  15606. * Creates a new instance CylinderDirectedParticleEmitter
  15607. * @param radius the radius of the emission cylinder (1 by default)
  15608. * @param height the height of the emission cylinder (1 by default)
  15609. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15610. * @param direction1 the min limit of the emission direction (up vector by default)
  15611. * @param direction2 the max limit of the emission direction (up vector by default)
  15612. */
  15613. constructor(radius?: number, height?: number, radiusRange?: number,
  15614. /**
  15615. * The min limit of the emission direction.
  15616. */
  15617. direction1?: Vector3,
  15618. /**
  15619. * The max limit of the emission direction.
  15620. */
  15621. direction2?: Vector3);
  15622. /**
  15623. * Called by the particle System when the direction is computed for the created particle.
  15624. * @param worldMatrix is the world matrix of the particle system
  15625. * @param directionToUpdate is the direction vector to update with the result
  15626. * @param particle is the particle we are computed the direction for
  15627. */
  15628. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15629. /**
  15630. * Clones the current emitter and returns a copy of it
  15631. * @returns the new emitter
  15632. */
  15633. clone(): CylinderDirectedParticleEmitter;
  15634. /**
  15635. * Called by the GPUParticleSystem to setup the update shader
  15636. * @param effect defines the update shader
  15637. */
  15638. applyToShader(effect: Effect): void;
  15639. /**
  15640. * Returns a string to use to update the GPU particles update shader
  15641. * @returns a string containng the defines string
  15642. */
  15643. getEffectDefines(): string;
  15644. /**
  15645. * Returns the string "CylinderDirectedParticleEmitter"
  15646. * @returns a string containing the class name
  15647. */
  15648. getClassName(): string;
  15649. /**
  15650. * Serializes the particle system to a JSON object.
  15651. * @returns the JSON object
  15652. */
  15653. serialize(): any;
  15654. /**
  15655. * Parse properties from a JSON object
  15656. * @param serializationObject defines the JSON object
  15657. */
  15658. parse(serializationObject: any): void;
  15659. }
  15660. }
  15661. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15662. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15663. import { Effect } from "babylonjs/Materials/effect";
  15664. import { Particle } from "babylonjs/Particles/particle";
  15665. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15666. /**
  15667. * Particle emitter emitting particles from the inside of a hemisphere.
  15668. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15669. */
  15670. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15671. /**
  15672. * The radius of the emission hemisphere.
  15673. */
  15674. radius: number;
  15675. /**
  15676. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15677. */
  15678. radiusRange: number;
  15679. /**
  15680. * How much to randomize the particle direction [0-1].
  15681. */
  15682. directionRandomizer: number;
  15683. /**
  15684. * Creates a new instance HemisphericParticleEmitter
  15685. * @param radius the radius of the emission hemisphere (1 by default)
  15686. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15687. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15688. */
  15689. constructor(
  15690. /**
  15691. * The radius of the emission hemisphere.
  15692. */
  15693. radius?: number,
  15694. /**
  15695. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15696. */
  15697. radiusRange?: number,
  15698. /**
  15699. * How much to randomize the particle direction [0-1].
  15700. */
  15701. directionRandomizer?: number);
  15702. /**
  15703. * Called by the particle System when the direction is computed for the created particle.
  15704. * @param worldMatrix is the world matrix of the particle system
  15705. * @param directionToUpdate is the direction vector to update with the result
  15706. * @param particle is the particle we are computed the direction for
  15707. */
  15708. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15709. /**
  15710. * Called by the particle System when the position is computed for the created particle.
  15711. * @param worldMatrix is the world matrix of the particle system
  15712. * @param positionToUpdate is the position vector to update with the result
  15713. * @param particle is the particle we are computed the position for
  15714. */
  15715. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15716. /**
  15717. * Clones the current emitter and returns a copy of it
  15718. * @returns the new emitter
  15719. */
  15720. clone(): HemisphericParticleEmitter;
  15721. /**
  15722. * Called by the GPUParticleSystem to setup the update shader
  15723. * @param effect defines the update shader
  15724. */
  15725. applyToShader(effect: Effect): void;
  15726. /**
  15727. * Returns a string to use to update the GPU particles update shader
  15728. * @returns a string containng the defines string
  15729. */
  15730. getEffectDefines(): string;
  15731. /**
  15732. * Returns the string "HemisphericParticleEmitter"
  15733. * @returns a string containing the class name
  15734. */
  15735. getClassName(): string;
  15736. /**
  15737. * Serializes the particle system to a JSON object.
  15738. * @returns the JSON object
  15739. */
  15740. serialize(): any;
  15741. /**
  15742. * Parse properties from a JSON object
  15743. * @param serializationObject defines the JSON object
  15744. */
  15745. parse(serializationObject: any): void;
  15746. }
  15747. }
  15748. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15749. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15750. import { Effect } from "babylonjs/Materials/effect";
  15751. import { Particle } from "babylonjs/Particles/particle";
  15752. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15753. /**
  15754. * Particle emitter emitting particles from a point.
  15755. * It emits the particles randomly between 2 given directions.
  15756. */
  15757. export class PointParticleEmitter implements IParticleEmitterType {
  15758. /**
  15759. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15760. */
  15761. direction1: Vector3;
  15762. /**
  15763. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15764. */
  15765. direction2: Vector3;
  15766. /**
  15767. * Creates a new instance PointParticleEmitter
  15768. */
  15769. constructor();
  15770. /**
  15771. * Called by the particle System when the direction is computed for the created particle.
  15772. * @param worldMatrix is the world matrix of the particle system
  15773. * @param directionToUpdate is the direction vector to update with the result
  15774. * @param particle is the particle we are computed the direction for
  15775. */
  15776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15777. /**
  15778. * Called by the particle System when the position is computed for the created particle.
  15779. * @param worldMatrix is the world matrix of the particle system
  15780. * @param positionToUpdate is the position vector to update with the result
  15781. * @param particle is the particle we are computed the position for
  15782. */
  15783. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15784. /**
  15785. * Clones the current emitter and returns a copy of it
  15786. * @returns the new emitter
  15787. */
  15788. clone(): PointParticleEmitter;
  15789. /**
  15790. * Called by the GPUParticleSystem to setup the update shader
  15791. * @param effect defines the update shader
  15792. */
  15793. applyToShader(effect: Effect): void;
  15794. /**
  15795. * Returns a string to use to update the GPU particles update shader
  15796. * @returns a string containng the defines string
  15797. */
  15798. getEffectDefines(): string;
  15799. /**
  15800. * Returns the string "PointParticleEmitter"
  15801. * @returns a string containing the class name
  15802. */
  15803. getClassName(): string;
  15804. /**
  15805. * Serializes the particle system to a JSON object.
  15806. * @returns the JSON object
  15807. */
  15808. serialize(): any;
  15809. /**
  15810. * Parse properties from a JSON object
  15811. * @param serializationObject defines the JSON object
  15812. */
  15813. parse(serializationObject: any): void;
  15814. }
  15815. }
  15816. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15817. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15818. import { Effect } from "babylonjs/Materials/effect";
  15819. import { Particle } from "babylonjs/Particles/particle";
  15820. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15821. /**
  15822. * Particle emitter emitting particles from the inside of a sphere.
  15823. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15824. */
  15825. export class SphereParticleEmitter implements IParticleEmitterType {
  15826. /**
  15827. * The radius of the emission sphere.
  15828. */
  15829. radius: number;
  15830. /**
  15831. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15832. */
  15833. radiusRange: number;
  15834. /**
  15835. * How much to randomize the particle direction [0-1].
  15836. */
  15837. directionRandomizer: number;
  15838. /**
  15839. * Creates a new instance SphereParticleEmitter
  15840. * @param radius the radius of the emission sphere (1 by default)
  15841. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15842. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15843. */
  15844. constructor(
  15845. /**
  15846. * The radius of the emission sphere.
  15847. */
  15848. radius?: number,
  15849. /**
  15850. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15851. */
  15852. radiusRange?: number,
  15853. /**
  15854. * How much to randomize the particle direction [0-1].
  15855. */
  15856. directionRandomizer?: number);
  15857. /**
  15858. * Called by the particle System when the direction is computed for the created particle.
  15859. * @param worldMatrix is the world matrix of the particle system
  15860. * @param directionToUpdate is the direction vector to update with the result
  15861. * @param particle is the particle we are computed the direction for
  15862. */
  15863. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15864. /**
  15865. * Called by the particle System when the position is computed for the created particle.
  15866. * @param worldMatrix is the world matrix of the particle system
  15867. * @param positionToUpdate is the position vector to update with the result
  15868. * @param particle is the particle we are computed the position for
  15869. */
  15870. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15871. /**
  15872. * Clones the current emitter and returns a copy of it
  15873. * @returns the new emitter
  15874. */
  15875. clone(): SphereParticleEmitter;
  15876. /**
  15877. * Called by the GPUParticleSystem to setup the update shader
  15878. * @param effect defines the update shader
  15879. */
  15880. applyToShader(effect: Effect): void;
  15881. /**
  15882. * Returns a string to use to update the GPU particles update shader
  15883. * @returns a string containng the defines string
  15884. */
  15885. getEffectDefines(): string;
  15886. /**
  15887. * Returns the string "SphereParticleEmitter"
  15888. * @returns a string containing the class name
  15889. */
  15890. getClassName(): string;
  15891. /**
  15892. * Serializes the particle system to a JSON object.
  15893. * @returns the JSON object
  15894. */
  15895. serialize(): any;
  15896. /**
  15897. * Parse properties from a JSON object
  15898. * @param serializationObject defines the JSON object
  15899. */
  15900. parse(serializationObject: any): void;
  15901. }
  15902. /**
  15903. * Particle emitter emitting particles from the inside of a sphere.
  15904. * It emits the particles randomly between two vectors.
  15905. */
  15906. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15907. /**
  15908. * The min limit of the emission direction.
  15909. */
  15910. direction1: Vector3;
  15911. /**
  15912. * The max limit of the emission direction.
  15913. */
  15914. direction2: Vector3;
  15915. /**
  15916. * Creates a new instance SphereDirectedParticleEmitter
  15917. * @param radius the radius of the emission sphere (1 by default)
  15918. * @param direction1 the min limit of the emission direction (up vector by default)
  15919. * @param direction2 the max limit of the emission direction (up vector by default)
  15920. */
  15921. constructor(radius?: number,
  15922. /**
  15923. * The min limit of the emission direction.
  15924. */
  15925. direction1?: Vector3,
  15926. /**
  15927. * The max limit of the emission direction.
  15928. */
  15929. direction2?: Vector3);
  15930. /**
  15931. * Called by the particle System when the direction is computed for the created particle.
  15932. * @param worldMatrix is the world matrix of the particle system
  15933. * @param directionToUpdate is the direction vector to update with the result
  15934. * @param particle is the particle we are computed the direction for
  15935. */
  15936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15937. /**
  15938. * Clones the current emitter and returns a copy of it
  15939. * @returns the new emitter
  15940. */
  15941. clone(): SphereDirectedParticleEmitter;
  15942. /**
  15943. * Called by the GPUParticleSystem to setup the update shader
  15944. * @param effect defines the update shader
  15945. */
  15946. applyToShader(effect: Effect): void;
  15947. /**
  15948. * Returns a string to use to update the GPU particles update shader
  15949. * @returns a string containng the defines string
  15950. */
  15951. getEffectDefines(): string;
  15952. /**
  15953. * Returns the string "SphereDirectedParticleEmitter"
  15954. * @returns a string containing the class name
  15955. */
  15956. getClassName(): string;
  15957. /**
  15958. * Serializes the particle system to a JSON object.
  15959. * @returns the JSON object
  15960. */
  15961. serialize(): any;
  15962. /**
  15963. * Parse properties from a JSON object
  15964. * @param serializationObject defines the JSON object
  15965. */
  15966. parse(serializationObject: any): void;
  15967. }
  15968. }
  15969. declare module "babylonjs/Particles/EmitterTypes/index" {
  15970. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  15971. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  15972. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  15973. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  15974. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15975. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  15976. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  15977. }
  15978. declare module "babylonjs/Particles/IParticleSystem" {
  15979. import { Nullable } from "babylonjs/types";
  15980. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15983. import { Texture } from "babylonjs/Materials/Textures/texture";
  15984. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15985. import { Scene } from "babylonjs/scene";
  15986. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15987. import { Animation } from "babylonjs/Animations/animation";
  15988. /**
  15989. * Interface representing a particle system in Babylon.js.
  15990. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15991. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15992. */
  15993. export interface IParticleSystem {
  15994. /**
  15995. * List of animations used by the particle system.
  15996. */
  15997. animations: Animation[];
  15998. /**
  15999. * The id of the Particle system.
  16000. */
  16001. id: string;
  16002. /**
  16003. * The name of the Particle system.
  16004. */
  16005. name: string;
  16006. /**
  16007. * The emitter represents the Mesh or position we are attaching the particle system to.
  16008. */
  16009. emitter: Nullable<AbstractMesh | Vector3>;
  16010. /**
  16011. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16012. */
  16013. isBillboardBased: boolean;
  16014. /**
  16015. * The rendering group used by the Particle system to chose when to render.
  16016. */
  16017. renderingGroupId: number;
  16018. /**
  16019. * The layer mask we are rendering the particles through.
  16020. */
  16021. layerMask: number;
  16022. /**
  16023. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16024. */
  16025. updateSpeed: number;
  16026. /**
  16027. * The amount of time the particle system is running (depends of the overall update speed).
  16028. */
  16029. targetStopDuration: number;
  16030. /**
  16031. * The texture used to render each particle. (this can be a spritesheet)
  16032. */
  16033. particleTexture: Nullable<Texture>;
  16034. /**
  16035. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16036. */
  16037. blendMode: number;
  16038. /**
  16039. * Minimum life time of emitting particles.
  16040. */
  16041. minLifeTime: number;
  16042. /**
  16043. * Maximum life time of emitting particles.
  16044. */
  16045. maxLifeTime: number;
  16046. /**
  16047. * Minimum Size of emitting particles.
  16048. */
  16049. minSize: number;
  16050. /**
  16051. * Maximum Size of emitting particles.
  16052. */
  16053. maxSize: number;
  16054. /**
  16055. * Minimum scale of emitting particles on X axis.
  16056. */
  16057. minScaleX: number;
  16058. /**
  16059. * Maximum scale of emitting particles on X axis.
  16060. */
  16061. maxScaleX: number;
  16062. /**
  16063. * Minimum scale of emitting particles on Y axis.
  16064. */
  16065. minScaleY: number;
  16066. /**
  16067. * Maximum scale of emitting particles on Y axis.
  16068. */
  16069. maxScaleY: number;
  16070. /**
  16071. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16072. */
  16073. color1: Color4;
  16074. /**
  16075. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16076. */
  16077. color2: Color4;
  16078. /**
  16079. * Color the particle will have at the end of its lifetime.
  16080. */
  16081. colorDead: Color4;
  16082. /**
  16083. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16084. */
  16085. emitRate: number;
  16086. /**
  16087. * You can use gravity if you want to give an orientation to your particles.
  16088. */
  16089. gravity: Vector3;
  16090. /**
  16091. * Minimum power of emitting particles.
  16092. */
  16093. minEmitPower: number;
  16094. /**
  16095. * Maximum power of emitting particles.
  16096. */
  16097. maxEmitPower: number;
  16098. /**
  16099. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16100. */
  16101. minAngularSpeed: number;
  16102. /**
  16103. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16104. */
  16105. maxAngularSpeed: number;
  16106. /**
  16107. * Gets or sets the minimal initial rotation in radians.
  16108. */
  16109. minInitialRotation: number;
  16110. /**
  16111. * Gets or sets the maximal initial rotation in radians.
  16112. */
  16113. maxInitialRotation: number;
  16114. /**
  16115. * The particle emitter type defines the emitter used by the particle system.
  16116. * It can be for example box, sphere, or cone...
  16117. */
  16118. particleEmitterType: Nullable<IParticleEmitterType>;
  16119. /**
  16120. * Defines the delay in milliseconds before starting the system (0 by default)
  16121. */
  16122. startDelay: number;
  16123. /**
  16124. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  16125. */
  16126. preWarmCycles: number;
  16127. /**
  16128. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16129. */
  16130. preWarmStepOffset: number;
  16131. /**
  16132. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16133. */
  16134. spriteCellChangeSpeed: number;
  16135. /**
  16136. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16137. */
  16138. startSpriteCellID: number;
  16139. /**
  16140. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16141. */
  16142. endSpriteCellID: number;
  16143. /**
  16144. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16145. */
  16146. spriteCellWidth: number;
  16147. /**
  16148. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16149. */
  16150. spriteCellHeight: number;
  16151. /**
  16152. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16153. */
  16154. spriteRandomStartCell: boolean;
  16155. /**
  16156. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16157. */
  16158. isAnimationSheetEnabled: boolean;
  16159. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16160. translationPivot: Vector2;
  16161. /**
  16162. * Gets or sets a texture used to add random noise to particle positions
  16163. */
  16164. noiseTexture: Nullable<BaseTexture>;
  16165. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16166. noiseStrength: Vector3;
  16167. /**
  16168. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16169. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16170. */
  16171. billboardMode: number;
  16172. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16173. limitVelocityDamping: number;
  16174. /**
  16175. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16176. */
  16177. beginAnimationOnStart: boolean;
  16178. /**
  16179. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16180. */
  16181. beginAnimationFrom: number;
  16182. /**
  16183. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16184. */
  16185. beginAnimationTo: number;
  16186. /**
  16187. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16188. */
  16189. beginAnimationLoop: boolean;
  16190. /**
  16191. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16192. */
  16193. disposeOnStop: boolean;
  16194. /**
  16195. * Gets the maximum number of particles active at the same time.
  16196. * @returns The max number of active particles.
  16197. */
  16198. getCapacity(): number;
  16199. /**
  16200. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16201. * @returns True if it has been started, otherwise false.
  16202. */
  16203. isStarted(): boolean;
  16204. /**
  16205. * Animates the particle system for this frame.
  16206. */
  16207. animate(): void;
  16208. /**
  16209. * Renders the particle system in its current state.
  16210. * @returns the current number of particles
  16211. */
  16212. render(): number;
  16213. /**
  16214. * Dispose the particle system and frees its associated resources.
  16215. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16216. */
  16217. dispose(disposeTexture?: boolean): void;
  16218. /**
  16219. * Clones the particle system.
  16220. * @param name The name of the cloned object
  16221. * @param newEmitter The new emitter to use
  16222. * @returns the cloned particle system
  16223. */
  16224. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16225. /**
  16226. * Serializes the particle system to a JSON object.
  16227. * @returns the JSON object
  16228. */
  16229. serialize(): any;
  16230. /**
  16231. * Rebuild the particle system
  16232. */
  16233. rebuild(): void;
  16234. /**
  16235. * Starts the particle system and begins to emit
  16236. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16237. */
  16238. start(delay?: number): void;
  16239. /**
  16240. * Stops the particle system.
  16241. */
  16242. stop(): void;
  16243. /**
  16244. * Remove all active particles
  16245. */
  16246. reset(): void;
  16247. /**
  16248. * Is this system ready to be used/rendered
  16249. * @return true if the system is ready
  16250. */
  16251. isReady(): boolean;
  16252. /**
  16253. * Adds a new color gradient
  16254. * @param gradient defines the gradient to use (between 0 and 1)
  16255. * @param color1 defines the color to affect to the specified gradient
  16256. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16257. * @returns the current particle system
  16258. */
  16259. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16260. /**
  16261. * Remove a specific color gradient
  16262. * @param gradient defines the gradient to remove
  16263. * @returns the current particle system
  16264. */
  16265. removeColorGradient(gradient: number): IParticleSystem;
  16266. /**
  16267. * Adds a new size gradient
  16268. * @param gradient defines the gradient to use (between 0 and 1)
  16269. * @param factor defines the size factor to affect to the specified gradient
  16270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16271. * @returns the current particle system
  16272. */
  16273. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16274. /**
  16275. * Remove a specific size gradient
  16276. * @param gradient defines the gradient to remove
  16277. * @returns the current particle system
  16278. */
  16279. removeSizeGradient(gradient: number): IParticleSystem;
  16280. /**
  16281. * Gets the current list of color gradients.
  16282. * You must use addColorGradient and removeColorGradient to udpate this list
  16283. * @returns the list of color gradients
  16284. */
  16285. getColorGradients(): Nullable<Array<ColorGradient>>;
  16286. /**
  16287. * Gets the current list of size gradients.
  16288. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16289. * @returns the list of size gradients
  16290. */
  16291. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16292. /**
  16293. * Gets the current list of angular speed gradients.
  16294. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16295. * @returns the list of angular speed gradients
  16296. */
  16297. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16298. /**
  16299. * Adds a new angular speed gradient
  16300. * @param gradient defines the gradient to use (between 0 and 1)
  16301. * @param factor defines the angular speed to affect to the specified gradient
  16302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16303. * @returns the current particle system
  16304. */
  16305. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16306. /**
  16307. * Remove a specific angular speed gradient
  16308. * @param gradient defines the gradient to remove
  16309. * @returns the current particle system
  16310. */
  16311. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16312. /**
  16313. * Gets the current list of velocity gradients.
  16314. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16315. * @returns the list of velocity gradients
  16316. */
  16317. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16318. /**
  16319. * Adds a new velocity gradient
  16320. * @param gradient defines the gradient to use (between 0 and 1)
  16321. * @param factor defines the velocity to affect to the specified gradient
  16322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16323. * @returns the current particle system
  16324. */
  16325. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16326. /**
  16327. * Remove a specific velocity gradient
  16328. * @param gradient defines the gradient to remove
  16329. * @returns the current particle system
  16330. */
  16331. removeVelocityGradient(gradient: number): IParticleSystem;
  16332. /**
  16333. * Gets the current list of limit velocity gradients.
  16334. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16335. * @returns the list of limit velocity gradients
  16336. */
  16337. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16338. /**
  16339. * Adds a new limit velocity gradient
  16340. * @param gradient defines the gradient to use (between 0 and 1)
  16341. * @param factor defines the limit velocity to affect to the specified gradient
  16342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16343. * @returns the current particle system
  16344. */
  16345. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16346. /**
  16347. * Remove a specific limit velocity gradient
  16348. * @param gradient defines the gradient to remove
  16349. * @returns the current particle system
  16350. */
  16351. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16352. /**
  16353. * Adds a new drag gradient
  16354. * @param gradient defines the gradient to use (between 0 and 1)
  16355. * @param factor defines the drag to affect to the specified gradient
  16356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16357. * @returns the current particle system
  16358. */
  16359. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16360. /**
  16361. * Remove a specific drag gradient
  16362. * @param gradient defines the gradient to remove
  16363. * @returns the current particle system
  16364. */
  16365. removeDragGradient(gradient: number): IParticleSystem;
  16366. /**
  16367. * Gets the current list of drag gradients.
  16368. * You must use addDragGradient and removeDragGradient to udpate this list
  16369. * @returns the list of drag gradients
  16370. */
  16371. getDragGradients(): Nullable<Array<FactorGradient>>;
  16372. /**
  16373. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16374. * @param gradient defines the gradient to use (between 0 and 1)
  16375. * @param factor defines the emit rate to affect to the specified gradient
  16376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16377. * @returns the current particle system
  16378. */
  16379. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16380. /**
  16381. * Remove a specific emit rate gradient
  16382. * @param gradient defines the gradient to remove
  16383. * @returns the current particle system
  16384. */
  16385. removeEmitRateGradient(gradient: number): IParticleSystem;
  16386. /**
  16387. * Gets the current list of emit rate gradients.
  16388. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16389. * @returns the list of emit rate gradients
  16390. */
  16391. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16392. /**
  16393. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16394. * @param gradient defines the gradient to use (between 0 and 1)
  16395. * @param factor defines the start size to affect to the specified gradient
  16396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16397. * @returns the current particle system
  16398. */
  16399. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16400. /**
  16401. * Remove a specific start size gradient
  16402. * @param gradient defines the gradient to remove
  16403. * @returns the current particle system
  16404. */
  16405. removeStartSizeGradient(gradient: number): IParticleSystem;
  16406. /**
  16407. * Gets the current list of start size gradients.
  16408. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16409. * @returns the list of start size gradients
  16410. */
  16411. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16412. /**
  16413. * Adds a new life time gradient
  16414. * @param gradient defines the gradient to use (between 0 and 1)
  16415. * @param factor defines the life time factor to affect to the specified gradient
  16416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16417. * @returns the current particle system
  16418. */
  16419. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16420. /**
  16421. * Remove a specific life time gradient
  16422. * @param gradient defines the gradient to remove
  16423. * @returns the current particle system
  16424. */
  16425. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16426. /**
  16427. * Gets the current list of life time gradients.
  16428. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16429. * @returns the list of life time gradients
  16430. */
  16431. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16432. /**
  16433. * Gets the current list of color gradients.
  16434. * You must use addColorGradient and removeColorGradient to udpate this list
  16435. * @returns the list of color gradients
  16436. */
  16437. getColorGradients(): Nullable<Array<ColorGradient>>;
  16438. /**
  16439. * Adds a new ramp gradient used to remap particle colors
  16440. * @param gradient defines the gradient to use (between 0 and 1)
  16441. * @param color defines the color to affect to the specified gradient
  16442. * @returns the current particle system
  16443. */
  16444. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16445. /**
  16446. * Gets the current list of ramp gradients.
  16447. * You must use addRampGradient and removeRampGradient to udpate this list
  16448. * @returns the list of ramp gradients
  16449. */
  16450. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16451. /** Gets or sets a boolean indicating that ramp gradients must be used
  16452. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16453. */
  16454. useRampGradients: boolean;
  16455. /**
  16456. * Adds a new color remap gradient
  16457. * @param gradient defines the gradient to use (between 0 and 1)
  16458. * @param min defines the color remap minimal range
  16459. * @param max defines the color remap maximal range
  16460. * @returns the current particle system
  16461. */
  16462. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16463. /**
  16464. * Gets the current list of color remap gradients.
  16465. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16466. * @returns the list of color remap gradients
  16467. */
  16468. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16469. /**
  16470. * Adds a new alpha remap gradient
  16471. * @param gradient defines the gradient to use (between 0 and 1)
  16472. * @param min defines the alpha remap minimal range
  16473. * @param max defines the alpha remap maximal range
  16474. * @returns the current particle system
  16475. */
  16476. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16477. /**
  16478. * Gets the current list of alpha remap gradients.
  16479. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16480. * @returns the list of alpha remap gradients
  16481. */
  16482. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16483. /**
  16484. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16487. * @returns the emitter
  16488. */
  16489. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16490. /**
  16491. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16492. * @param radius The radius of the hemisphere to emit from
  16493. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16494. * @returns the emitter
  16495. */
  16496. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16497. /**
  16498. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16499. * @param radius The radius of the sphere to emit from
  16500. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16501. * @returns the emitter
  16502. */
  16503. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16504. /**
  16505. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16506. * @param radius The radius of the sphere to emit from
  16507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16509. * @returns the emitter
  16510. */
  16511. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16512. /**
  16513. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16514. * @param radius The radius of the emission cylinder
  16515. * @param height The height of the emission cylinder
  16516. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16517. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16518. * @returns the emitter
  16519. */
  16520. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16521. /**
  16522. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16523. * @param radius The radius of the cylinder to emit from
  16524. * @param height The height of the emission cylinder
  16525. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16528. * @returns the emitter
  16529. */
  16530. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16531. /**
  16532. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16533. * @param radius The radius of the cone to emit from
  16534. * @param angle The base angle of the cone
  16535. * @returns the emitter
  16536. */
  16537. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16538. /**
  16539. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16540. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16541. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16542. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16543. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16544. * @returns the emitter
  16545. */
  16546. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16547. /**
  16548. * Get hosting scene
  16549. * @returns the scene
  16550. */
  16551. getScene(): Scene;
  16552. }
  16553. }
  16554. declare module "babylonjs/Meshes/instancedMesh" {
  16555. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16556. import { Vector3 } from "babylonjs/Maths/math";
  16557. import { Camera } from "babylonjs/Cameras/camera";
  16558. import { Node } from "babylonjs/node";
  16559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16560. import { Mesh } from "babylonjs/Meshes/mesh";
  16561. import { Material } from "babylonjs/Materials/material";
  16562. import { Skeleton } from "babylonjs/Bones/skeleton";
  16563. /**
  16564. * Creates an instance based on a source mesh.
  16565. */
  16566. export class InstancedMesh extends AbstractMesh {
  16567. private _sourceMesh;
  16568. private _currentLOD;
  16569. /** @hidden */
  16570. _indexInSourceMeshInstanceArray: number;
  16571. constructor(name: string, source: Mesh);
  16572. /**
  16573. * Returns the string "InstancedMesh".
  16574. */
  16575. getClassName(): string;
  16576. /**
  16577. * If the source mesh receives shadows
  16578. */
  16579. readonly receiveShadows: boolean;
  16580. /**
  16581. * The material of the source mesh
  16582. */
  16583. readonly material: Nullable<Material>;
  16584. /**
  16585. * Visibility of the source mesh
  16586. */
  16587. readonly visibility: number;
  16588. /**
  16589. * Skeleton of the source mesh
  16590. */
  16591. readonly skeleton: Nullable<Skeleton>;
  16592. /**
  16593. * Rendering ground id of the source mesh
  16594. */
  16595. renderingGroupId: number;
  16596. /**
  16597. * Returns the total number of vertices (integer).
  16598. */
  16599. getTotalVertices(): number;
  16600. /**
  16601. * Returns a positive integer : the total number of indices in this mesh geometry.
  16602. * @returns the numner of indices or zero if the mesh has no geometry.
  16603. */
  16604. getTotalIndices(): number;
  16605. /**
  16606. * The source mesh of the instance
  16607. */
  16608. readonly sourceMesh: Mesh;
  16609. /**
  16610. * Is this node ready to be used/rendered
  16611. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16612. * @return {boolean} is it ready
  16613. */
  16614. isReady(completeCheck?: boolean): boolean;
  16615. /**
  16616. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16617. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16618. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16619. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16620. */
  16621. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16622. /**
  16623. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16624. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16625. * The `data` are either a numeric array either a Float32Array.
  16626. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16627. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16628. * Note that a new underlying VertexBuffer object is created each call.
  16629. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16630. *
  16631. * Possible `kind` values :
  16632. * - VertexBuffer.PositionKind
  16633. * - VertexBuffer.UVKind
  16634. * - VertexBuffer.UV2Kind
  16635. * - VertexBuffer.UV3Kind
  16636. * - VertexBuffer.UV4Kind
  16637. * - VertexBuffer.UV5Kind
  16638. * - VertexBuffer.UV6Kind
  16639. * - VertexBuffer.ColorKind
  16640. * - VertexBuffer.MatricesIndicesKind
  16641. * - VertexBuffer.MatricesIndicesExtraKind
  16642. * - VertexBuffer.MatricesWeightsKind
  16643. * - VertexBuffer.MatricesWeightsExtraKind
  16644. *
  16645. * Returns the Mesh.
  16646. */
  16647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16648. /**
  16649. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16650. * If the mesh has no geometry, it is simply returned as it is.
  16651. * The `data` are either a numeric array either a Float32Array.
  16652. * No new underlying VertexBuffer object is created.
  16653. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16654. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16655. *
  16656. * Possible `kind` values :
  16657. * - VertexBuffer.PositionKind
  16658. * - VertexBuffer.UVKind
  16659. * - VertexBuffer.UV2Kind
  16660. * - VertexBuffer.UV3Kind
  16661. * - VertexBuffer.UV4Kind
  16662. * - VertexBuffer.UV5Kind
  16663. * - VertexBuffer.UV6Kind
  16664. * - VertexBuffer.ColorKind
  16665. * - VertexBuffer.MatricesIndicesKind
  16666. * - VertexBuffer.MatricesIndicesExtraKind
  16667. * - VertexBuffer.MatricesWeightsKind
  16668. * - VertexBuffer.MatricesWeightsExtraKind
  16669. *
  16670. * Returns the Mesh.
  16671. */
  16672. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16673. /**
  16674. * Sets the mesh indices.
  16675. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16676. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16677. * This method creates a new index buffer each call.
  16678. * Returns the Mesh.
  16679. */
  16680. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16681. /**
  16682. * Boolean : True if the mesh owns the requested kind of data.
  16683. */
  16684. isVerticesDataPresent(kind: string): boolean;
  16685. /**
  16686. * Returns an array of indices (IndicesArray).
  16687. */
  16688. getIndices(): Nullable<IndicesArray>;
  16689. readonly _positions: Nullable<Vector3[]>;
  16690. /**
  16691. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16692. * This means the mesh underlying bounding box and sphere are recomputed.
  16693. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16694. * @returns the current mesh
  16695. */
  16696. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16697. /** @hidden */
  16698. _preActivate(): InstancedMesh;
  16699. /** @hidden */
  16700. _activate(renderId: number): InstancedMesh;
  16701. /**
  16702. * Returns the current associated LOD AbstractMesh.
  16703. */
  16704. getLOD(camera: Camera): AbstractMesh;
  16705. /** @hidden */
  16706. _syncSubMeshes(): InstancedMesh;
  16707. /** @hidden */
  16708. _generatePointsArray(): boolean;
  16709. /**
  16710. * Creates a new InstancedMesh from the current mesh.
  16711. * - name (string) : the cloned mesh name
  16712. * - newParent (optional Node) : the optional Node to parent the clone to.
  16713. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16714. *
  16715. * Returns the clone.
  16716. */
  16717. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16718. /**
  16719. * Disposes the InstancedMesh.
  16720. * Returns nothing.
  16721. */
  16722. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16723. }
  16724. }
  16725. declare module "babylonjs/Materials/shaderMaterial" {
  16726. import { Scene } from "babylonjs/scene";
  16727. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16729. import { Mesh } from "babylonjs/Meshes/mesh";
  16730. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16731. import { Texture } from "babylonjs/Materials/Textures/texture";
  16732. import { Material } from "babylonjs/Materials/material";
  16733. /**
  16734. * Defines the options associated with the creation of a shader material.
  16735. */
  16736. export interface IShaderMaterialOptions {
  16737. /**
  16738. * Does the material work in alpha blend mode
  16739. */
  16740. needAlphaBlending: boolean;
  16741. /**
  16742. * Does the material work in alpha test mode
  16743. */
  16744. needAlphaTesting: boolean;
  16745. /**
  16746. * The list of attribute names used in the shader
  16747. */
  16748. attributes: string[];
  16749. /**
  16750. * The list of unifrom names used in the shader
  16751. */
  16752. uniforms: string[];
  16753. /**
  16754. * The list of UBO names used in the shader
  16755. */
  16756. uniformBuffers: string[];
  16757. /**
  16758. * The list of sampler names used in the shader
  16759. */
  16760. samplers: string[];
  16761. /**
  16762. * The list of defines used in the shader
  16763. */
  16764. defines: string[];
  16765. }
  16766. /**
  16767. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16768. *
  16769. * This returned material effects how the mesh will look based on the code in the shaders.
  16770. *
  16771. * @see http://doc.babylonjs.com/how_to/shader_material
  16772. */
  16773. export class ShaderMaterial extends Material {
  16774. private _shaderPath;
  16775. private _options;
  16776. private _textures;
  16777. private _textureArrays;
  16778. private _floats;
  16779. private _ints;
  16780. private _floatsArrays;
  16781. private _colors3;
  16782. private _colors3Arrays;
  16783. private _colors4;
  16784. private _vectors2;
  16785. private _vectors3;
  16786. private _vectors4;
  16787. private _matrices;
  16788. private _matrices3x3;
  16789. private _matrices2x2;
  16790. private _vectors2Arrays;
  16791. private _vectors3Arrays;
  16792. private _cachedWorldViewMatrix;
  16793. private _renderId;
  16794. /**
  16795. * Instantiate a new shader material.
  16796. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16797. * This returned material effects how the mesh will look based on the code in the shaders.
  16798. * @see http://doc.babylonjs.com/how_to/shader_material
  16799. * @param name Define the name of the material in the scene
  16800. * @param scene Define the scene the material belongs to
  16801. * @param shaderPath Defines the route to the shader code in one of three ways:
  16802. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16803. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16804. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16805. * @param options Define the options used to create the shader
  16806. */
  16807. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16808. /**
  16809. * Gets the current class name of the material e.g. "ShaderMaterial"
  16810. * Mainly use in serialization.
  16811. * @returns the class name
  16812. */
  16813. getClassName(): string;
  16814. /**
  16815. * Specifies if the material will require alpha blending
  16816. * @returns a boolean specifying if alpha blending is needed
  16817. */
  16818. needAlphaBlending(): boolean;
  16819. /**
  16820. * Specifies if this material should be rendered in alpha test mode
  16821. * @returns a boolean specifying if an alpha test is needed.
  16822. */
  16823. needAlphaTesting(): boolean;
  16824. private _checkUniform;
  16825. /**
  16826. * Set a texture in the shader.
  16827. * @param name Define the name of the uniform samplers as defined in the shader
  16828. * @param texture Define the texture to bind to this sampler
  16829. * @return the material itself allowing "fluent" like uniform updates
  16830. */
  16831. setTexture(name: string, texture: Texture): ShaderMaterial;
  16832. /**
  16833. * Set a texture array in the shader.
  16834. * @param name Define the name of the uniform sampler array as defined in the shader
  16835. * @param textures Define the list of textures to bind to this sampler
  16836. * @return the material itself allowing "fluent" like uniform updates
  16837. */
  16838. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16839. /**
  16840. * Set a float in the shader.
  16841. * @param name Define the name of the uniform as defined in the shader
  16842. * @param value Define the value to give to the uniform
  16843. * @return the material itself allowing "fluent" like uniform updates
  16844. */
  16845. setFloat(name: string, value: number): ShaderMaterial;
  16846. /**
  16847. * Set a int in the shader.
  16848. * @param name Define the name of the uniform as defined in the shader
  16849. * @param value Define the value to give to the uniform
  16850. * @return the material itself allowing "fluent" like uniform updates
  16851. */
  16852. setInt(name: string, value: number): ShaderMaterial;
  16853. /**
  16854. * Set an array of floats in the shader.
  16855. * @param name Define the name of the uniform as defined in the shader
  16856. * @param value Define the value to give to the uniform
  16857. * @return the material itself allowing "fluent" like uniform updates
  16858. */
  16859. setFloats(name: string, value: number[]): ShaderMaterial;
  16860. /**
  16861. * Set a vec3 in the shader from a Color3.
  16862. * @param name Define the name of the uniform as defined in the shader
  16863. * @param value Define the value to give to the uniform
  16864. * @return the material itself allowing "fluent" like uniform updates
  16865. */
  16866. setColor3(name: string, value: Color3): ShaderMaterial;
  16867. /**
  16868. * Set a vec3 array in the shader from a Color3 array.
  16869. * @param name Define the name of the uniform as defined in the shader
  16870. * @param value Define the value to give to the uniform
  16871. * @return the material itself allowing "fluent" like uniform updates
  16872. */
  16873. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16874. /**
  16875. * Set a vec4 in the shader from a Color4.
  16876. * @param name Define the name of the uniform as defined in the shader
  16877. * @param value Define the value to give to the uniform
  16878. * @return the material itself allowing "fluent" like uniform updates
  16879. */
  16880. setColor4(name: string, value: Color4): ShaderMaterial;
  16881. /**
  16882. * Set a vec2 in the shader from a Vector2.
  16883. * @param name Define the name of the uniform as defined in the shader
  16884. * @param value Define the value to give to the uniform
  16885. * @return the material itself allowing "fluent" like uniform updates
  16886. */
  16887. setVector2(name: string, value: Vector2): ShaderMaterial;
  16888. /**
  16889. * Set a vec3 in the shader from a Vector3.
  16890. * @param name Define the name of the uniform as defined in the shader
  16891. * @param value Define the value to give to the uniform
  16892. * @return the material itself allowing "fluent" like uniform updates
  16893. */
  16894. setVector3(name: string, value: Vector3): ShaderMaterial;
  16895. /**
  16896. * Set a vec4 in the shader from a Vector4.
  16897. * @param name Define the name of the uniform as defined in the shader
  16898. * @param value Define the value to give to the uniform
  16899. * @return the material itself allowing "fluent" like uniform updates
  16900. */
  16901. setVector4(name: string, value: Vector4): ShaderMaterial;
  16902. /**
  16903. * Set a mat4 in the shader from a Matrix.
  16904. * @param name Define the name of the uniform as defined in the shader
  16905. * @param value Define the value to give to the uniform
  16906. * @return the material itself allowing "fluent" like uniform updates
  16907. */
  16908. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16909. /**
  16910. * Set a mat3 in the shader from a Float32Array.
  16911. * @param name Define the name of the uniform as defined in the shader
  16912. * @param value Define the value to give to the uniform
  16913. * @return the material itself allowing "fluent" like uniform updates
  16914. */
  16915. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16916. /**
  16917. * Set a mat2 in the shader from a Float32Array.
  16918. * @param name Define the name of the uniform as defined in the shader
  16919. * @param value Define the value to give to the uniform
  16920. * @return the material itself allowing "fluent" like uniform updates
  16921. */
  16922. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16923. /**
  16924. * Set a vec2 array in the shader from a number array.
  16925. * @param name Define the name of the uniform as defined in the shader
  16926. * @param value Define the value to give to the uniform
  16927. * @return the material itself allowing "fluent" like uniform updates
  16928. */
  16929. setArray2(name: string, value: number[]): ShaderMaterial;
  16930. /**
  16931. * Set a vec3 array in the shader from a number array.
  16932. * @param name Define the name of the uniform as defined in the shader
  16933. * @param value Define the value to give to the uniform
  16934. * @return the material itself allowing "fluent" like uniform updates
  16935. */
  16936. setArray3(name: string, value: number[]): ShaderMaterial;
  16937. private _checkCache;
  16938. /**
  16939. * Checks if the material is ready to render the requested mesh
  16940. * @param mesh Define the mesh to render
  16941. * @param useInstances Define whether or not the material is used with instances
  16942. * @returns true if ready, otherwise false
  16943. */
  16944. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16945. /**
  16946. * Binds the world matrix to the material
  16947. * @param world defines the world transformation matrix
  16948. */
  16949. bindOnlyWorldMatrix(world: Matrix): void;
  16950. /**
  16951. * Binds the material to the mesh
  16952. * @param world defines the world transformation matrix
  16953. * @param mesh defines the mesh to bind the material to
  16954. */
  16955. bind(world: Matrix, mesh?: Mesh): void;
  16956. /**
  16957. * Gets the active textures from the material
  16958. * @returns an array of textures
  16959. */
  16960. getActiveTextures(): BaseTexture[];
  16961. /**
  16962. * Specifies if the material uses a texture
  16963. * @param texture defines the texture to check against the material
  16964. * @returns a boolean specifying if the material uses the texture
  16965. */
  16966. hasTexture(texture: BaseTexture): boolean;
  16967. /**
  16968. * Makes a duplicate of the material, and gives it a new name
  16969. * @param name defines the new name for the duplicated material
  16970. * @returns the cloned material
  16971. */
  16972. clone(name: string): ShaderMaterial;
  16973. /**
  16974. * Disposes the material
  16975. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16976. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16977. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16978. */
  16979. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16980. /**
  16981. * Serializes this material in a JSON representation
  16982. * @returns the serialized material object
  16983. */
  16984. serialize(): any;
  16985. /**
  16986. * Creates a shader material from parsed shader material data
  16987. * @param source defines the JSON represnetation of the material
  16988. * @param scene defines the hosting scene
  16989. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16990. * @returns a new material
  16991. */
  16992. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16993. }
  16994. }
  16995. declare module "babylonjs/Shaders/color.fragment" {
  16996. /** @hidden */
  16997. export var colorPixelShader: {
  16998. name: string;
  16999. shader: string;
  17000. };
  17001. }
  17002. declare module "babylonjs/Shaders/color.vertex" {
  17003. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17004. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17005. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17006. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17007. /** @hidden */
  17008. export var colorVertexShader: {
  17009. name: string;
  17010. shader: string;
  17011. };
  17012. }
  17013. declare module "babylonjs/Meshes/linesMesh" {
  17014. import { Nullable } from "babylonjs/types";
  17015. import { Scene } from "babylonjs/scene";
  17016. import { Color3 } from "babylonjs/Maths/math";
  17017. import { Node } from "babylonjs/node";
  17018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17019. import { Mesh } from "babylonjs/Meshes/mesh";
  17020. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17021. import { Effect } from "babylonjs/Materials/effect";
  17022. import { Material } from "babylonjs/Materials/material";
  17023. import "babylonjs/Shaders/color.fragment";
  17024. import "babylonjs/Shaders/color.vertex";
  17025. /**
  17026. * Line mesh
  17027. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17028. */
  17029. export class LinesMesh extends Mesh {
  17030. /**
  17031. * If vertex color should be applied to the mesh
  17032. */
  17033. useVertexColor?: boolean | undefined;
  17034. /**
  17035. * If vertex alpha should be applied to the mesh
  17036. */
  17037. useVertexAlpha?: boolean | undefined;
  17038. /**
  17039. * Color of the line (Default: White)
  17040. */
  17041. color: Color3;
  17042. /**
  17043. * Alpha of the line (Default: 1)
  17044. */
  17045. alpha: number;
  17046. /**
  17047. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17048. * This margin is expressed in world space coordinates, so its value may vary.
  17049. * Default value is 0.1
  17050. */
  17051. intersectionThreshold: number;
  17052. private _colorShader;
  17053. /**
  17054. * Creates a new LinesMesh
  17055. * @param name defines the name
  17056. * @param scene defines the hosting scene
  17057. * @param parent defines the parent mesh if any
  17058. * @param source defines the optional source LinesMesh used to clone data from
  17059. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17060. * When false, achieved by calling a clone(), also passing False.
  17061. * This will make creation of children, recursive.
  17062. * @param useVertexColor defines if this LinesMesh supports vertex color
  17063. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17064. */
  17065. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17066. /**
  17067. * If vertex color should be applied to the mesh
  17068. */
  17069. useVertexColor?: boolean | undefined,
  17070. /**
  17071. * If vertex alpha should be applied to the mesh
  17072. */
  17073. useVertexAlpha?: boolean | undefined);
  17074. /**
  17075. * Returns the string "LineMesh"
  17076. */
  17077. getClassName(): string;
  17078. /**
  17079. * @hidden
  17080. */
  17081. /**
  17082. * @hidden
  17083. */
  17084. material: Material;
  17085. /**
  17086. * @hidden
  17087. */
  17088. readonly checkCollisions: boolean;
  17089. /** @hidden */
  17090. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17091. /** @hidden */
  17092. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17093. /**
  17094. * Disposes of the line mesh
  17095. * @param doNotRecurse If children should be disposed
  17096. */
  17097. dispose(doNotRecurse?: boolean): void;
  17098. /**
  17099. * Returns a new LineMesh object cloned from the current one.
  17100. */
  17101. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17102. /**
  17103. * Creates a new InstancedLinesMesh object from the mesh model.
  17104. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17105. * @param name defines the name of the new instance
  17106. * @returns a new InstancedLinesMesh
  17107. */
  17108. createInstance(name: string): InstancedLinesMesh;
  17109. }
  17110. /**
  17111. * Creates an instance based on a source LinesMesh
  17112. */
  17113. export class InstancedLinesMesh extends InstancedMesh {
  17114. /**
  17115. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17116. * This margin is expressed in world space coordinates, so its value may vary.
  17117. * Initilized with the intersectionThreshold value of the source LinesMesh
  17118. */
  17119. intersectionThreshold: number;
  17120. constructor(name: string, source: LinesMesh);
  17121. /**
  17122. * Returns the string "InstancedLinesMesh".
  17123. */
  17124. getClassName(): string;
  17125. }
  17126. }
  17127. declare module "babylonjs/Shaders/line.fragment" {
  17128. /** @hidden */
  17129. export var linePixelShader: {
  17130. name: string;
  17131. shader: string;
  17132. };
  17133. }
  17134. declare module "babylonjs/Shaders/line.vertex" {
  17135. /** @hidden */
  17136. export var lineVertexShader: {
  17137. name: string;
  17138. shader: string;
  17139. };
  17140. }
  17141. declare module "babylonjs/Rendering/edgesRenderer" {
  17142. import { Nullable } from "babylonjs/types";
  17143. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17145. import { Vector3 } from "babylonjs/Maths/math";
  17146. import { IDisposable } from "babylonjs/scene";
  17147. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17148. import "babylonjs/Shaders/line.fragment";
  17149. import "babylonjs/Shaders/line.vertex";
  17150. module "babylonjs/Meshes/abstractMesh" {
  17151. interface AbstractMesh {
  17152. /**
  17153. * Disables the mesh edge rendering mode
  17154. * @returns the currentAbstractMesh
  17155. */
  17156. disableEdgesRendering(): AbstractMesh;
  17157. /**
  17158. * Enables the edge rendering mode on the mesh.
  17159. * This mode makes the mesh edges visible
  17160. * @param epsilon defines the maximal distance between two angles to detect a face
  17161. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17162. * @returns the currentAbstractMesh
  17163. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17164. */
  17165. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17166. /**
  17167. * Gets the edgesRenderer associated with the mesh
  17168. */
  17169. edgesRenderer: Nullable<EdgesRenderer>;
  17170. }
  17171. }
  17172. module "babylonjs/Meshes/linesMesh" {
  17173. interface LinesMesh {
  17174. /**
  17175. * Enables the edge rendering mode on the mesh.
  17176. * This mode makes the mesh edges visible
  17177. * @param epsilon defines the maximal distance between two angles to detect a face
  17178. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17179. * @returns the currentAbstractMesh
  17180. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17181. */
  17182. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17183. }
  17184. }
  17185. module "babylonjs/Meshes/linesMesh" {
  17186. interface InstancedLinesMesh {
  17187. /**
  17188. * Enables the edge rendering mode on the mesh.
  17189. * This mode makes the mesh edges visible
  17190. * @param epsilon defines the maximal distance between two angles to detect a face
  17191. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17192. * @returns the current InstancedLinesMesh
  17193. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17194. */
  17195. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17196. }
  17197. }
  17198. /**
  17199. * Defines the minimum contract an Edges renderer should follow.
  17200. */
  17201. export interface IEdgesRenderer extends IDisposable {
  17202. /**
  17203. * Gets or sets a boolean indicating if the edgesRenderer is active
  17204. */
  17205. isEnabled: boolean;
  17206. /**
  17207. * Renders the edges of the attached mesh,
  17208. */
  17209. render(): void;
  17210. /**
  17211. * Checks wether or not the edges renderer is ready to render.
  17212. * @return true if ready, otherwise false.
  17213. */
  17214. isReady(): boolean;
  17215. }
  17216. /**
  17217. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17218. */
  17219. export class EdgesRenderer implements IEdgesRenderer {
  17220. /**
  17221. * Define the size of the edges with an orthographic camera
  17222. */
  17223. edgesWidthScalerForOrthographic: number;
  17224. /**
  17225. * Define the size of the edges with a perspective camera
  17226. */
  17227. edgesWidthScalerForPerspective: number;
  17228. protected _source: AbstractMesh;
  17229. protected _linesPositions: number[];
  17230. protected _linesNormals: number[];
  17231. protected _linesIndices: number[];
  17232. protected _epsilon: number;
  17233. protected _indicesCount: number;
  17234. protected _lineShader: ShaderMaterial;
  17235. protected _ib: WebGLBuffer;
  17236. protected _buffers: {
  17237. [key: string]: Nullable<VertexBuffer>;
  17238. };
  17239. protected _checkVerticesInsteadOfIndices: boolean;
  17240. private _meshRebuildObserver;
  17241. private _meshDisposeObserver;
  17242. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17243. isEnabled: boolean;
  17244. /**
  17245. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17246. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17247. * @param source Mesh used to create edges
  17248. * @param epsilon sum of angles in adjacency to check for edge
  17249. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17250. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17251. */
  17252. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17253. protected _prepareRessources(): void;
  17254. /** @hidden */
  17255. _rebuild(): void;
  17256. /**
  17257. * Releases the required resources for the edges renderer
  17258. */
  17259. dispose(): void;
  17260. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17261. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17262. /**
  17263. * Checks if the pair of p0 and p1 is en edge
  17264. * @param faceIndex
  17265. * @param edge
  17266. * @param faceNormals
  17267. * @param p0
  17268. * @param p1
  17269. * @private
  17270. */
  17271. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17272. /**
  17273. * push line into the position, normal and index buffer
  17274. * @protected
  17275. */
  17276. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17277. /**
  17278. * Generates lines edges from adjacencjes
  17279. * @private
  17280. */
  17281. _generateEdgesLines(): void;
  17282. /**
  17283. * Checks wether or not the edges renderer is ready to render.
  17284. * @return true if ready, otherwise false.
  17285. */
  17286. isReady(): boolean;
  17287. /**
  17288. * Renders the edges of the attached mesh,
  17289. */
  17290. render(): void;
  17291. }
  17292. /**
  17293. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17294. */
  17295. export class LineEdgesRenderer extends EdgesRenderer {
  17296. /**
  17297. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17298. * @param source LineMesh used to generate edges
  17299. * @param epsilon not important (specified angle for edge detection)
  17300. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17301. */
  17302. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17303. /**
  17304. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17305. */
  17306. _generateEdgesLines(): void;
  17307. }
  17308. }
  17309. declare module "babylonjs/Rendering/renderingGroup" {
  17310. import { SmartArray } from "babylonjs/Misc/smartArray";
  17311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17313. import { Nullable } from "babylonjs/types";
  17314. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17315. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17316. import { Material } from "babylonjs/Materials/material";
  17317. import { Scene } from "babylonjs/scene";
  17318. /**
  17319. * This represents the object necessary to create a rendering group.
  17320. * This is exclusively used and created by the rendering manager.
  17321. * To modify the behavior, you use the available helpers in your scene or meshes.
  17322. * @hidden
  17323. */
  17324. export class RenderingGroup {
  17325. index: number;
  17326. private _scene;
  17327. private _opaqueSubMeshes;
  17328. private _transparentSubMeshes;
  17329. private _alphaTestSubMeshes;
  17330. private _depthOnlySubMeshes;
  17331. private _particleSystems;
  17332. private _spriteManagers;
  17333. private _opaqueSortCompareFn;
  17334. private _alphaTestSortCompareFn;
  17335. private _transparentSortCompareFn;
  17336. private _renderOpaque;
  17337. private _renderAlphaTest;
  17338. private _renderTransparent;
  17339. private _edgesRenderers;
  17340. onBeforeTransparentRendering: () => void;
  17341. /**
  17342. * Set the opaque sort comparison function.
  17343. * If null the sub meshes will be render in the order they were created
  17344. */
  17345. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17346. /**
  17347. * Set the alpha test sort comparison function.
  17348. * If null the sub meshes will be render in the order they were created
  17349. */
  17350. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17351. /**
  17352. * Set the transparent sort comparison function.
  17353. * If null the sub meshes will be render in the order they were created
  17354. */
  17355. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17356. /**
  17357. * Creates a new rendering group.
  17358. * @param index The rendering group index
  17359. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17360. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17361. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17362. */
  17363. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17364. /**
  17365. * Render all the sub meshes contained in the group.
  17366. * @param customRenderFunction Used to override the default render behaviour of the group.
  17367. * @returns true if rendered some submeshes.
  17368. */
  17369. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17370. /**
  17371. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17372. * @param subMeshes The submeshes to render
  17373. */
  17374. private renderOpaqueSorted;
  17375. /**
  17376. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17377. * @param subMeshes The submeshes to render
  17378. */
  17379. private renderAlphaTestSorted;
  17380. /**
  17381. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17382. * @param subMeshes The submeshes to render
  17383. */
  17384. private renderTransparentSorted;
  17385. /**
  17386. * Renders the submeshes in a specified order.
  17387. * @param subMeshes The submeshes to sort before render
  17388. * @param sortCompareFn The comparison function use to sort
  17389. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17390. * @param transparent Specifies to activate blending if true
  17391. */
  17392. private static renderSorted;
  17393. /**
  17394. * Renders the submeshes in the order they were dispatched (no sort applied).
  17395. * @param subMeshes The submeshes to render
  17396. */
  17397. private static renderUnsorted;
  17398. /**
  17399. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17400. * are rendered back to front if in the same alpha index.
  17401. *
  17402. * @param a The first submesh
  17403. * @param b The second submesh
  17404. * @returns The result of the comparison
  17405. */
  17406. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17407. /**
  17408. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17409. * are rendered back to front.
  17410. *
  17411. * @param a The first submesh
  17412. * @param b The second submesh
  17413. * @returns The result of the comparison
  17414. */
  17415. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17416. /**
  17417. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17418. * are rendered front to back (prevent overdraw).
  17419. *
  17420. * @param a The first submesh
  17421. * @param b The second submesh
  17422. * @returns The result of the comparison
  17423. */
  17424. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17425. /**
  17426. * Resets the different lists of submeshes to prepare a new frame.
  17427. */
  17428. prepare(): void;
  17429. dispose(): void;
  17430. /**
  17431. * Inserts the submesh in its correct queue depending on its material.
  17432. * @param subMesh The submesh to dispatch
  17433. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17434. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17435. */
  17436. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17437. dispatchSprites(spriteManager: ISpriteManager): void;
  17438. dispatchParticles(particleSystem: IParticleSystem): void;
  17439. private _renderParticles;
  17440. private _renderSprites;
  17441. }
  17442. }
  17443. declare module "babylonjs/Rendering/renderingManager" {
  17444. import { Nullable } from "babylonjs/types";
  17445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17446. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17447. import { SmartArray } from "babylonjs/Misc/smartArray";
  17448. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17449. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17450. import { Material } from "babylonjs/Materials/material";
  17451. import { Scene } from "babylonjs/scene";
  17452. import { Camera } from "babylonjs/Cameras/camera";
  17453. /**
  17454. * Interface describing the different options available in the rendering manager
  17455. * regarding Auto Clear between groups.
  17456. */
  17457. export interface IRenderingManagerAutoClearSetup {
  17458. /**
  17459. * Defines whether or not autoclear is enable.
  17460. */
  17461. autoClear: boolean;
  17462. /**
  17463. * Defines whether or not to autoclear the depth buffer.
  17464. */
  17465. depth: boolean;
  17466. /**
  17467. * Defines whether or not to autoclear the stencil buffer.
  17468. */
  17469. stencil: boolean;
  17470. }
  17471. /**
  17472. * This class is used by the onRenderingGroupObservable
  17473. */
  17474. export class RenderingGroupInfo {
  17475. /**
  17476. * The Scene that being rendered
  17477. */
  17478. scene: Scene;
  17479. /**
  17480. * The camera currently used for the rendering pass
  17481. */
  17482. camera: Nullable<Camera>;
  17483. /**
  17484. * The ID of the renderingGroup being processed
  17485. */
  17486. renderingGroupId: number;
  17487. }
  17488. /**
  17489. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17490. * It is enable to manage the different groups as well as the different necessary sort functions.
  17491. * This should not be used directly aside of the few static configurations
  17492. */
  17493. export class RenderingManager {
  17494. /**
  17495. * The max id used for rendering groups (not included)
  17496. */
  17497. static MAX_RENDERINGGROUPS: number;
  17498. /**
  17499. * The min id used for rendering groups (included)
  17500. */
  17501. static MIN_RENDERINGGROUPS: number;
  17502. /**
  17503. * Used to globally prevent autoclearing scenes.
  17504. */
  17505. static AUTOCLEAR: boolean;
  17506. /**
  17507. * @hidden
  17508. */
  17509. _useSceneAutoClearSetup: boolean;
  17510. private _scene;
  17511. private _renderingGroups;
  17512. private _depthStencilBufferAlreadyCleaned;
  17513. private _autoClearDepthStencil;
  17514. private _customOpaqueSortCompareFn;
  17515. private _customAlphaTestSortCompareFn;
  17516. private _customTransparentSortCompareFn;
  17517. private _renderingGroupInfo;
  17518. /**
  17519. * Instantiates a new rendering group for a particular scene
  17520. * @param scene Defines the scene the groups belongs to
  17521. */
  17522. constructor(scene: Scene);
  17523. private _clearDepthStencilBuffer;
  17524. /**
  17525. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17526. * @hidden
  17527. */
  17528. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17529. /**
  17530. * Resets the different information of the group to prepare a new frame
  17531. * @hidden
  17532. */
  17533. reset(): void;
  17534. /**
  17535. * Dispose and release the group and its associated resources.
  17536. * @hidden
  17537. */
  17538. dispose(): void;
  17539. /**
  17540. * Clear the info related to rendering groups preventing retention points during dispose.
  17541. */
  17542. freeRenderingGroups(): void;
  17543. private _prepareRenderingGroup;
  17544. /**
  17545. * Add a sprite manager to the rendering manager in order to render it this frame.
  17546. * @param spriteManager Define the sprite manager to render
  17547. */
  17548. dispatchSprites(spriteManager: ISpriteManager): void;
  17549. /**
  17550. * Add a particle system to the rendering manager in order to render it this frame.
  17551. * @param particleSystem Define the particle system to render
  17552. */
  17553. dispatchParticles(particleSystem: IParticleSystem): void;
  17554. /**
  17555. * Add a submesh to the manager in order to render it this frame
  17556. * @param subMesh The submesh to dispatch
  17557. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17558. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17559. */
  17560. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17561. /**
  17562. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17563. * This allowed control for front to back rendering or reversly depending of the special needs.
  17564. *
  17565. * @param renderingGroupId The rendering group id corresponding to its index
  17566. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17567. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17568. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17569. */
  17570. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17571. /**
  17572. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17573. *
  17574. * @param renderingGroupId The rendering group id corresponding to its index
  17575. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17576. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17577. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17578. */
  17579. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17580. /**
  17581. * Gets the current auto clear configuration for one rendering group of the rendering
  17582. * manager.
  17583. * @param index the rendering group index to get the information for
  17584. * @returns The auto clear setup for the requested rendering group
  17585. */
  17586. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17587. }
  17588. }
  17589. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17590. import { Observable } from "babylonjs/Misc/observable";
  17591. import { SmartArray } from "babylonjs/Misc/smartArray";
  17592. import { Nullable } from "babylonjs/types";
  17593. import { Camera } from "babylonjs/Cameras/camera";
  17594. import { Scene } from "babylonjs/scene";
  17595. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17596. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17598. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17599. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17600. import { Texture } from "babylonjs/Materials/Textures/texture";
  17601. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17602. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17603. import { Engine } from "babylonjs/Engines/engine";
  17604. /**
  17605. * This Helps creating a texture that will be created from a camera in your scene.
  17606. * It is basically a dynamic texture that could be used to create special effects for instance.
  17607. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17608. */
  17609. export class RenderTargetTexture extends Texture {
  17610. isCube: boolean;
  17611. /**
  17612. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17613. */
  17614. static readonly REFRESHRATE_RENDER_ONCE: number;
  17615. /**
  17616. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17617. */
  17618. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17619. /**
  17620. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17621. * the central point of your effect and can save a lot of performances.
  17622. */
  17623. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17624. /**
  17625. * Use this predicate to dynamically define the list of mesh you want to render.
  17626. * If set, the renderList property will be overwritten.
  17627. */
  17628. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17629. private _renderList;
  17630. /**
  17631. * Use this list to define the list of mesh you want to render.
  17632. */
  17633. renderList: Nullable<Array<AbstractMesh>>;
  17634. private _hookArray;
  17635. /**
  17636. * Define if particles should be rendered in your texture.
  17637. */
  17638. renderParticles: boolean;
  17639. /**
  17640. * Define if sprites should be rendered in your texture.
  17641. */
  17642. renderSprites: boolean;
  17643. /**
  17644. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17645. */
  17646. coordinatesMode: number;
  17647. /**
  17648. * Define the camera used to render the texture.
  17649. */
  17650. activeCamera: Nullable<Camera>;
  17651. /**
  17652. * Override the render function of the texture with your own one.
  17653. */
  17654. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17655. /**
  17656. * Define if camera post processes should be use while rendering the texture.
  17657. */
  17658. useCameraPostProcesses: boolean;
  17659. /**
  17660. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17661. */
  17662. ignoreCameraViewport: boolean;
  17663. private _postProcessManager;
  17664. private _postProcesses;
  17665. private _resizeObserver;
  17666. /**
  17667. * An event triggered when the texture is unbind.
  17668. */
  17669. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17670. /**
  17671. * An event triggered when the texture is unbind.
  17672. */
  17673. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17674. private _onAfterUnbindObserver;
  17675. /**
  17676. * Set a after unbind callback in the texture.
  17677. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17678. */
  17679. onAfterUnbind: () => void;
  17680. /**
  17681. * An event triggered before rendering the texture
  17682. */
  17683. onBeforeRenderObservable: Observable<number>;
  17684. private _onBeforeRenderObserver;
  17685. /**
  17686. * Set a before render callback in the texture.
  17687. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17688. */
  17689. onBeforeRender: (faceIndex: number) => void;
  17690. /**
  17691. * An event triggered after rendering the texture
  17692. */
  17693. onAfterRenderObservable: Observable<number>;
  17694. private _onAfterRenderObserver;
  17695. /**
  17696. * Set a after render callback in the texture.
  17697. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17698. */
  17699. onAfterRender: (faceIndex: number) => void;
  17700. /**
  17701. * An event triggered after the texture clear
  17702. */
  17703. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17704. private _onClearObserver;
  17705. /**
  17706. * Set a clear callback in the texture.
  17707. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17708. */
  17709. onClear: (Engine: Engine) => void;
  17710. /**
  17711. * Define the clear color of the Render Target if it should be different from the scene.
  17712. */
  17713. clearColor: Color4;
  17714. protected _size: number | {
  17715. width: number;
  17716. height: number;
  17717. };
  17718. protected _initialSizeParameter: number | {
  17719. width: number;
  17720. height: number;
  17721. } | {
  17722. ratio: number;
  17723. };
  17724. protected _sizeRatio: Nullable<number>;
  17725. /** @hidden */
  17726. _generateMipMaps: boolean;
  17727. protected _renderingManager: RenderingManager;
  17728. /** @hidden */
  17729. _waitingRenderList: string[];
  17730. protected _doNotChangeAspectRatio: boolean;
  17731. protected _currentRefreshId: number;
  17732. protected _refreshRate: number;
  17733. protected _textureMatrix: Matrix;
  17734. protected _samples: number;
  17735. protected _renderTargetOptions: RenderTargetCreationOptions;
  17736. /**
  17737. * Gets render target creation options that were used.
  17738. */
  17739. readonly renderTargetOptions: RenderTargetCreationOptions;
  17740. protected _engine: Engine;
  17741. protected _onRatioRescale(): void;
  17742. /**
  17743. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17744. * It must define where the camera used to render the texture is set
  17745. */
  17746. boundingBoxPosition: Vector3;
  17747. private _boundingBoxSize;
  17748. /**
  17749. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17750. * When defined, the cubemap will switch to local mode
  17751. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17752. * @example https://www.babylonjs-playground.com/#RNASML
  17753. */
  17754. boundingBoxSize: Vector3;
  17755. /**
  17756. * In case the RTT has been created with a depth texture, get the associated
  17757. * depth texture.
  17758. * Otherwise, return null.
  17759. */
  17760. depthStencilTexture: Nullable<InternalTexture>;
  17761. /**
  17762. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17763. * or used a shadow, depth texture...
  17764. * @param name The friendly name of the texture
  17765. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  17766. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17767. * @param generateMipMaps True if mip maps need to be generated after render.
  17768. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17769. * @param type The type of the buffer in the RTT (int, half float, float...)
  17770. * @param isCube True if a cube texture needs to be created
  17771. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17772. * @param generateDepthBuffer True to generate a depth buffer
  17773. * @param generateStencilBuffer True to generate a stencil buffer
  17774. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17775. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17776. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17777. */
  17778. constructor(name: string, size: number | {
  17779. width: number;
  17780. height: number;
  17781. } | {
  17782. ratio: number;
  17783. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17784. /**
  17785. * Creates a depth stencil texture.
  17786. * This is only available in WebGL 2 or with the depth texture extension available.
  17787. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17788. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17789. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17790. */
  17791. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17792. private _processSizeParameter;
  17793. /**
  17794. * Define the number of samples to use in case of MSAA.
  17795. * It defaults to one meaning no MSAA has been enabled.
  17796. */
  17797. samples: number;
  17798. /**
  17799. * Resets the refresh counter of the texture and start bak from scratch.
  17800. * Could be useful to regenerate the texture if it is setup to render only once.
  17801. */
  17802. resetRefreshCounter(): void;
  17803. /**
  17804. * Define the refresh rate of the texture or the rendering frequency.
  17805. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17806. */
  17807. refreshRate: number;
  17808. /**
  17809. * Adds a post process to the render target rendering passes.
  17810. * @param postProcess define the post process to add
  17811. */
  17812. addPostProcess(postProcess: PostProcess): void;
  17813. /**
  17814. * Clear all the post processes attached to the render target
  17815. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17816. */
  17817. clearPostProcesses(dispose?: boolean): void;
  17818. /**
  17819. * Remove one of the post process from the list of attached post processes to the texture
  17820. * @param postProcess define the post process to remove from the list
  17821. */
  17822. removePostProcess(postProcess: PostProcess): void;
  17823. /** @hidden */
  17824. _shouldRender(): boolean;
  17825. /**
  17826. * Gets the actual render size of the texture.
  17827. * @returns the width of the render size
  17828. */
  17829. getRenderSize(): number;
  17830. /**
  17831. * Gets the actual render width of the texture.
  17832. * @returns the width of the render size
  17833. */
  17834. getRenderWidth(): number;
  17835. /**
  17836. * Gets the actual render height of the texture.
  17837. * @returns the height of the render size
  17838. */
  17839. getRenderHeight(): number;
  17840. /**
  17841. * Get if the texture can be rescaled or not.
  17842. */
  17843. readonly canRescale: boolean;
  17844. /**
  17845. * Resize the texture using a ratio.
  17846. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17847. */
  17848. scale(ratio: number): void;
  17849. /**
  17850. * Get the texture reflection matrix used to rotate/transform the reflection.
  17851. * @returns the reflection matrix
  17852. */
  17853. getReflectionTextureMatrix(): Matrix;
  17854. /**
  17855. * Resize the texture to a new desired size.
  17856. * Be carrefull as it will recreate all the data in the new texture.
  17857. * @param size Define the new size. It can be:
  17858. * - a number for squared texture,
  17859. * - an object containing { width: number, height: number }
  17860. * - or an object containing a ratio { ratio: number }
  17861. */
  17862. resize(size: number | {
  17863. width: number;
  17864. height: number;
  17865. } | {
  17866. ratio: number;
  17867. }): void;
  17868. /**
  17869. * Renders all the objects from the render list into the texture.
  17870. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17871. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17872. */
  17873. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17874. private _bestReflectionRenderTargetDimension;
  17875. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17876. private renderToTarget;
  17877. /**
  17878. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17879. * This allowed control for front to back rendering or reversly depending of the special needs.
  17880. *
  17881. * @param renderingGroupId The rendering group id corresponding to its index
  17882. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17883. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17884. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17885. */
  17886. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17887. /**
  17888. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17889. *
  17890. * @param renderingGroupId The rendering group id corresponding to its index
  17891. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17892. */
  17893. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17894. /**
  17895. * Clones the texture.
  17896. * @returns the cloned texture
  17897. */
  17898. clone(): RenderTargetTexture;
  17899. /**
  17900. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17901. * @returns The JSON representation of the texture
  17902. */
  17903. serialize(): any;
  17904. /**
  17905. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17906. */
  17907. disposeFramebufferObjects(): void;
  17908. /**
  17909. * Dispose the texture and release its associated resources.
  17910. */
  17911. dispose(): void;
  17912. /** @hidden */
  17913. _rebuild(): void;
  17914. /**
  17915. * Clear the info related to rendering groups preventing retention point in material dispose.
  17916. */
  17917. freeRenderingGroups(): void;
  17918. }
  17919. }
  17920. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  17921. import { Scene } from "babylonjs/scene";
  17922. import { Plane } from "babylonjs/Maths/math";
  17923. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17924. /**
  17925. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17926. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17927. * You can then easily use it as a reflectionTexture on a flat surface.
  17928. * In case the surface is not a plane, please consider relying on reflection probes.
  17929. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17930. */
  17931. export class MirrorTexture extends RenderTargetTexture {
  17932. private scene;
  17933. /**
  17934. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17935. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  17936. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17937. */
  17938. mirrorPlane: Plane;
  17939. /**
  17940. * Define the blur ratio used to blur the reflection if needed.
  17941. */
  17942. blurRatio: number;
  17943. /**
  17944. * Define the adaptive blur kernel used to blur the reflection if needed.
  17945. * This will autocompute the closest best match for the `blurKernel`
  17946. */
  17947. adaptiveBlurKernel: number;
  17948. /**
  17949. * Define the blur kernel used to blur the reflection if needed.
  17950. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17951. */
  17952. blurKernel: number;
  17953. /**
  17954. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17955. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17956. */
  17957. blurKernelX: number;
  17958. /**
  17959. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17960. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17961. */
  17962. blurKernelY: number;
  17963. private _autoComputeBlurKernel;
  17964. protected _onRatioRescale(): void;
  17965. private _updateGammaSpace;
  17966. private _imageProcessingConfigChangeObserver;
  17967. private _transformMatrix;
  17968. private _mirrorMatrix;
  17969. private _savedViewMatrix;
  17970. private _blurX;
  17971. private _blurY;
  17972. private _adaptiveBlurKernel;
  17973. private _blurKernelX;
  17974. private _blurKernelY;
  17975. private _blurRatio;
  17976. /**
  17977. * Instantiates a Mirror Texture.
  17978. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17979. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17980. * You can then easily use it as a reflectionTexture on a flat surface.
  17981. * In case the surface is not a plane, please consider relying on reflection probes.
  17982. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17983. * @param name
  17984. * @param size
  17985. * @param scene
  17986. * @param generateMipMaps
  17987. * @param type
  17988. * @param samplingMode
  17989. * @param generateDepthBuffer
  17990. */
  17991. constructor(name: string, size: number | {
  17992. width: number;
  17993. height: number;
  17994. } | {
  17995. ratio: number;
  17996. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17997. private _preparePostProcesses;
  17998. /**
  17999. * Clone the mirror texture.
  18000. * @returns the cloned texture
  18001. */
  18002. clone(): MirrorTexture;
  18003. /**
  18004. * Serialize the texture to a JSON representation you could use in Parse later on
  18005. * @returns the serialized JSON representation
  18006. */
  18007. serialize(): any;
  18008. /**
  18009. * Dispose the texture and release its associated resources.
  18010. */
  18011. dispose(): void;
  18012. }
  18013. }
  18014. declare module "babylonjs/Materials/Textures/texture" {
  18015. import { Observable } from "babylonjs/Misc/observable";
  18016. import { Nullable } from "babylonjs/types";
  18017. import { Scene } from "babylonjs/scene";
  18018. import { Matrix } from "babylonjs/Maths/math";
  18019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18020. /**
  18021. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18022. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18023. */
  18024. export class Texture extends BaseTexture {
  18025. /** @hidden */
  18026. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18027. /** @hidden */
  18028. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18029. /** @hidden */
  18030. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18031. /** nearest is mag = nearest and min = nearest and mip = linear */
  18032. static readonly NEAREST_SAMPLINGMODE: number;
  18033. /** nearest is mag = nearest and min = nearest and mip = linear */
  18034. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18035. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18036. static readonly BILINEAR_SAMPLINGMODE: number;
  18037. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18038. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18039. /** Trilinear is mag = linear and min = linear and mip = linear */
  18040. static readonly TRILINEAR_SAMPLINGMODE: number;
  18041. /** Trilinear is mag = linear and min = linear and mip = linear */
  18042. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18043. /** mag = nearest and min = nearest and mip = nearest */
  18044. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18045. /** mag = nearest and min = linear and mip = nearest */
  18046. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18047. /** mag = nearest and min = linear and mip = linear */
  18048. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18049. /** mag = nearest and min = linear and mip = none */
  18050. static readonly NEAREST_LINEAR: number;
  18051. /** mag = nearest and min = nearest and mip = none */
  18052. static readonly NEAREST_NEAREST: number;
  18053. /** mag = linear and min = nearest and mip = nearest */
  18054. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18055. /** mag = linear and min = nearest and mip = linear */
  18056. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18057. /** mag = linear and min = linear and mip = none */
  18058. static readonly LINEAR_LINEAR: number;
  18059. /** mag = linear and min = nearest and mip = none */
  18060. static readonly LINEAR_NEAREST: number;
  18061. /** Explicit coordinates mode */
  18062. static readonly EXPLICIT_MODE: number;
  18063. /** Spherical coordinates mode */
  18064. static readonly SPHERICAL_MODE: number;
  18065. /** Planar coordinates mode */
  18066. static readonly PLANAR_MODE: number;
  18067. /** Cubic coordinates mode */
  18068. static readonly CUBIC_MODE: number;
  18069. /** Projection coordinates mode */
  18070. static readonly PROJECTION_MODE: number;
  18071. /** Inverse Cubic coordinates mode */
  18072. static readonly SKYBOX_MODE: number;
  18073. /** Inverse Cubic coordinates mode */
  18074. static readonly INVCUBIC_MODE: number;
  18075. /** Equirectangular coordinates mode */
  18076. static readonly EQUIRECTANGULAR_MODE: number;
  18077. /** Equirectangular Fixed coordinates mode */
  18078. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18079. /** Equirectangular Fixed Mirrored coordinates mode */
  18080. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18081. /** Texture is not repeating outside of 0..1 UVs */
  18082. static readonly CLAMP_ADDRESSMODE: number;
  18083. /** Texture is repeating outside of 0..1 UVs */
  18084. static readonly WRAP_ADDRESSMODE: number;
  18085. /** Texture is repeating and mirrored */
  18086. static readonly MIRROR_ADDRESSMODE: number;
  18087. /**
  18088. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  18089. */
  18090. static UseSerializedUrlIfAny: boolean;
  18091. /**
  18092. * Define the url of the texture.
  18093. */
  18094. url: Nullable<string>;
  18095. /**
  18096. * Define an offset on the texture to offset the u coordinates of the UVs
  18097. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18098. */
  18099. uOffset: number;
  18100. /**
  18101. * Define an offset on the texture to offset the v coordinates of the UVs
  18102. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18103. */
  18104. vOffset: number;
  18105. /**
  18106. * Define an offset on the texture to scale the u coordinates of the UVs
  18107. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18108. */
  18109. uScale: number;
  18110. /**
  18111. * Define an offset on the texture to scale the v coordinates of the UVs
  18112. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18113. */
  18114. vScale: number;
  18115. /**
  18116. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18117. * @see http://doc.babylonjs.com/how_to/more_materials
  18118. */
  18119. uAng: number;
  18120. /**
  18121. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18122. * @see http://doc.babylonjs.com/how_to/more_materials
  18123. */
  18124. vAng: number;
  18125. /**
  18126. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18127. * @see http://doc.babylonjs.com/how_to/more_materials
  18128. */
  18129. wAng: number;
  18130. /**
  18131. * Defines the center of rotation (U)
  18132. */
  18133. uRotationCenter: number;
  18134. /**
  18135. * Defines the center of rotation (V)
  18136. */
  18137. vRotationCenter: number;
  18138. /**
  18139. * Defines the center of rotation (W)
  18140. */
  18141. wRotationCenter: number;
  18142. /**
  18143. * Are mip maps generated for this texture or not.
  18144. */
  18145. readonly noMipmap: boolean;
  18146. private _noMipmap;
  18147. /** @hidden */
  18148. _invertY: boolean;
  18149. private _rowGenerationMatrix;
  18150. private _cachedTextureMatrix;
  18151. private _projectionModeMatrix;
  18152. private _t0;
  18153. private _t1;
  18154. private _t2;
  18155. private _cachedUOffset;
  18156. private _cachedVOffset;
  18157. private _cachedUScale;
  18158. private _cachedVScale;
  18159. private _cachedUAng;
  18160. private _cachedVAng;
  18161. private _cachedWAng;
  18162. private _cachedProjectionMatrixId;
  18163. private _cachedCoordinatesMode;
  18164. /** @hidden */
  18165. protected _initialSamplingMode: number;
  18166. /** @hidden */
  18167. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18168. private _deleteBuffer;
  18169. protected _format: Nullable<number>;
  18170. private _delayedOnLoad;
  18171. private _delayedOnError;
  18172. /**
  18173. * Observable triggered once the texture has been loaded.
  18174. */
  18175. onLoadObservable: Observable<Texture>;
  18176. protected _isBlocking: boolean;
  18177. /**
  18178. * Is the texture preventing material to render while loading.
  18179. * If false, a default texture will be used instead of the loading one during the preparation step.
  18180. */
  18181. isBlocking: boolean;
  18182. /**
  18183. * Get the current sampling mode associated with the texture.
  18184. */
  18185. readonly samplingMode: number;
  18186. /**
  18187. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18188. */
  18189. readonly invertY: boolean;
  18190. /**
  18191. * Instantiates a new texture.
  18192. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18193. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18194. * @param url define the url of the picture to load as a texture
  18195. * @param scene define the scene the texture will belong to
  18196. * @param noMipmap define if the texture will require mip maps or not
  18197. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18198. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18199. * @param onLoad define a callback triggered when the texture has been loaded
  18200. * @param onError define a callback triggered when an error occurred during the loading session
  18201. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18202. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18203. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18204. */
  18205. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18206. /**
  18207. * Update the url (and optional buffer) of this texture if url was null during construction.
  18208. * @param url the url of the texture
  18209. * @param buffer the buffer of the texture (defaults to null)
  18210. * @param onLoad callback called when the texture is loaded (defaults to null)
  18211. */
  18212. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18213. /**
  18214. * Finish the loading sequence of a texture flagged as delayed load.
  18215. * @hidden
  18216. */
  18217. delayLoad(): void;
  18218. private _prepareRowForTextureGeneration;
  18219. /**
  18220. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18221. * @returns the transform matrix of the texture.
  18222. */
  18223. getTextureMatrix(): Matrix;
  18224. /**
  18225. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18226. * @returns The reflection texture transform
  18227. */
  18228. getReflectionTextureMatrix(): Matrix;
  18229. /**
  18230. * Clones the texture.
  18231. * @returns the cloned texture
  18232. */
  18233. clone(): Texture;
  18234. /**
  18235. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18236. * @returns The JSON representation of the texture
  18237. */
  18238. serialize(): any;
  18239. /**
  18240. * Get the current class name of the texture useful for serialization or dynamic coding.
  18241. * @returns "Texture"
  18242. */
  18243. getClassName(): string;
  18244. /**
  18245. * Dispose the texture and release its associated resources.
  18246. */
  18247. dispose(): void;
  18248. /**
  18249. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18250. * @param parsedTexture Define the JSON representation of the texture
  18251. * @param scene Define the scene the parsed texture should be instantiated in
  18252. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18253. * @returns The parsed texture if successful
  18254. */
  18255. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18256. /**
  18257. * Creates a texture from its base 64 representation.
  18258. * @param data Define the base64 payload without the data: prefix
  18259. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18260. * @param scene Define the scene the texture should belong to
  18261. * @param noMipmap Forces the texture to not create mip map information if true
  18262. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18263. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18264. * @param onLoad define a callback triggered when the texture has been loaded
  18265. * @param onError define a callback triggered when an error occurred during the loading session
  18266. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18267. * @returns the created texture
  18268. */
  18269. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18270. /**
  18271. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18272. * @param data Define the base64 payload without the data: prefix
  18273. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18274. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18275. * @param scene Define the scene the texture should belong to
  18276. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18277. * @param noMipmap Forces the texture to not create mip map information if true
  18278. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18279. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18280. * @param onLoad define a callback triggered when the texture has been loaded
  18281. * @param onError define a callback triggered when an error occurred during the loading session
  18282. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18283. * @returns the created texture
  18284. */
  18285. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  18286. }
  18287. }
  18288. declare module "babylonjs/Materials/Textures/rawTexture" {
  18289. import { Scene } from "babylonjs/scene";
  18290. import { Texture } from "babylonjs/Materials/Textures/texture";
  18291. /**
  18292. * Raw texture can help creating a texture directly from an array of data.
  18293. * This can be super useful if you either get the data from an uncompressed source or
  18294. * if you wish to create your texture pixel by pixel.
  18295. */
  18296. export class RawTexture extends Texture {
  18297. /**
  18298. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18299. */
  18300. format: number;
  18301. private _engine;
  18302. /**
  18303. * Instantiates a new RawTexture.
  18304. * Raw texture can help creating a texture directly from an array of data.
  18305. * This can be super useful if you either get the data from an uncompressed source or
  18306. * if you wish to create your texture pixel by pixel.
  18307. * @param data define the array of data to use to create the texture
  18308. * @param width define the width of the texture
  18309. * @param height define the height of the texture
  18310. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18311. * @param scene define the scene the texture belongs to
  18312. * @param generateMipMaps define whether mip maps should be generated or not
  18313. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18314. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18315. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18316. */
  18317. constructor(data: ArrayBufferView, width: number, height: number,
  18318. /**
  18319. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18320. */
  18321. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18322. /**
  18323. * Updates the texture underlying data.
  18324. * @param data Define the new data of the texture
  18325. */
  18326. update(data: ArrayBufferView): void;
  18327. /**
  18328. * Creates a luminance texture from some data.
  18329. * @param data Define the texture data
  18330. * @param width Define the width of the texture
  18331. * @param height Define the height of the texture
  18332. * @param scene Define the scene the texture belongs to
  18333. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18334. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18335. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18336. * @returns the luminance texture
  18337. */
  18338. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18339. /**
  18340. * Creates a luminance alpha texture from some data.
  18341. * @param data Define the texture data
  18342. * @param width Define the width of the texture
  18343. * @param height Define the height of the texture
  18344. * @param scene Define the scene the texture belongs to
  18345. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18346. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18347. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18348. * @returns the luminance alpha texture
  18349. */
  18350. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18351. /**
  18352. * Creates an alpha texture from some data.
  18353. * @param data Define the texture data
  18354. * @param width Define the width of the texture
  18355. * @param height Define the height of the texture
  18356. * @param scene Define the scene the texture belongs to
  18357. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18358. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18359. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18360. * @returns the alpha texture
  18361. */
  18362. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18363. /**
  18364. * Creates a RGB texture from some data.
  18365. * @param data Define the texture data
  18366. * @param width Define the width of the texture
  18367. * @param height Define the height of the texture
  18368. * @param scene Define the scene the texture belongs to
  18369. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18370. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18371. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18372. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18373. * @returns the RGB alpha texture
  18374. */
  18375. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18376. /**
  18377. * Creates a RGBA texture from some data.
  18378. * @param data Define the texture data
  18379. * @param width Define the width of the texture
  18380. * @param height Define the height of the texture
  18381. * @param scene Define the scene the texture belongs to
  18382. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18383. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18384. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18385. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18386. * @returns the RGBA texture
  18387. */
  18388. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18389. /**
  18390. * Creates a R texture from some data.
  18391. * @param data Define the texture data
  18392. * @param width Define the width of the texture
  18393. * @param height Define the height of the texture
  18394. * @param scene Define the scene the texture belongs to
  18395. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18396. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18397. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18398. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18399. * @returns the R texture
  18400. */
  18401. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18402. }
  18403. }
  18404. declare module "babylonjs/Animations/runtimeAnimation" {
  18405. import { Animation } from "babylonjs/Animations/animation";
  18406. import { Animatable } from "babylonjs/Animations/animatable";
  18407. import { Scene } from "babylonjs/scene";
  18408. /**
  18409. * Defines a runtime animation
  18410. */
  18411. export class RuntimeAnimation {
  18412. private _events;
  18413. /**
  18414. * The current frame of the runtime animation
  18415. */
  18416. private _currentFrame;
  18417. /**
  18418. * The animation used by the runtime animation
  18419. */
  18420. private _animation;
  18421. /**
  18422. * The target of the runtime animation
  18423. */
  18424. private _target;
  18425. /**
  18426. * The initiating animatable
  18427. */
  18428. private _host;
  18429. /**
  18430. * The original value of the runtime animation
  18431. */
  18432. private _originalValue;
  18433. /**
  18434. * The original blend value of the runtime animation
  18435. */
  18436. private _originalBlendValue;
  18437. /**
  18438. * The offsets cache of the runtime animation
  18439. */
  18440. private _offsetsCache;
  18441. /**
  18442. * The high limits cache of the runtime animation
  18443. */
  18444. private _highLimitsCache;
  18445. /**
  18446. * Specifies if the runtime animation has been stopped
  18447. */
  18448. private _stopped;
  18449. /**
  18450. * The blending factor of the runtime animation
  18451. */
  18452. private _blendingFactor;
  18453. /**
  18454. * The BabylonJS scene
  18455. */
  18456. private _scene;
  18457. /**
  18458. * The current value of the runtime animation
  18459. */
  18460. private _currentValue;
  18461. /** @hidden */
  18462. _workValue: any;
  18463. /**
  18464. * The active target of the runtime animation
  18465. */
  18466. private _activeTarget;
  18467. /**
  18468. * The target path of the runtime animation
  18469. */
  18470. private _targetPath;
  18471. /**
  18472. * The weight of the runtime animation
  18473. */
  18474. private _weight;
  18475. /**
  18476. * The ratio offset of the runtime animation
  18477. */
  18478. private _ratioOffset;
  18479. /**
  18480. * The previous delay of the runtime animation
  18481. */
  18482. private _previousDelay;
  18483. /**
  18484. * The previous ratio of the runtime animation
  18485. */
  18486. private _previousRatio;
  18487. /**
  18488. * Gets the current frame of the runtime animation
  18489. */
  18490. readonly currentFrame: number;
  18491. /**
  18492. * Gets the weight of the runtime animation
  18493. */
  18494. readonly weight: number;
  18495. /**
  18496. * Gets the current value of the runtime animation
  18497. */
  18498. readonly currentValue: any;
  18499. /**
  18500. * Gets the target path of the runtime animation
  18501. */
  18502. readonly targetPath: string;
  18503. /**
  18504. * Gets the actual target of the runtime animation
  18505. */
  18506. readonly target: any;
  18507. /**
  18508. * Create a new RuntimeAnimation object
  18509. * @param target defines the target of the animation
  18510. * @param animation defines the source animation object
  18511. * @param scene defines the hosting scene
  18512. * @param host defines the initiating Animatable
  18513. */
  18514. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18515. /**
  18516. * Gets the animation from the runtime animation
  18517. */
  18518. readonly animation: Animation;
  18519. /**
  18520. * Resets the runtime animation to the beginning
  18521. * @param restoreOriginal defines whether to restore the target property to the original value
  18522. */
  18523. reset(restoreOriginal?: boolean): void;
  18524. /**
  18525. * Specifies if the runtime animation is stopped
  18526. * @returns Boolean specifying if the runtime animation is stopped
  18527. */
  18528. isStopped(): boolean;
  18529. /**
  18530. * Disposes of the runtime animation
  18531. */
  18532. dispose(): void;
  18533. /**
  18534. * Interpolates the animation from the current frame
  18535. * @param currentFrame The frame to interpolate the animation to
  18536. * @param repeatCount The number of times that the animation should loop
  18537. * @param loopMode The type of looping mode to use
  18538. * @param offsetValue Animation offset value
  18539. * @param highLimitValue The high limit value
  18540. * @returns The interpolated value
  18541. */
  18542. private _interpolate;
  18543. /**
  18544. * Apply the interpolated value to the target
  18545. * @param currentValue defines the value computed by the animation
  18546. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18547. */
  18548. setValue(currentValue: any, weight?: number): void;
  18549. private _setValue;
  18550. /**
  18551. * Gets the loop pmode of the runtime animation
  18552. * @returns Loop Mode
  18553. */
  18554. private _getCorrectLoopMode;
  18555. /**
  18556. * Move the current animation to a given frame
  18557. * @param frame defines the frame to move to
  18558. */
  18559. goToFrame(frame: number): void;
  18560. /**
  18561. * @hidden Internal use only
  18562. */
  18563. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18564. /**
  18565. * Execute the current animation
  18566. * @param delay defines the delay to add to the current frame
  18567. * @param from defines the lower bound of the animation range
  18568. * @param to defines the upper bound of the animation range
  18569. * @param loop defines if the current animation must loop
  18570. * @param speedRatio defines the current speed ratio
  18571. * @param weight defines the weight of the animation (default is -1 so no weight)
  18572. * @param onLoop optional callback called when animation loops
  18573. * @returns a boolean indicating if the animation is running
  18574. */
  18575. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18576. }
  18577. }
  18578. declare module "babylonjs/Animations/animatable" {
  18579. import { Animation } from "babylonjs/Animations/animation";
  18580. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18581. import { Nullable } from "babylonjs/types";
  18582. import { Observable } from "babylonjs/Misc/observable";
  18583. import { Scene } from "babylonjs/scene";
  18584. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18585. import { Node } from "babylonjs/node";
  18586. /**
  18587. * Class used to store an actual running animation
  18588. */
  18589. export class Animatable {
  18590. /** defines the target object */
  18591. target: any;
  18592. /** defines the starting frame number (default is 0) */
  18593. fromFrame: number;
  18594. /** defines the ending frame number (default is 100) */
  18595. toFrame: number;
  18596. /** defines if the animation must loop (default is false) */
  18597. loopAnimation: boolean;
  18598. /** defines a callback to call when animation ends if it is not looping */
  18599. onAnimationEnd?: (() => void) | null | undefined;
  18600. /** defines a callback to call when animation loops */
  18601. onAnimationLoop?: (() => void) | null | undefined;
  18602. private _localDelayOffset;
  18603. private _pausedDelay;
  18604. private _runtimeAnimations;
  18605. private _paused;
  18606. private _scene;
  18607. private _speedRatio;
  18608. private _weight;
  18609. private _syncRoot;
  18610. /**
  18611. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18612. * This will only apply for non looping animation (default is true)
  18613. */
  18614. disposeOnEnd: boolean;
  18615. /**
  18616. * Gets a boolean indicating if the animation has started
  18617. */
  18618. animationStarted: boolean;
  18619. /**
  18620. * Observer raised when the animation ends
  18621. */
  18622. onAnimationEndObservable: Observable<Animatable>;
  18623. /**
  18624. * Observer raised when the animation loops
  18625. */
  18626. onAnimationLoopObservable: Observable<Animatable>;
  18627. /**
  18628. * Gets the root Animatable used to synchronize and normalize animations
  18629. */
  18630. readonly syncRoot: Animatable;
  18631. /**
  18632. * Gets the current frame of the first RuntimeAnimation
  18633. * Used to synchronize Animatables
  18634. */
  18635. readonly masterFrame: number;
  18636. /**
  18637. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18638. */
  18639. weight: number;
  18640. /**
  18641. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18642. */
  18643. speedRatio: number;
  18644. /**
  18645. * Creates a new Animatable
  18646. * @param scene defines the hosting scene
  18647. * @param target defines the target object
  18648. * @param fromFrame defines the starting frame number (default is 0)
  18649. * @param toFrame defines the ending frame number (default is 100)
  18650. * @param loopAnimation defines if the animation must loop (default is false)
  18651. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18652. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18653. * @param animations defines a group of animation to add to the new Animatable
  18654. * @param onAnimationLoop defines a callback to call when animation loops
  18655. */
  18656. constructor(scene: Scene,
  18657. /** defines the target object */
  18658. target: any,
  18659. /** defines the starting frame number (default is 0) */
  18660. fromFrame?: number,
  18661. /** defines the ending frame number (default is 100) */
  18662. toFrame?: number,
  18663. /** defines if the animation must loop (default is false) */
  18664. loopAnimation?: boolean, speedRatio?: number,
  18665. /** defines a callback to call when animation ends if it is not looping */
  18666. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18667. /** defines a callback to call when animation loops */
  18668. onAnimationLoop?: (() => void) | null | undefined);
  18669. /**
  18670. * Synchronize and normalize current Animatable with a source Animatable
  18671. * This is useful when using animation weights and when animations are not of the same length
  18672. * @param root defines the root Animatable to synchronize with
  18673. * @returns the current Animatable
  18674. */
  18675. syncWith(root: Animatable): Animatable;
  18676. /**
  18677. * Gets the list of runtime animations
  18678. * @returns an array of RuntimeAnimation
  18679. */
  18680. getAnimations(): RuntimeAnimation[];
  18681. /**
  18682. * Adds more animations to the current animatable
  18683. * @param target defines the target of the animations
  18684. * @param animations defines the new animations to add
  18685. */
  18686. appendAnimations(target: any, animations: Animation[]): void;
  18687. /**
  18688. * Gets the source animation for a specific property
  18689. * @param property defines the propertyu to look for
  18690. * @returns null or the source animation for the given property
  18691. */
  18692. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18693. /**
  18694. * Gets the runtime animation for a specific property
  18695. * @param property defines the propertyu to look for
  18696. * @returns null or the runtime animation for the given property
  18697. */
  18698. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18699. /**
  18700. * Resets the animatable to its original state
  18701. */
  18702. reset(): void;
  18703. /**
  18704. * Allows the animatable to blend with current running animations
  18705. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18706. * @param blendingSpeed defines the blending speed to use
  18707. */
  18708. enableBlending(blendingSpeed: number): void;
  18709. /**
  18710. * Disable animation blending
  18711. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18712. */
  18713. disableBlending(): void;
  18714. /**
  18715. * Jump directly to a given frame
  18716. * @param frame defines the frame to jump to
  18717. */
  18718. goToFrame(frame: number): void;
  18719. /**
  18720. * Pause the animation
  18721. */
  18722. pause(): void;
  18723. /**
  18724. * Restart the animation
  18725. */
  18726. restart(): void;
  18727. private _raiseOnAnimationEnd;
  18728. /**
  18729. * Stop and delete the current animation
  18730. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18731. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  18732. */
  18733. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18734. /**
  18735. * Wait asynchronously for the animation to end
  18736. * @returns a promise which will be fullfilled when the animation ends
  18737. */
  18738. waitAsync(): Promise<Animatable>;
  18739. /** @hidden */
  18740. _animate(delay: number): boolean;
  18741. }
  18742. module "babylonjs/scene" {
  18743. interface Scene {
  18744. /** @hidden */
  18745. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18746. /** @hidden */
  18747. _processLateAnimationBindingsForMatrices(holder: {
  18748. totalWeight: number;
  18749. animations: RuntimeAnimation[];
  18750. originalValue: Matrix;
  18751. }): any;
  18752. /** @hidden */
  18753. _processLateAnimationBindingsForQuaternions(holder: {
  18754. totalWeight: number;
  18755. animations: RuntimeAnimation[];
  18756. originalValue: Quaternion;
  18757. }, refQuaternion: Quaternion): Quaternion;
  18758. /** @hidden */
  18759. _processLateAnimationBindings(): void;
  18760. /**
  18761. * Will start the animation sequence of a given target
  18762. * @param target defines the target
  18763. * @param from defines from which frame should animation start
  18764. * @param to defines until which frame should animation run.
  18765. * @param weight defines the weight to apply to the animation (1.0 by default)
  18766. * @param loop defines if the animation loops
  18767. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18768. * @param onAnimationEnd defines the function to be executed when the animation ends
  18769. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18770. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18771. * @param onAnimationLoop defines the callback to call when an animation loops
  18772. * @returns the animatable object created for this animation
  18773. */
  18774. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18775. /**
  18776. * Will start the animation sequence of a given target
  18777. * @param target defines the target
  18778. * @param from defines from which frame should animation start
  18779. * @param to defines until which frame should animation run.
  18780. * @param loop defines if the animation loops
  18781. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18782. * @param onAnimationEnd defines the function to be executed when the animation ends
  18783. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18784. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18785. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18786. * @param onAnimationLoop defines the callback to call when an animation loops
  18787. * @returns the animatable object created for this animation
  18788. */
  18789. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18790. /**
  18791. * Will start the animation sequence of a given target and its hierarchy
  18792. * @param target defines the target
  18793. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  18794. * @param from defines from which frame should animation start
  18795. * @param to defines until which frame should animation run.
  18796. * @param loop defines if the animation loops
  18797. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18798. * @param onAnimationEnd defines the function to be executed when the animation ends
  18799. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18800. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18801. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18802. * @param onAnimationLoop defines the callback to call when an animation loops
  18803. * @returns the list of created animatables
  18804. */
  18805. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  18806. /**
  18807. * Begin a new animation on a given node
  18808. * @param target defines the target where the animation will take place
  18809. * @param animations defines the list of animations to start
  18810. * @param from defines the initial value
  18811. * @param to defines the final value
  18812. * @param loop defines if you want animation to loop (off by default)
  18813. * @param speedRatio defines the speed ratio to apply to all animations
  18814. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18815. * @param onAnimationLoop defines the callback to call when an animation loops
  18816. * @returns the list of created animatables
  18817. */
  18818. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18819. /**
  18820. * Begin a new animation on a given node and its hierarchy
  18821. * @param target defines the root node where the animation will take place
  18822. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  18823. * @param animations defines the list of animations to start
  18824. * @param from defines the initial value
  18825. * @param to defines the final value
  18826. * @param loop defines if you want animation to loop (off by default)
  18827. * @param speedRatio defines the speed ratio to apply to all animations
  18828. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18829. * @param onAnimationLoop defines the callback to call when an animation loops
  18830. * @returns the list of animatables created for all nodes
  18831. */
  18832. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18833. /**
  18834. * Gets the animatable associated with a specific target
  18835. * @param target defines the target of the animatable
  18836. * @returns the required animatable if found
  18837. */
  18838. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18839. /**
  18840. * Gets all animatables associated with a given target
  18841. * @param target defines the target to look animatables for
  18842. * @returns an array of Animatables
  18843. */
  18844. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18845. /**
  18846. * Will stop the animation of the given target
  18847. * @param target - the target
  18848. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18849. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  18850. */
  18851. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18852. /**
  18853. * Stops and removes all animations that have been applied to the scene
  18854. */
  18855. stopAllAnimations(): void;
  18856. }
  18857. }
  18858. module "babylonjs/Bones/bone" {
  18859. interface Bone {
  18860. /**
  18861. * Copy an animation range from another bone
  18862. * @param source defines the source bone
  18863. * @param rangeName defines the range name to copy
  18864. * @param frameOffset defines the frame offset
  18865. * @param rescaleAsRequired defines if rescaling must be applied if required
  18866. * @param skelDimensionsRatio defines the scaling ratio
  18867. * @returns true if operation was successful
  18868. */
  18869. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18870. }
  18871. }
  18872. }
  18873. declare module "babylonjs/Bones/skeleton" {
  18874. import { Bone } from "babylonjs/Bones/bone";
  18875. import { IAnimatable } from "babylonjs/Misc/tools";
  18876. import { Observable } from "babylonjs/Misc/observable";
  18877. import { Vector3, Matrix } from "babylonjs/Maths/math";
  18878. import { Scene } from "babylonjs/scene";
  18879. import { Nullable } from "babylonjs/types";
  18880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18881. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  18882. import { Animatable } from "babylonjs/Animations/animatable";
  18883. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  18884. import { Animation } from "babylonjs/Animations/animation";
  18885. import { AnimationRange } from "babylonjs/Animations/animationRange";
  18886. /**
  18887. * Class used to handle skinning animations
  18888. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18889. */
  18890. export class Skeleton implements IAnimatable {
  18891. /** defines the skeleton name */
  18892. name: string;
  18893. /** defines the skeleton Id */
  18894. id: string;
  18895. /**
  18896. * Defines the list of child bones
  18897. */
  18898. bones: Bone[];
  18899. /**
  18900. * Defines an estimate of the dimension of the skeleton at rest
  18901. */
  18902. dimensionsAtRest: Vector3;
  18903. /**
  18904. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18905. */
  18906. needInitialSkinMatrix: boolean;
  18907. /**
  18908. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18909. */
  18910. overrideMesh: Nullable<AbstractMesh>;
  18911. /**
  18912. * Gets the list of animations attached to this skeleton
  18913. */
  18914. animations: Array<Animation>;
  18915. private _scene;
  18916. private _isDirty;
  18917. private _transformMatrices;
  18918. private _transformMatrixTexture;
  18919. private _meshesWithPoseMatrix;
  18920. private _animatables;
  18921. private _identity;
  18922. private _synchronizedWithMesh;
  18923. private _ranges;
  18924. private _lastAbsoluteTransformsUpdateId;
  18925. private _canUseTextureForBones;
  18926. /** @hidden */
  18927. _numBonesWithLinkedTransformNode: number;
  18928. /**
  18929. * Specifies if the skeleton should be serialized
  18930. */
  18931. doNotSerialize: boolean;
  18932. /**
  18933. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18934. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18935. */
  18936. useTextureToStoreBoneMatrices: boolean;
  18937. private _animationPropertiesOverride;
  18938. /**
  18939. * Gets or sets the animation properties override
  18940. */
  18941. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18942. /**
  18943. * An observable triggered before computing the skeleton's matrices
  18944. */
  18945. onBeforeComputeObservable: Observable<Skeleton>;
  18946. /**
  18947. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18948. */
  18949. readonly isUsingTextureForMatrices: boolean;
  18950. /**
  18951. * Creates a new skeleton
  18952. * @param name defines the skeleton name
  18953. * @param id defines the skeleton Id
  18954. * @param scene defines the hosting scene
  18955. */
  18956. constructor(
  18957. /** defines the skeleton name */
  18958. name: string,
  18959. /** defines the skeleton Id */
  18960. id: string, scene: Scene);
  18961. /**
  18962. * Gets the current object class name.
  18963. * @return the class name
  18964. */
  18965. getClassName(): string;
  18966. /**
  18967. * Returns an array containing the root bones
  18968. * @returns an array containing the root bones
  18969. */
  18970. getChildren(): Array<Bone>;
  18971. /**
  18972. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18973. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18974. * @returns a Float32Array containing matrices data
  18975. */
  18976. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18977. /**
  18978. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18979. * @returns a raw texture containing the data
  18980. */
  18981. getTransformMatrixTexture(): Nullable<RawTexture>;
  18982. /**
  18983. * Gets the current hosting scene
  18984. * @returns a scene object
  18985. */
  18986. getScene(): Scene;
  18987. /**
  18988. * Gets a string representing the current skeleton data
  18989. * @param fullDetails defines a boolean indicating if we want a verbose version
  18990. * @returns a string representing the current skeleton data
  18991. */
  18992. toString(fullDetails?: boolean): string;
  18993. /**
  18994. * Get bone's index searching by name
  18995. * @param name defines bone's name to search for
  18996. * @return the indice of the bone. Returns -1 if not found
  18997. */
  18998. getBoneIndexByName(name: string): number;
  18999. /**
  19000. * Creater a new animation range
  19001. * @param name defines the name of the range
  19002. * @param from defines the start key
  19003. * @param to defines the end key
  19004. */
  19005. createAnimationRange(name: string, from: number, to: number): void;
  19006. /**
  19007. * Delete a specific animation range
  19008. * @param name defines the name of the range
  19009. * @param deleteFrames defines if frames must be removed as well
  19010. */
  19011. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19012. /**
  19013. * Gets a specific animation range
  19014. * @param name defines the name of the range to look for
  19015. * @returns the requested animation range or null if not found
  19016. */
  19017. getAnimationRange(name: string): Nullable<AnimationRange>;
  19018. /**
  19019. * Gets the list of all animation ranges defined on this skeleton
  19020. * @returns an array
  19021. */
  19022. getAnimationRanges(): Nullable<AnimationRange>[];
  19023. /**
  19024. * Copy animation range from a source skeleton.
  19025. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19026. * @param source defines the source skeleton
  19027. * @param name defines the name of the range to copy
  19028. * @param rescaleAsRequired defines if rescaling must be applied if required
  19029. * @returns true if operation was successful
  19030. */
  19031. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19032. /**
  19033. * Forces the skeleton to go to rest pose
  19034. */
  19035. returnToRest(): void;
  19036. private _getHighestAnimationFrame;
  19037. /**
  19038. * Begin a specific animation range
  19039. * @param name defines the name of the range to start
  19040. * @param loop defines if looping must be turned on (false by default)
  19041. * @param speedRatio defines the speed ratio to apply (1 by default)
  19042. * @param onAnimationEnd defines a callback which will be called when animation will end
  19043. * @returns a new animatable
  19044. */
  19045. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19046. /** @hidden */
  19047. _markAsDirty(): void;
  19048. /** @hidden */
  19049. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19050. /** @hidden */
  19051. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19052. private _computeTransformMatrices;
  19053. /**
  19054. * Build all resources required to render a skeleton
  19055. */
  19056. prepare(): void;
  19057. /**
  19058. * Gets the list of animatables currently running for this skeleton
  19059. * @returns an array of animatables
  19060. */
  19061. getAnimatables(): IAnimatable[];
  19062. /**
  19063. * Clone the current skeleton
  19064. * @param name defines the name of the new skeleton
  19065. * @param id defines the id of the enw skeleton
  19066. * @returns the new skeleton
  19067. */
  19068. clone(name: string, id: string): Skeleton;
  19069. /**
  19070. * Enable animation blending for this skeleton
  19071. * @param blendingSpeed defines the blending speed to apply
  19072. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19073. */
  19074. enableBlending(blendingSpeed?: number): void;
  19075. /**
  19076. * Releases all resources associated with the current skeleton
  19077. */
  19078. dispose(): void;
  19079. /**
  19080. * Serialize the skeleton in a JSON object
  19081. * @returns a JSON object
  19082. */
  19083. serialize(): any;
  19084. /**
  19085. * Creates a new skeleton from serialized data
  19086. * @param parsedSkeleton defines the serialized data
  19087. * @param scene defines the hosting scene
  19088. * @returns a new skeleton
  19089. */
  19090. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19091. /**
  19092. * Compute all node absolute transforms
  19093. * @param forceUpdate defines if computation must be done even if cache is up to date
  19094. */
  19095. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19096. /**
  19097. * Gets the root pose matrix
  19098. * @returns a matrix
  19099. */
  19100. getPoseMatrix(): Nullable<Matrix>;
  19101. /**
  19102. * Sorts bones per internal index
  19103. */
  19104. sortBones(): void;
  19105. private _sortBones;
  19106. }
  19107. }
  19108. declare module "babylonjs/Morph/morphTarget" {
  19109. import { IAnimatable } from "babylonjs/Misc/tools";
  19110. import { Observable } from "babylonjs/Misc/observable";
  19111. import { Nullable, FloatArray } from "babylonjs/types";
  19112. import { Scene } from "babylonjs/scene";
  19113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19114. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19115. /**
  19116. * Defines a target to use with MorphTargetManager
  19117. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19118. */
  19119. export class MorphTarget implements IAnimatable {
  19120. /** defines the name of the target */
  19121. name: string;
  19122. /**
  19123. * Gets or sets the list of animations
  19124. */
  19125. animations: import("babylonjs/Animations/animation").Animation[];
  19126. private _scene;
  19127. private _positions;
  19128. private _normals;
  19129. private _tangents;
  19130. private _influence;
  19131. /**
  19132. * Observable raised when the influence changes
  19133. */
  19134. onInfluenceChanged: Observable<boolean>;
  19135. /** @hidden */
  19136. _onDataLayoutChanged: Observable<void>;
  19137. /**
  19138. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19139. */
  19140. influence: number;
  19141. /**
  19142. * Gets or sets the id of the morph Target
  19143. */
  19144. id: string;
  19145. private _animationPropertiesOverride;
  19146. /**
  19147. * Gets or sets the animation properties override
  19148. */
  19149. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19150. /**
  19151. * Creates a new MorphTarget
  19152. * @param name defines the name of the target
  19153. * @param influence defines the influence to use
  19154. * @param scene defines the scene the morphtarget belongs to
  19155. */
  19156. constructor(
  19157. /** defines the name of the target */
  19158. name: string, influence?: number, scene?: Nullable<Scene>);
  19159. /**
  19160. * Gets a boolean defining if the target contains position data
  19161. */
  19162. readonly hasPositions: boolean;
  19163. /**
  19164. * Gets a boolean defining if the target contains normal data
  19165. */
  19166. readonly hasNormals: boolean;
  19167. /**
  19168. * Gets a boolean defining if the target contains tangent data
  19169. */
  19170. readonly hasTangents: boolean;
  19171. /**
  19172. * Affects position data to this target
  19173. * @param data defines the position data to use
  19174. */
  19175. setPositions(data: Nullable<FloatArray>): void;
  19176. /**
  19177. * Gets the position data stored in this target
  19178. * @returns a FloatArray containing the position data (or null if not present)
  19179. */
  19180. getPositions(): Nullable<FloatArray>;
  19181. /**
  19182. * Affects normal data to this target
  19183. * @param data defines the normal data to use
  19184. */
  19185. setNormals(data: Nullable<FloatArray>): void;
  19186. /**
  19187. * Gets the normal data stored in this target
  19188. * @returns a FloatArray containing the normal data (or null if not present)
  19189. */
  19190. getNormals(): Nullable<FloatArray>;
  19191. /**
  19192. * Affects tangent data to this target
  19193. * @param data defines the tangent data to use
  19194. */
  19195. setTangents(data: Nullable<FloatArray>): void;
  19196. /**
  19197. * Gets the tangent data stored in this target
  19198. * @returns a FloatArray containing the tangent data (or null if not present)
  19199. */
  19200. getTangents(): Nullable<FloatArray>;
  19201. /**
  19202. * Serializes the current target into a Serialization object
  19203. * @returns the serialized object
  19204. */
  19205. serialize(): any;
  19206. /**
  19207. * Returns the string "MorphTarget"
  19208. * @returns "MorphTarget"
  19209. */
  19210. getClassName(): string;
  19211. /**
  19212. * Creates a new target from serialized data
  19213. * @param serializationObject defines the serialized data to use
  19214. * @returns a new MorphTarget
  19215. */
  19216. static Parse(serializationObject: any): MorphTarget;
  19217. /**
  19218. * Creates a MorphTarget from mesh data
  19219. * @param mesh defines the source mesh
  19220. * @param name defines the name to use for the new target
  19221. * @param influence defines the influence to attach to the target
  19222. * @returns a new MorphTarget
  19223. */
  19224. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19225. }
  19226. }
  19227. declare module "babylonjs/Morph/morphTargetManager" {
  19228. import { Nullable } from "babylonjs/types";
  19229. import { Scene } from "babylonjs/scene";
  19230. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19231. /**
  19232. * This class is used to deform meshes using morphing between different targets
  19233. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19234. */
  19235. export class MorphTargetManager {
  19236. private _targets;
  19237. private _targetInfluenceChangedObservers;
  19238. private _targetDataLayoutChangedObservers;
  19239. private _activeTargets;
  19240. private _scene;
  19241. private _influences;
  19242. private _supportsNormals;
  19243. private _supportsTangents;
  19244. private _vertexCount;
  19245. private _uniqueId;
  19246. private _tempInfluences;
  19247. /**
  19248. * Creates a new MorphTargetManager
  19249. * @param scene defines the current scene
  19250. */
  19251. constructor(scene?: Nullable<Scene>);
  19252. /**
  19253. * Gets the unique ID of this manager
  19254. */
  19255. readonly uniqueId: number;
  19256. /**
  19257. * Gets the number of vertices handled by this manager
  19258. */
  19259. readonly vertexCount: number;
  19260. /**
  19261. * Gets a boolean indicating if this manager supports morphing of normals
  19262. */
  19263. readonly supportsNormals: boolean;
  19264. /**
  19265. * Gets a boolean indicating if this manager supports morphing of tangents
  19266. */
  19267. readonly supportsTangents: boolean;
  19268. /**
  19269. * Gets the number of targets stored in this manager
  19270. */
  19271. readonly numTargets: number;
  19272. /**
  19273. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19274. */
  19275. readonly numInfluencers: number;
  19276. /**
  19277. * Gets the list of influences (one per target)
  19278. */
  19279. readonly influences: Float32Array;
  19280. /**
  19281. * Gets the active target at specified index. An active target is a target with an influence > 0
  19282. * @param index defines the index to check
  19283. * @returns the requested target
  19284. */
  19285. getActiveTarget(index: number): MorphTarget;
  19286. /**
  19287. * Gets the target at specified index
  19288. * @param index defines the index to check
  19289. * @returns the requested target
  19290. */
  19291. getTarget(index: number): MorphTarget;
  19292. /**
  19293. * Add a new target to this manager
  19294. * @param target defines the target to add
  19295. */
  19296. addTarget(target: MorphTarget): void;
  19297. /**
  19298. * Removes a target from the manager
  19299. * @param target defines the target to remove
  19300. */
  19301. removeTarget(target: MorphTarget): void;
  19302. /**
  19303. * Serializes the current manager into a Serialization object
  19304. * @returns the serialized object
  19305. */
  19306. serialize(): any;
  19307. private _syncActiveTargets;
  19308. /**
  19309. * Syncrhonize the targets with all the meshes using this morph target manager
  19310. */
  19311. synchronize(): void;
  19312. /**
  19313. * Creates a new MorphTargetManager from serialized data
  19314. * @param serializationObject defines the serialized data
  19315. * @param scene defines the hosting scene
  19316. * @returns the new MorphTargetManager
  19317. */
  19318. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19319. }
  19320. }
  19321. declare module "babylonjs/Meshes/groundMesh" {
  19322. import { Scene } from "babylonjs/scene";
  19323. import { Vector3 } from "babylonjs/Maths/math";
  19324. import { Mesh } from "babylonjs/Meshes/mesh";
  19325. /**
  19326. * Mesh representing the gorund
  19327. */
  19328. export class GroundMesh extends Mesh {
  19329. /** If octree should be generated */
  19330. generateOctree: boolean;
  19331. private _heightQuads;
  19332. /** @hidden */
  19333. _subdivisionsX: number;
  19334. /** @hidden */
  19335. _subdivisionsY: number;
  19336. /** @hidden */
  19337. _width: number;
  19338. /** @hidden */
  19339. _height: number;
  19340. /** @hidden */
  19341. _minX: number;
  19342. /** @hidden */
  19343. _maxX: number;
  19344. /** @hidden */
  19345. _minZ: number;
  19346. /** @hidden */
  19347. _maxZ: number;
  19348. constructor(name: string, scene: Scene);
  19349. /**
  19350. * "GroundMesh"
  19351. * @returns "GroundMesh"
  19352. */
  19353. getClassName(): string;
  19354. /**
  19355. * The minimum of x and y subdivisions
  19356. */
  19357. readonly subdivisions: number;
  19358. /**
  19359. * X subdivisions
  19360. */
  19361. readonly subdivisionsX: number;
  19362. /**
  19363. * Y subdivisions
  19364. */
  19365. readonly subdivisionsY: number;
  19366. /**
  19367. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19368. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19369. * @param chunksCount the number of subdivisions for x and y
  19370. * @param octreeBlocksSize (Default: 32)
  19371. */
  19372. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19373. /**
  19374. * Returns a height (y) value in the Worl system :
  19375. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19376. * @param x x coordinate
  19377. * @param z z coordinate
  19378. * @returns the ground y position if (x, z) are outside the ground surface.
  19379. */
  19380. getHeightAtCoordinates(x: number, z: number): number;
  19381. /**
  19382. * Returns a normalized vector (Vector3) orthogonal to the ground
  19383. * at the ground coordinates (x, z) expressed in the World system.
  19384. * @param x x coordinate
  19385. * @param z z coordinate
  19386. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19387. */
  19388. getNormalAtCoordinates(x: number, z: number): Vector3;
  19389. /**
  19390. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19391. * at the ground coordinates (x, z) expressed in the World system.
  19392. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19393. * @param x x coordinate
  19394. * @param z z coordinate
  19395. * @param ref vector to store the result
  19396. * @returns the GroundMesh.
  19397. */
  19398. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19399. /**
  19400. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19401. * if the ground has been updated.
  19402. * This can be used in the render loop.
  19403. * @returns the GroundMesh.
  19404. */
  19405. updateCoordinateHeights(): GroundMesh;
  19406. private _getFacetAt;
  19407. private _initHeightQuads;
  19408. private _computeHeightQuads;
  19409. /**
  19410. * Serializes this ground mesh
  19411. * @param serializationObject object to write serialization to
  19412. */
  19413. serialize(serializationObject: any): void;
  19414. /**
  19415. * Parses a serialized ground mesh
  19416. * @param parsedMesh the serialized mesh
  19417. * @param scene the scene to create the ground mesh in
  19418. * @returns the created ground mesh
  19419. */
  19420. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19421. }
  19422. }
  19423. declare module "babylonjs/Physics/physicsJoint" {
  19424. import { Vector3 } from "babylonjs/Maths/math";
  19425. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19426. /**
  19427. * Interface for Physics-Joint data
  19428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19429. */
  19430. export interface PhysicsJointData {
  19431. /**
  19432. * The main pivot of the joint
  19433. */
  19434. mainPivot?: Vector3;
  19435. /**
  19436. * The connected pivot of the joint
  19437. */
  19438. connectedPivot?: Vector3;
  19439. /**
  19440. * The main axis of the joint
  19441. */
  19442. mainAxis?: Vector3;
  19443. /**
  19444. * The connected axis of the joint
  19445. */
  19446. connectedAxis?: Vector3;
  19447. /**
  19448. * The collision of the joint
  19449. */
  19450. collision?: boolean;
  19451. /**
  19452. * Native Oimo/Cannon/Energy data
  19453. */
  19454. nativeParams?: any;
  19455. }
  19456. /**
  19457. * This is a holder class for the physics joint created by the physics plugin
  19458. * It holds a set of functions to control the underlying joint
  19459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19460. */
  19461. export class PhysicsJoint {
  19462. /**
  19463. * The type of the physics joint
  19464. */
  19465. type: number;
  19466. /**
  19467. * The data for the physics joint
  19468. */
  19469. jointData: PhysicsJointData;
  19470. private _physicsJoint;
  19471. protected _physicsPlugin: IPhysicsEnginePlugin;
  19472. /**
  19473. * Initializes the physics joint
  19474. * @param type The type of the physics joint
  19475. * @param jointData The data for the physics joint
  19476. */
  19477. constructor(
  19478. /**
  19479. * The type of the physics joint
  19480. */
  19481. type: number,
  19482. /**
  19483. * The data for the physics joint
  19484. */
  19485. jointData: PhysicsJointData);
  19486. /**
  19487. * Gets the physics joint
  19488. */
  19489. /**
  19490. * Sets the physics joint
  19491. */
  19492. physicsJoint: any;
  19493. /**
  19494. * Sets the physics plugin
  19495. */
  19496. physicsPlugin: IPhysicsEnginePlugin;
  19497. /**
  19498. * Execute a function that is physics-plugin specific.
  19499. * @param {Function} func the function that will be executed.
  19500. * It accepts two parameters: the physics world and the physics joint
  19501. */
  19502. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19503. /**
  19504. * Distance-Joint type
  19505. */
  19506. static DistanceJoint: number;
  19507. /**
  19508. * Hinge-Joint type
  19509. */
  19510. static HingeJoint: number;
  19511. /**
  19512. * Ball-and-Socket joint type
  19513. */
  19514. static BallAndSocketJoint: number;
  19515. /**
  19516. * Wheel-Joint type
  19517. */
  19518. static WheelJoint: number;
  19519. /**
  19520. * Slider-Joint type
  19521. */
  19522. static SliderJoint: number;
  19523. /**
  19524. * Prismatic-Joint type
  19525. */
  19526. static PrismaticJoint: number;
  19527. /**
  19528. * Universal-Joint type
  19529. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19530. */
  19531. static UniversalJoint: number;
  19532. /**
  19533. * Hinge-Joint 2 type
  19534. */
  19535. static Hinge2Joint: number;
  19536. /**
  19537. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19538. */
  19539. static PointToPointJoint: number;
  19540. /**
  19541. * Spring-Joint type
  19542. */
  19543. static SpringJoint: number;
  19544. /**
  19545. * Lock-Joint type
  19546. */
  19547. static LockJoint: number;
  19548. }
  19549. /**
  19550. * A class representing a physics distance joint
  19551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19552. */
  19553. export class DistanceJoint extends PhysicsJoint {
  19554. /**
  19555. *
  19556. * @param jointData The data for the Distance-Joint
  19557. */
  19558. constructor(jointData: DistanceJointData);
  19559. /**
  19560. * Update the predefined distance.
  19561. * @param maxDistance The maximum preferred distance
  19562. * @param minDistance The minimum preferred distance
  19563. */
  19564. updateDistance(maxDistance: number, minDistance?: number): void;
  19565. }
  19566. /**
  19567. * Represents a Motor-Enabled Joint
  19568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19569. */
  19570. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19571. /**
  19572. * Initializes the Motor-Enabled Joint
  19573. * @param type The type of the joint
  19574. * @param jointData The physica joint data for the joint
  19575. */
  19576. constructor(type: number, jointData: PhysicsJointData);
  19577. /**
  19578. * Set the motor values.
  19579. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19580. * @param force the force to apply
  19581. * @param maxForce max force for this motor.
  19582. */
  19583. setMotor(force?: number, maxForce?: number): void;
  19584. /**
  19585. * Set the motor's limits.
  19586. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19587. * @param upperLimit The upper limit of the motor
  19588. * @param lowerLimit The lower limit of the motor
  19589. */
  19590. setLimit(upperLimit: number, lowerLimit?: number): void;
  19591. }
  19592. /**
  19593. * This class represents a single physics Hinge-Joint
  19594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19595. */
  19596. export class HingeJoint extends MotorEnabledJoint {
  19597. /**
  19598. * Initializes the Hinge-Joint
  19599. * @param jointData The joint data for the Hinge-Joint
  19600. */
  19601. constructor(jointData: PhysicsJointData);
  19602. /**
  19603. * Set the motor values.
  19604. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19605. * @param {number} force the force to apply
  19606. * @param {number} maxForce max force for this motor.
  19607. */
  19608. setMotor(force?: number, maxForce?: number): void;
  19609. /**
  19610. * Set the motor's limits.
  19611. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19612. * @param upperLimit The upper limit of the motor
  19613. * @param lowerLimit The lower limit of the motor
  19614. */
  19615. setLimit(upperLimit: number, lowerLimit?: number): void;
  19616. }
  19617. /**
  19618. * This class represents a dual hinge physics joint (same as wheel joint)
  19619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19620. */
  19621. export class Hinge2Joint extends MotorEnabledJoint {
  19622. /**
  19623. * Initializes the Hinge2-Joint
  19624. * @param jointData The joint data for the Hinge2-Joint
  19625. */
  19626. constructor(jointData: PhysicsJointData);
  19627. /**
  19628. * Set the motor values.
  19629. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19630. * @param {number} targetSpeed the speed the motor is to reach
  19631. * @param {number} maxForce max force for this motor.
  19632. * @param {motorIndex} the motor's index, 0 or 1.
  19633. */
  19634. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19635. /**
  19636. * Set the motor limits.
  19637. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19638. * @param {number} upperLimit the upper limit
  19639. * @param {number} lowerLimit lower limit
  19640. * @param {motorIndex} the motor's index, 0 or 1.
  19641. */
  19642. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19643. }
  19644. /**
  19645. * Interface for a motor enabled joint
  19646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19647. */
  19648. export interface IMotorEnabledJoint {
  19649. /**
  19650. * Physics joint
  19651. */
  19652. physicsJoint: any;
  19653. /**
  19654. * Sets the motor of the motor-enabled joint
  19655. * @param force The force of the motor
  19656. * @param maxForce The maximum force of the motor
  19657. * @param motorIndex The index of the motor
  19658. */
  19659. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19660. /**
  19661. * Sets the limit of the motor
  19662. * @param upperLimit The upper limit of the motor
  19663. * @param lowerLimit The lower limit of the motor
  19664. * @param motorIndex The index of the motor
  19665. */
  19666. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19667. }
  19668. /**
  19669. * Joint data for a Distance-Joint
  19670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19671. */
  19672. export interface DistanceJointData extends PhysicsJointData {
  19673. /**
  19674. * Max distance the 2 joint objects can be apart
  19675. */
  19676. maxDistance: number;
  19677. }
  19678. /**
  19679. * Joint data from a spring joint
  19680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19681. */
  19682. export interface SpringJointData extends PhysicsJointData {
  19683. /**
  19684. * Length of the spring
  19685. */
  19686. length: number;
  19687. /**
  19688. * Stiffness of the spring
  19689. */
  19690. stiffness: number;
  19691. /**
  19692. * Damping of the spring
  19693. */
  19694. damping: number;
  19695. /** this callback will be called when applying the force to the impostors. */
  19696. forceApplicationCallback: () => void;
  19697. }
  19698. }
  19699. declare module "babylonjs/Physics/IPhysicsEngine" {
  19700. import { Nullable } from "babylonjs/types";
  19701. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19703. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19704. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19705. /**
  19706. * Interface used to describe a physics joint
  19707. */
  19708. export interface PhysicsImpostorJoint {
  19709. /** Defines the main impostor to which the joint is linked */
  19710. mainImpostor: PhysicsImpostor;
  19711. /** Defines the impostor that is connected to the main impostor using this joint */
  19712. connectedImpostor: PhysicsImpostor;
  19713. /** Defines the joint itself */
  19714. joint: PhysicsJoint;
  19715. }
  19716. /** @hidden */
  19717. export interface IPhysicsEnginePlugin {
  19718. world: any;
  19719. name: string;
  19720. setGravity(gravity: Vector3): void;
  19721. setTimeStep(timeStep: number): void;
  19722. getTimeStep(): number;
  19723. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19724. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19725. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19726. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19727. removePhysicsBody(impostor: PhysicsImpostor): void;
  19728. generateJoint(joint: PhysicsImpostorJoint): void;
  19729. removeJoint(joint: PhysicsImpostorJoint): void;
  19730. isSupported(): boolean;
  19731. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19732. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19733. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19734. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19735. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19736. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19737. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19738. getBodyMass(impostor: PhysicsImpostor): number;
  19739. getBodyFriction(impostor: PhysicsImpostor): number;
  19740. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19741. getBodyRestitution(impostor: PhysicsImpostor): number;
  19742. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19743. sleepBody(impostor: PhysicsImpostor): void;
  19744. wakeUpBody(impostor: PhysicsImpostor): void;
  19745. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19746. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19747. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19748. getRadius(impostor: PhysicsImpostor): number;
  19749. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19750. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19751. dispose(): void;
  19752. }
  19753. /**
  19754. * Interface used to define a physics engine
  19755. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19756. */
  19757. export interface IPhysicsEngine {
  19758. /**
  19759. * Gets the gravity vector used by the simulation
  19760. */
  19761. gravity: Vector3;
  19762. /**
  19763. * Sets the gravity vector used by the simulation
  19764. * @param gravity defines the gravity vector to use
  19765. */
  19766. setGravity(gravity: Vector3): void;
  19767. /**
  19768. * Set the time step of the physics engine.
  19769. * Default is 1/60.
  19770. * To slow it down, enter 1/600 for example.
  19771. * To speed it up, 1/30
  19772. * @param newTimeStep the new timestep to apply to this world.
  19773. */
  19774. setTimeStep(newTimeStep: number): void;
  19775. /**
  19776. * Get the time step of the physics engine.
  19777. * @returns the current time step
  19778. */
  19779. getTimeStep(): number;
  19780. /**
  19781. * Release all resources
  19782. */
  19783. dispose(): void;
  19784. /**
  19785. * Gets the name of the current physics plugin
  19786. * @returns the name of the plugin
  19787. */
  19788. getPhysicsPluginName(): string;
  19789. /**
  19790. * Adding a new impostor for the impostor tracking.
  19791. * This will be done by the impostor itself.
  19792. * @param impostor the impostor to add
  19793. */
  19794. addImpostor(impostor: PhysicsImpostor): void;
  19795. /**
  19796. * Remove an impostor from the engine.
  19797. * This impostor and its mesh will not longer be updated by the physics engine.
  19798. * @param impostor the impostor to remove
  19799. */
  19800. removeImpostor(impostor: PhysicsImpostor): void;
  19801. /**
  19802. * Add a joint to the physics engine
  19803. * @param mainImpostor defines the main impostor to which the joint is added.
  19804. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19805. * @param joint defines the joint that will connect both impostors.
  19806. */
  19807. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19808. /**
  19809. * Removes a joint from the simulation
  19810. * @param mainImpostor defines the impostor used with the joint
  19811. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19812. * @param joint defines the joint to remove
  19813. */
  19814. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19815. /**
  19816. * Gets the current plugin used to run the simulation
  19817. * @returns current plugin
  19818. */
  19819. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19820. /**
  19821. * Gets the list of physic impostors
  19822. * @returns an array of PhysicsImpostor
  19823. */
  19824. getImpostors(): Array<PhysicsImpostor>;
  19825. /**
  19826. * Gets the impostor for a physics enabled object
  19827. * @param object defines the object impersonated by the impostor
  19828. * @returns the PhysicsImpostor or null if not found
  19829. */
  19830. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19831. /**
  19832. * Gets the impostor for a physics body object
  19833. * @param body defines physics body used by the impostor
  19834. * @returns the PhysicsImpostor or null if not found
  19835. */
  19836. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19837. /**
  19838. * Called by the scene. No need to call it.
  19839. * @param delta defines the timespam between frames
  19840. */
  19841. _step(delta: number): void;
  19842. }
  19843. }
  19844. declare module "babylonjs/Physics/physicsImpostor" {
  19845. import { Nullable, IndicesArray } from "babylonjs/types";
  19846. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  19847. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19848. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19849. import { Scene } from "babylonjs/scene";
  19850. import { Bone } from "babylonjs/Bones/bone";
  19851. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  19852. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  19853. /**
  19854. * The interface for the physics imposter parameters
  19855. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19856. */
  19857. export interface PhysicsImpostorParameters {
  19858. /**
  19859. * The mass of the physics imposter
  19860. */
  19861. mass: number;
  19862. /**
  19863. * The friction of the physics imposter
  19864. */
  19865. friction?: number;
  19866. /**
  19867. * The coefficient of restitution of the physics imposter
  19868. */
  19869. restitution?: number;
  19870. /**
  19871. * The native options of the physics imposter
  19872. */
  19873. nativeOptions?: any;
  19874. /**
  19875. * Specifies if the parent should be ignored
  19876. */
  19877. ignoreParent?: boolean;
  19878. /**
  19879. * Specifies if bi-directional transformations should be disabled
  19880. */
  19881. disableBidirectionalTransformation?: boolean;
  19882. }
  19883. /**
  19884. * Interface for a physics-enabled object
  19885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19886. */
  19887. export interface IPhysicsEnabledObject {
  19888. /**
  19889. * The position of the physics-enabled object
  19890. */
  19891. position: Vector3;
  19892. /**
  19893. * The rotation of the physics-enabled object
  19894. */
  19895. rotationQuaternion: Nullable<Quaternion>;
  19896. /**
  19897. * The scale of the physics-enabled object
  19898. */
  19899. scaling: Vector3;
  19900. /**
  19901. * The rotation of the physics-enabled object
  19902. */
  19903. rotation?: Vector3;
  19904. /**
  19905. * The parent of the physics-enabled object
  19906. */
  19907. parent?: any;
  19908. /**
  19909. * The bounding info of the physics-enabled object
  19910. * @returns The bounding info of the physics-enabled object
  19911. */
  19912. getBoundingInfo(): BoundingInfo;
  19913. /**
  19914. * Computes the world matrix
  19915. * @param force Specifies if the world matrix should be computed by force
  19916. * @returns A world matrix
  19917. */
  19918. computeWorldMatrix(force: boolean): Matrix;
  19919. /**
  19920. * Gets the world matrix
  19921. * @returns A world matrix
  19922. */
  19923. getWorldMatrix?(): Matrix;
  19924. /**
  19925. * Gets the child meshes
  19926. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19927. * @returns An array of abstract meshes
  19928. */
  19929. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19930. /**
  19931. * Gets the vertex data
  19932. * @param kind The type of vertex data
  19933. * @returns A nullable array of numbers, or a float32 array
  19934. */
  19935. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19936. /**
  19937. * Gets the indices from the mesh
  19938. * @returns A nullable array of index arrays
  19939. */
  19940. getIndices?(): Nullable<IndicesArray>;
  19941. /**
  19942. * Gets the scene from the mesh
  19943. * @returns the indices array or null
  19944. */
  19945. getScene?(): Scene;
  19946. /**
  19947. * Gets the absolute position from the mesh
  19948. * @returns the absolute position
  19949. */
  19950. getAbsolutePosition(): Vector3;
  19951. /**
  19952. * Gets the absolute pivot point from the mesh
  19953. * @returns the absolute pivot point
  19954. */
  19955. getAbsolutePivotPoint(): Vector3;
  19956. /**
  19957. * Rotates the mesh
  19958. * @param axis The axis of rotation
  19959. * @param amount The amount of rotation
  19960. * @param space The space of the rotation
  19961. * @returns The rotation transform node
  19962. */
  19963. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19964. /**
  19965. * Translates the mesh
  19966. * @param axis The axis of translation
  19967. * @param distance The distance of translation
  19968. * @param space The space of the translation
  19969. * @returns The transform node
  19970. */
  19971. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19972. /**
  19973. * Sets the absolute position of the mesh
  19974. * @param absolutePosition The absolute position of the mesh
  19975. * @returns The transform node
  19976. */
  19977. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19978. /**
  19979. * Gets the class name of the mesh
  19980. * @returns The class name
  19981. */
  19982. getClassName(): string;
  19983. }
  19984. /**
  19985. * Represents a physics imposter
  19986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19987. */
  19988. export class PhysicsImpostor {
  19989. /**
  19990. * The physics-enabled object used as the physics imposter
  19991. */
  19992. object: IPhysicsEnabledObject;
  19993. /**
  19994. * The type of the physics imposter
  19995. */
  19996. type: number;
  19997. private _options;
  19998. private _scene?;
  19999. /**
  20000. * The default object size of the imposter
  20001. */
  20002. static DEFAULT_OBJECT_SIZE: Vector3;
  20003. /**
  20004. * The identity quaternion of the imposter
  20005. */
  20006. static IDENTITY_QUATERNION: Quaternion;
  20007. /** @hidden */
  20008. _pluginData: any;
  20009. private _physicsEngine;
  20010. private _physicsBody;
  20011. private _bodyUpdateRequired;
  20012. private _onBeforePhysicsStepCallbacks;
  20013. private _onAfterPhysicsStepCallbacks;
  20014. /** @hidden */
  20015. _onPhysicsCollideCallbacks: Array<{
  20016. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20017. otherImpostors: Array<PhysicsImpostor>;
  20018. }>;
  20019. private _deltaPosition;
  20020. private _deltaRotation;
  20021. private _deltaRotationConjugated;
  20022. private _parent;
  20023. private _isDisposed;
  20024. private static _tmpVecs;
  20025. private static _tmpQuat;
  20026. /**
  20027. * Specifies if the physics imposter is disposed
  20028. */
  20029. readonly isDisposed: boolean;
  20030. /**
  20031. * Gets the mass of the physics imposter
  20032. */
  20033. mass: number;
  20034. /**
  20035. * Gets the coefficient of friction
  20036. */
  20037. /**
  20038. * Sets the coefficient of friction
  20039. */
  20040. friction: number;
  20041. /**
  20042. * Gets the coefficient of restitution
  20043. */
  20044. /**
  20045. * Sets the coefficient of restitution
  20046. */
  20047. restitution: number;
  20048. /**
  20049. * The unique id of the physics imposter
  20050. * set by the physics engine when adding this impostor to the array
  20051. */
  20052. uniqueId: number;
  20053. private _joints;
  20054. /**
  20055. * Initializes the physics imposter
  20056. * @param object The physics-enabled object used as the physics imposter
  20057. * @param type The type of the physics imposter
  20058. * @param _options The options for the physics imposter
  20059. * @param _scene The Babylon scene
  20060. */
  20061. constructor(
  20062. /**
  20063. * The physics-enabled object used as the physics imposter
  20064. */
  20065. object: IPhysicsEnabledObject,
  20066. /**
  20067. * The type of the physics imposter
  20068. */
  20069. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20070. /**
  20071. * This function will completly initialize this impostor.
  20072. * It will create a new body - but only if this mesh has no parent.
  20073. * If it has, this impostor will not be used other than to define the impostor
  20074. * of the child mesh.
  20075. * @hidden
  20076. */
  20077. _init(): void;
  20078. private _getPhysicsParent;
  20079. /**
  20080. * Should a new body be generated.
  20081. * @returns boolean specifying if body initialization is required
  20082. */
  20083. isBodyInitRequired(): boolean;
  20084. /**
  20085. * Sets the updated scaling
  20086. * @param updated Specifies if the scaling is updated
  20087. */
  20088. setScalingUpdated(): void;
  20089. /**
  20090. * Force a regeneration of this or the parent's impostor's body.
  20091. * Use under cautious - This will remove all joints already implemented.
  20092. */
  20093. forceUpdate(): void;
  20094. /**
  20095. * Gets the body that holds this impostor. Either its own, or its parent.
  20096. */
  20097. /**
  20098. * Set the physics body. Used mainly by the physics engine/plugin
  20099. */
  20100. physicsBody: any;
  20101. /**
  20102. * Get the parent of the physics imposter
  20103. * @returns Physics imposter or null
  20104. */
  20105. /**
  20106. * Sets the parent of the physics imposter
  20107. */
  20108. parent: Nullable<PhysicsImpostor>;
  20109. /**
  20110. * Resets the update flags
  20111. */
  20112. resetUpdateFlags(): void;
  20113. /**
  20114. * Gets the object extend size
  20115. * @returns the object extend size
  20116. */
  20117. getObjectExtendSize(): Vector3;
  20118. /**
  20119. * Gets the object center
  20120. * @returns The object center
  20121. */
  20122. getObjectCenter(): Vector3;
  20123. /**
  20124. * Get a specific parametes from the options parameter
  20125. * @param paramName The object parameter name
  20126. * @returns The object parameter
  20127. */
  20128. getParam(paramName: string): any;
  20129. /**
  20130. * Sets a specific parameter in the options given to the physics plugin
  20131. * @param paramName The parameter name
  20132. * @param value The value of the parameter
  20133. */
  20134. setParam(paramName: string, value: number): void;
  20135. /**
  20136. * Specifically change the body's mass option. Won't recreate the physics body object
  20137. * @param mass The mass of the physics imposter
  20138. */
  20139. setMass(mass: number): void;
  20140. /**
  20141. * Gets the linear velocity
  20142. * @returns linear velocity or null
  20143. */
  20144. getLinearVelocity(): Nullable<Vector3>;
  20145. /**
  20146. * Sets the linear velocity
  20147. * @param velocity linear velocity or null
  20148. */
  20149. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20150. /**
  20151. * Gets the angular velocity
  20152. * @returns angular velocity or null
  20153. */
  20154. getAngularVelocity(): Nullable<Vector3>;
  20155. /**
  20156. * Sets the angular velocity
  20157. * @param velocity The velocity or null
  20158. */
  20159. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20160. /**
  20161. * Execute a function with the physics plugin native code
  20162. * Provide a function the will have two variables - the world object and the physics body object
  20163. * @param func The function to execute with the physics plugin native code
  20164. */
  20165. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20166. /**
  20167. * Register a function that will be executed before the physics world is stepping forward
  20168. * @param func The function to execute before the physics world is stepped forward
  20169. */
  20170. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20171. /**
  20172. * Unregister a function that will be executed before the physics world is stepping forward
  20173. * @param func The function to execute before the physics world is stepped forward
  20174. */
  20175. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20176. /**
  20177. * Register a function that will be executed after the physics step
  20178. * @param func The function to execute after physics step
  20179. */
  20180. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20181. /**
  20182. * Unregisters a function that will be executed after the physics step
  20183. * @param func The function to execute after physics step
  20184. */
  20185. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20186. /**
  20187. * register a function that will be executed when this impostor collides against a different body
  20188. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20189. * @param func Callback that is executed on collision
  20190. */
  20191. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20192. /**
  20193. * Unregisters the physics imposter on contact
  20194. * @param collideAgainst The physics object to collide against
  20195. * @param func Callback to execute on collision
  20196. */
  20197. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20198. private _tmpQuat;
  20199. private _tmpQuat2;
  20200. /**
  20201. * Get the parent rotation
  20202. * @returns The parent rotation
  20203. */
  20204. getParentsRotation(): Quaternion;
  20205. /**
  20206. * this function is executed by the physics engine.
  20207. */
  20208. beforeStep: () => void;
  20209. /**
  20210. * this function is executed by the physics engine
  20211. */
  20212. afterStep: () => void;
  20213. /**
  20214. * Legacy collision detection event support
  20215. */
  20216. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20217. /**
  20218. * event and body object due to cannon's event-based architecture.
  20219. */
  20220. onCollide: (e: {
  20221. body: any;
  20222. }) => void;
  20223. /**
  20224. * Apply a force
  20225. * @param force The force to apply
  20226. * @param contactPoint The contact point for the force
  20227. * @returns The physics imposter
  20228. */
  20229. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20230. /**
  20231. * Apply an impulse
  20232. * @param force The impulse force
  20233. * @param contactPoint The contact point for the impulse force
  20234. * @returns The physics imposter
  20235. */
  20236. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20237. /**
  20238. * A help function to create a joint
  20239. * @param otherImpostor A physics imposter used to create a joint
  20240. * @param jointType The type of joint
  20241. * @param jointData The data for the joint
  20242. * @returns The physics imposter
  20243. */
  20244. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20245. /**
  20246. * Add a joint to this impostor with a different impostor
  20247. * @param otherImpostor A physics imposter used to add a joint
  20248. * @param joint The joint to add
  20249. * @returns The physics imposter
  20250. */
  20251. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20252. /**
  20253. * Will keep this body still, in a sleep mode.
  20254. * @returns the physics imposter
  20255. */
  20256. sleep(): PhysicsImpostor;
  20257. /**
  20258. * Wake the body up.
  20259. * @returns The physics imposter
  20260. */
  20261. wakeUp(): PhysicsImpostor;
  20262. /**
  20263. * Clones the physics imposter
  20264. * @param newObject The physics imposter clones to this physics-enabled object
  20265. * @returns A nullable physics imposter
  20266. */
  20267. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20268. /**
  20269. * Disposes the physics imposter
  20270. */
  20271. dispose(): void;
  20272. /**
  20273. * Sets the delta position
  20274. * @param position The delta position amount
  20275. */
  20276. setDeltaPosition(position: Vector3): void;
  20277. /**
  20278. * Sets the delta rotation
  20279. * @param rotation The delta rotation amount
  20280. */
  20281. setDeltaRotation(rotation: Quaternion): void;
  20282. /**
  20283. * Gets the box size of the physics imposter and stores the result in the input parameter
  20284. * @param result Stores the box size
  20285. * @returns The physics imposter
  20286. */
  20287. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20288. /**
  20289. * Gets the radius of the physics imposter
  20290. * @returns Radius of the physics imposter
  20291. */
  20292. getRadius(): number;
  20293. /**
  20294. * Sync a bone with this impostor
  20295. * @param bone The bone to sync to the impostor.
  20296. * @param boneMesh The mesh that the bone is influencing.
  20297. * @param jointPivot The pivot of the joint / bone in local space.
  20298. * @param distToJoint Optional distance from the impostor to the joint.
  20299. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20300. */
  20301. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20302. /**
  20303. * Sync impostor to a bone
  20304. * @param bone The bone that the impostor will be synced to.
  20305. * @param boneMesh The mesh that the bone is influencing.
  20306. * @param jointPivot The pivot of the joint / bone in local space.
  20307. * @param distToJoint Optional distance from the impostor to the joint.
  20308. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20309. * @param boneAxis Optional vector3 axis the bone is aligned with
  20310. */
  20311. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20312. /**
  20313. * No-Imposter type
  20314. */
  20315. static NoImpostor: number;
  20316. /**
  20317. * Sphere-Imposter type
  20318. */
  20319. static SphereImpostor: number;
  20320. /**
  20321. * Box-Imposter type
  20322. */
  20323. static BoxImpostor: number;
  20324. /**
  20325. * Plane-Imposter type
  20326. */
  20327. static PlaneImpostor: number;
  20328. /**
  20329. * Mesh-imposter type
  20330. */
  20331. static MeshImpostor: number;
  20332. /**
  20333. * Cylinder-Imposter type
  20334. */
  20335. static CylinderImpostor: number;
  20336. /**
  20337. * Particle-Imposter type
  20338. */
  20339. static ParticleImpostor: number;
  20340. /**
  20341. * Heightmap-Imposter type
  20342. */
  20343. static HeightmapImpostor: number;
  20344. }
  20345. }
  20346. declare module "babylonjs/Meshes/mesh" {
  20347. import { Observable } from "babylonjs/Misc/observable";
  20348. import { IAnimatable } from "babylonjs/Misc/tools";
  20349. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20350. import { Camera } from "babylonjs/Cameras/camera";
  20351. import { Scene } from "babylonjs/scene";
  20352. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20353. import { Engine } from "babylonjs/Engines/engine";
  20354. import { Node } from "babylonjs/node";
  20355. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20356. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20357. import { Buffer } from "babylonjs/Meshes/buffer";
  20358. import { Geometry } from "babylonjs/Meshes/geometry";
  20359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20360. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20361. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20362. import { Effect } from "babylonjs/Materials/effect";
  20363. import { Material } from "babylonjs/Materials/material";
  20364. import { Skeleton } from "babylonjs/Bones/skeleton";
  20365. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20366. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20367. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20368. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20369. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20370. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20371. /**
  20372. * Class used to represent a specific level of detail of a mesh
  20373. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20374. */
  20375. export class MeshLODLevel {
  20376. /** Defines the distance where this level should star being displayed */
  20377. distance: number;
  20378. /** Defines the mesh to use to render this level */
  20379. mesh: Nullable<Mesh>;
  20380. /**
  20381. * Creates a new LOD level
  20382. * @param distance defines the distance where this level should star being displayed
  20383. * @param mesh defines the mesh to use to render this level
  20384. */
  20385. constructor(
  20386. /** Defines the distance where this level should star being displayed */
  20387. distance: number,
  20388. /** Defines the mesh to use to render this level */
  20389. mesh: Nullable<Mesh>);
  20390. }
  20391. /**
  20392. * @hidden
  20393. **/
  20394. export class _CreationDataStorage {
  20395. closePath?: boolean;
  20396. closeArray?: boolean;
  20397. idx: number[];
  20398. dashSize: number;
  20399. gapSize: number;
  20400. path3D: Path3D;
  20401. pathArray: Vector3[][];
  20402. arc: number;
  20403. radius: number;
  20404. cap: number;
  20405. tessellation: number;
  20406. }
  20407. /**
  20408. * @hidden
  20409. **/
  20410. class _InstanceDataStorage {
  20411. visibleInstances: any;
  20412. renderIdForInstances: number[];
  20413. batchCache: _InstancesBatch;
  20414. instancesBufferSize: number;
  20415. instancesBuffer: Nullable<Buffer>;
  20416. instancesData: Float32Array;
  20417. overridenInstanceCount: number;
  20418. }
  20419. /**
  20420. * @hidden
  20421. **/
  20422. export class _InstancesBatch {
  20423. mustReturn: boolean;
  20424. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20425. renderSelf: boolean[];
  20426. }
  20427. /**
  20428. * Class used to represent renderable models
  20429. */
  20430. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20431. /**
  20432. * Mesh side orientation : usually the external or front surface
  20433. */
  20434. static readonly FRONTSIDE: number;
  20435. /**
  20436. * Mesh side orientation : usually the internal or back surface
  20437. */
  20438. static readonly BACKSIDE: number;
  20439. /**
  20440. * Mesh side orientation : both internal and external or front and back surfaces
  20441. */
  20442. static readonly DOUBLESIDE: number;
  20443. /**
  20444. * Mesh side orientation : by default, `FRONTSIDE`
  20445. */
  20446. static readonly DEFAULTSIDE: number;
  20447. /**
  20448. * Mesh cap setting : no cap
  20449. */
  20450. static readonly NO_CAP: number;
  20451. /**
  20452. * Mesh cap setting : one cap at the beginning of the mesh
  20453. */
  20454. static readonly CAP_START: number;
  20455. /**
  20456. * Mesh cap setting : one cap at the end of the mesh
  20457. */
  20458. static readonly CAP_END: number;
  20459. /**
  20460. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20461. */
  20462. static readonly CAP_ALL: number;
  20463. /**
  20464. * Gets the default side orientation.
  20465. * @param orientation the orientation to value to attempt to get
  20466. * @returns the default orientation
  20467. * @hidden
  20468. */
  20469. static _GetDefaultSideOrientation(orientation?: number): number;
  20470. private _onBeforeRenderObservable;
  20471. private _onBeforeBindObservable;
  20472. private _onAfterRenderObservable;
  20473. private _onBeforeDrawObservable;
  20474. /**
  20475. * An event triggered before rendering the mesh
  20476. */
  20477. readonly onBeforeRenderObservable: Observable<Mesh>;
  20478. /**
  20479. * An event triggered before binding the mesh
  20480. */
  20481. readonly onBeforeBindObservable: Observable<Mesh>;
  20482. /**
  20483. * An event triggered after rendering the mesh
  20484. */
  20485. readonly onAfterRenderObservable: Observable<Mesh>;
  20486. /**
  20487. * An event triggered before drawing the mesh
  20488. */
  20489. readonly onBeforeDrawObservable: Observable<Mesh>;
  20490. private _onBeforeDrawObserver;
  20491. /**
  20492. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20493. */
  20494. onBeforeDraw: () => void;
  20495. /**
  20496. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20497. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20498. */
  20499. delayLoadState: number;
  20500. /**
  20501. * Gets the list of instances created from this mesh
  20502. * it is not supposed to be modified manually.
  20503. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20504. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20505. */
  20506. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20507. /**
  20508. * Gets the file containing delay loading data for this mesh
  20509. */
  20510. delayLoadingFile: string;
  20511. /** @hidden */
  20512. _binaryInfo: any;
  20513. private _LODLevels;
  20514. /**
  20515. * User defined function used to change how LOD level selection is done
  20516. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20517. */
  20518. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20519. private _morphTargetManager;
  20520. /**
  20521. * Gets or sets the morph target manager
  20522. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20523. */
  20524. morphTargetManager: Nullable<MorphTargetManager>;
  20525. /** @hidden */
  20526. _creationDataStorage: Nullable<_CreationDataStorage>;
  20527. /** @hidden */
  20528. _geometry: Nullable<Geometry>;
  20529. /** @hidden */
  20530. _delayInfo: Array<string>;
  20531. /** @hidden */
  20532. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20533. /** @hidden */
  20534. _instanceDataStorage: _InstanceDataStorage;
  20535. private _effectiveMaterial;
  20536. /** @hidden */
  20537. _shouldGenerateFlatShading: boolean;
  20538. private _preActivateId;
  20539. /** @hidden */
  20540. _originalBuilderSideOrientation: number;
  20541. /**
  20542. * Use this property to change the original side orientation defined at construction time
  20543. */
  20544. overrideMaterialSideOrientation: Nullable<number>;
  20545. private _areNormalsFrozen;
  20546. private _sourcePositions;
  20547. private _sourceNormals;
  20548. private _source;
  20549. private meshMap;
  20550. /**
  20551. * Gets the source mesh (the one used to clone this one from)
  20552. */
  20553. readonly source: Nullable<Mesh>;
  20554. /**
  20555. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20556. */
  20557. isUnIndexed: boolean;
  20558. /**
  20559. * @constructor
  20560. * @param name The value used by scene.getMeshByName() to do a lookup.
  20561. * @param scene The scene to add this mesh to.
  20562. * @param parent The parent of this mesh, if it has one
  20563. * @param source An optional Mesh from which geometry is shared, cloned.
  20564. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20565. * When false, achieved by calling a clone(), also passing False.
  20566. * This will make creation of children, recursive.
  20567. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20568. */
  20569. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20570. /**
  20571. * Gets the class name
  20572. * @returns the string "Mesh".
  20573. */
  20574. getClassName(): string;
  20575. /** @hidden */
  20576. readonly _isMesh: boolean;
  20577. /**
  20578. * Returns a description of this mesh
  20579. * @param fullDetails define if full details about this mesh must be used
  20580. * @returns a descriptive string representing this mesh
  20581. */
  20582. toString(fullDetails?: boolean): string;
  20583. /** @hidden */
  20584. _unBindEffect(): void;
  20585. /**
  20586. * Gets a boolean indicating if this mesh has LOD
  20587. */
  20588. readonly hasLODLevels: boolean;
  20589. /**
  20590. * Gets the list of MeshLODLevel associated with the current mesh
  20591. * @returns an array of MeshLODLevel
  20592. */
  20593. getLODLevels(): MeshLODLevel[];
  20594. private _sortLODLevels;
  20595. /**
  20596. * Add a mesh as LOD level triggered at the given distance.
  20597. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20598. * @param distance The distance from the center of the object to show this level
  20599. * @param mesh The mesh to be added as LOD level (can be null)
  20600. * @return This mesh (for chaining)
  20601. */
  20602. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20603. /**
  20604. * Returns the LOD level mesh at the passed distance or null if not found.
  20605. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20606. * @param distance The distance from the center of the object to show this level
  20607. * @returns a Mesh or `null`
  20608. */
  20609. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20610. /**
  20611. * Remove a mesh from the LOD array
  20612. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20613. * @param mesh defines the mesh to be removed
  20614. * @return This mesh (for chaining)
  20615. */
  20616. removeLODLevel(mesh: Mesh): Mesh;
  20617. /**
  20618. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20619. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20620. * @param camera defines the camera to use to compute distance
  20621. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20622. * @return This mesh (for chaining)
  20623. */
  20624. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20625. /**
  20626. * Gets the mesh internal Geometry object
  20627. */
  20628. readonly geometry: Nullable<Geometry>;
  20629. /**
  20630. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20631. * @returns the total number of vertices
  20632. */
  20633. getTotalVertices(): number;
  20634. /**
  20635. * Returns the content of an associated vertex buffer
  20636. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20637. * - VertexBuffer.PositionKind
  20638. * - VertexBuffer.UVKind
  20639. * - VertexBuffer.UV2Kind
  20640. * - VertexBuffer.UV3Kind
  20641. * - VertexBuffer.UV4Kind
  20642. * - VertexBuffer.UV5Kind
  20643. * - VertexBuffer.UV6Kind
  20644. * - VertexBuffer.ColorKind
  20645. * - VertexBuffer.MatricesIndicesKind
  20646. * - VertexBuffer.MatricesIndicesExtraKind
  20647. * - VertexBuffer.MatricesWeightsKind
  20648. * - VertexBuffer.MatricesWeightsExtraKind
  20649. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  20650. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20651. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20652. */
  20653. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20654. /**
  20655. * Returns the mesh VertexBuffer object from the requested `kind`
  20656. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20657. * - VertexBuffer.PositionKind
  20658. * - VertexBuffer.UVKind
  20659. * - VertexBuffer.UV2Kind
  20660. * - VertexBuffer.UV3Kind
  20661. * - VertexBuffer.UV4Kind
  20662. * - VertexBuffer.UV5Kind
  20663. * - VertexBuffer.UV6Kind
  20664. * - VertexBuffer.ColorKind
  20665. * - VertexBuffer.MatricesIndicesKind
  20666. * - VertexBuffer.MatricesIndicesExtraKind
  20667. * - VertexBuffer.MatricesWeightsKind
  20668. * - VertexBuffer.MatricesWeightsExtraKind
  20669. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20670. */
  20671. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20672. /**
  20673. * Tests if a specific vertex buffer is associated with this mesh
  20674. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20675. * - VertexBuffer.PositionKind
  20676. * - VertexBuffer.UVKind
  20677. * - VertexBuffer.UV2Kind
  20678. * - VertexBuffer.UV3Kind
  20679. * - VertexBuffer.UV4Kind
  20680. * - VertexBuffer.UV5Kind
  20681. * - VertexBuffer.UV6Kind
  20682. * - VertexBuffer.ColorKind
  20683. * - VertexBuffer.MatricesIndicesKind
  20684. * - VertexBuffer.MatricesIndicesExtraKind
  20685. * - VertexBuffer.MatricesWeightsKind
  20686. * - VertexBuffer.MatricesWeightsExtraKind
  20687. * @returns a boolean
  20688. */
  20689. isVerticesDataPresent(kind: string): boolean;
  20690. /**
  20691. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20692. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20693. * - VertexBuffer.PositionKind
  20694. * - VertexBuffer.UVKind
  20695. * - VertexBuffer.UV2Kind
  20696. * - VertexBuffer.UV3Kind
  20697. * - VertexBuffer.UV4Kind
  20698. * - VertexBuffer.UV5Kind
  20699. * - VertexBuffer.UV6Kind
  20700. * - VertexBuffer.ColorKind
  20701. * - VertexBuffer.MatricesIndicesKind
  20702. * - VertexBuffer.MatricesIndicesExtraKind
  20703. * - VertexBuffer.MatricesWeightsKind
  20704. * - VertexBuffer.MatricesWeightsExtraKind
  20705. * @returns a boolean
  20706. */
  20707. isVertexBufferUpdatable(kind: string): boolean;
  20708. /**
  20709. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20710. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20711. * - VertexBuffer.PositionKind
  20712. * - VertexBuffer.UVKind
  20713. * - VertexBuffer.UV2Kind
  20714. * - VertexBuffer.UV3Kind
  20715. * - VertexBuffer.UV4Kind
  20716. * - VertexBuffer.UV5Kind
  20717. * - VertexBuffer.UV6Kind
  20718. * - VertexBuffer.ColorKind
  20719. * - VertexBuffer.MatricesIndicesKind
  20720. * - VertexBuffer.MatricesIndicesExtraKind
  20721. * - VertexBuffer.MatricesWeightsKind
  20722. * - VertexBuffer.MatricesWeightsExtraKind
  20723. * @returns an array of strings
  20724. */
  20725. getVerticesDataKinds(): string[];
  20726. /**
  20727. * Returns a positive integer : the total number of indices in this mesh geometry.
  20728. * @returns the numner of indices or zero if the mesh has no geometry.
  20729. */
  20730. getTotalIndices(): number;
  20731. /**
  20732. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20733. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  20734. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20735. * @returns the indices array or an empty array if the mesh has no geometry
  20736. */
  20737. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20738. readonly isBlocked: boolean;
  20739. /**
  20740. * Determine if the current mesh is ready to be rendered
  20741. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20742. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20743. * @returns true if all associated assets are ready (material, textures, shaders)
  20744. */
  20745. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20746. /**
  20747. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  20748. */
  20749. readonly areNormalsFrozen: boolean;
  20750. /**
  20751. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  20752. * @returns the current mesh
  20753. */
  20754. freezeNormals(): Mesh;
  20755. /**
  20756. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  20757. * @returns the current mesh
  20758. */
  20759. unfreezeNormals(): Mesh;
  20760. /**
  20761. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20762. */
  20763. overridenInstanceCount: number;
  20764. /** @hidden */
  20765. _preActivate(): Mesh;
  20766. /** @hidden */
  20767. _preActivateForIntermediateRendering(renderId: number): Mesh;
  20768. /** @hidden */
  20769. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20770. /**
  20771. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20772. * This means the mesh underlying bounding box and sphere are recomputed.
  20773. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20774. * @returns the current mesh
  20775. */
  20776. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20777. /** @hidden */
  20778. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20779. /**
  20780. * This function will subdivide the mesh into multiple submeshes
  20781. * @param count defines the expected number of submeshes
  20782. */
  20783. subdivide(count: number): void;
  20784. /**
  20785. * Copy a FloatArray into a specific associated vertex buffer
  20786. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20787. * - VertexBuffer.PositionKind
  20788. * - VertexBuffer.UVKind
  20789. * - VertexBuffer.UV2Kind
  20790. * - VertexBuffer.UV3Kind
  20791. * - VertexBuffer.UV4Kind
  20792. * - VertexBuffer.UV5Kind
  20793. * - VertexBuffer.UV6Kind
  20794. * - VertexBuffer.ColorKind
  20795. * - VertexBuffer.MatricesIndicesKind
  20796. * - VertexBuffer.MatricesIndicesExtraKind
  20797. * - VertexBuffer.MatricesWeightsKind
  20798. * - VertexBuffer.MatricesWeightsExtraKind
  20799. * @param data defines the data source
  20800. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20801. * @param stride defines the data stride size (can be null)
  20802. * @returns the current mesh
  20803. */
  20804. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20805. /**
  20806. * Flags an associated vertex buffer as updatable
  20807. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20808. * - VertexBuffer.PositionKind
  20809. * - VertexBuffer.UVKind
  20810. * - VertexBuffer.UV2Kind
  20811. * - VertexBuffer.UV3Kind
  20812. * - VertexBuffer.UV4Kind
  20813. * - VertexBuffer.UV5Kind
  20814. * - VertexBuffer.UV6Kind
  20815. * - VertexBuffer.ColorKind
  20816. * - VertexBuffer.MatricesIndicesKind
  20817. * - VertexBuffer.MatricesIndicesExtraKind
  20818. * - VertexBuffer.MatricesWeightsKind
  20819. * - VertexBuffer.MatricesWeightsExtraKind
  20820. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20821. */
  20822. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20823. /**
  20824. * Sets the mesh global Vertex Buffer
  20825. * @param buffer defines the buffer to use
  20826. * @returns the current mesh
  20827. */
  20828. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20829. /**
  20830. * Update a specific associated vertex buffer
  20831. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20832. * - VertexBuffer.PositionKind
  20833. * - VertexBuffer.UVKind
  20834. * - VertexBuffer.UV2Kind
  20835. * - VertexBuffer.UV3Kind
  20836. * - VertexBuffer.UV4Kind
  20837. * - VertexBuffer.UV5Kind
  20838. * - VertexBuffer.UV6Kind
  20839. * - VertexBuffer.ColorKind
  20840. * - VertexBuffer.MatricesIndicesKind
  20841. * - VertexBuffer.MatricesIndicesExtraKind
  20842. * - VertexBuffer.MatricesWeightsKind
  20843. * - VertexBuffer.MatricesWeightsExtraKind
  20844. * @param data defines the data source
  20845. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20846. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  20847. * @returns the current mesh
  20848. */
  20849. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20850. /**
  20851. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20852. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20853. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20854. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20855. * @returns the current mesh
  20856. */
  20857. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20858. /**
  20859. * Creates a un-shared specific occurence of the geometry for the mesh.
  20860. * @returns the current mesh
  20861. */
  20862. makeGeometryUnique(): Mesh;
  20863. /**
  20864. * Set the index buffer of this mesh
  20865. * @param indices defines the source data
  20866. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20867. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20868. * @returns the current mesh
  20869. */
  20870. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20871. /**
  20872. * Update the current index buffer
  20873. * @param indices defines the source data
  20874. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20875. * @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)
  20876. * @returns the current mesh
  20877. */
  20878. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20879. /**
  20880. * Invert the geometry to move from a right handed system to a left handed one.
  20881. * @returns the current mesh
  20882. */
  20883. toLeftHanded(): Mesh;
  20884. /** @hidden */
  20885. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20886. /** @hidden */
  20887. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  20888. /**
  20889. * Registers for this mesh a javascript function called just before the rendering process
  20890. * @param func defines the function to call before rendering this mesh
  20891. * @returns the current mesh
  20892. */
  20893. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20894. /**
  20895. * Disposes a previously registered javascript function called before the rendering
  20896. * @param func defines the function to remove
  20897. * @returns the current mesh
  20898. */
  20899. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20900. /**
  20901. * Registers for this mesh a javascript function called just after the rendering is complete
  20902. * @param func defines the function to call after rendering this mesh
  20903. * @returns the current mesh
  20904. */
  20905. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20906. /**
  20907. * Disposes a previously registered javascript function called after the rendering.
  20908. * @param func defines the function to remove
  20909. * @returns the current mesh
  20910. */
  20911. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20912. /** @hidden */
  20913. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20914. /** @hidden */
  20915. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20916. /** @hidden */
  20917. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20918. /**
  20919. * 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
  20920. * @param subMesh defines the subMesh to render
  20921. * @param enableAlphaMode defines if alpha mode can be changed
  20922. * @returns the current mesh
  20923. */
  20924. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20925. private _onBeforeDraw;
  20926. /**
  20927. * Renormalize the mesh and patch it up if there are no weights
  20928. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20929. * However in the case of zero weights then we set just a single influence to 1.
  20930. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20931. */
  20932. cleanMatrixWeights(): void;
  20933. private normalizeSkinFourWeights;
  20934. private normalizeSkinWeightsAndExtra;
  20935. /**
  20936. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20937. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20938. * the user know there was an issue with importing the mesh
  20939. * @returns a validation object with skinned, valid and report string
  20940. */
  20941. validateSkinning(): {
  20942. skinned: boolean;
  20943. valid: boolean;
  20944. report: string;
  20945. };
  20946. /** @hidden */
  20947. _checkDelayState(): Mesh;
  20948. private _queueLoad;
  20949. /**
  20950. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20951. * A mesh is in the frustum if its bounding box intersects the frustum
  20952. * @param frustumPlanes defines the frustum to test
  20953. * @returns true if the mesh is in the frustum planes
  20954. */
  20955. isInFrustum(frustumPlanes: Plane[]): boolean;
  20956. /**
  20957. * Sets the mesh material by the material or multiMaterial `id` property
  20958. * @param id is a string identifying the material or the multiMaterial
  20959. * @returns the current mesh
  20960. */
  20961. setMaterialByID(id: string): Mesh;
  20962. /**
  20963. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20964. * @returns an array of IAnimatable
  20965. */
  20966. getAnimatables(): IAnimatable[];
  20967. /**
  20968. * Modifies the mesh geometry according to the passed transformation matrix.
  20969. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20970. * The mesh normals are modified using the same transformation.
  20971. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20972. * @param transform defines the transform matrix to use
  20973. * @see http://doc.babylonjs.com/resources/baking_transformations
  20974. * @returns the current mesh
  20975. */
  20976. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20977. /**
  20978. * Modifies the mesh geometry according to its own current World Matrix.
  20979. * The mesh World Matrix is then reset.
  20980. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20981. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20982. * @see http://doc.babylonjs.com/resources/baking_transformations
  20983. * @returns the current mesh
  20984. */
  20985. bakeCurrentTransformIntoVertices(): Mesh;
  20986. /** @hidden */
  20987. readonly _positions: Nullable<Vector3[]>;
  20988. /** @hidden */
  20989. _resetPointsArrayCache(): Mesh;
  20990. /** @hidden */
  20991. _generatePointsArray(): boolean;
  20992. /**
  20993. * Returns a new Mesh object generated from the current mesh properties.
  20994. * This method must not get confused with createInstance()
  20995. * @param name is a string, the name given to the new mesh
  20996. * @param newParent can be any Node object (default `null`)
  20997. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20998. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20999. * @returns a new mesh
  21000. */
  21001. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21002. /**
  21003. * Releases resources associated with this mesh.
  21004. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21005. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21006. */
  21007. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21008. /**
  21009. * Modifies the mesh geometry according to a displacement map.
  21010. * 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.
  21011. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21012. * @param url is a string, the URL from the image file is to be downloaded.
  21013. * @param minHeight is the lower limit of the displacement.
  21014. * @param maxHeight is the upper limit of the displacement.
  21015. * @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.
  21016. * @param uvOffset is an optional vector2 used to offset UV.
  21017. * @param uvScale is an optional vector2 used to scale UV.
  21018. * @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.
  21019. * @returns the Mesh.
  21020. */
  21021. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21022. /**
  21023. * Modifies the mesh geometry according to a displacementMap buffer.
  21024. * 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.
  21025. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21026. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21027. * @param heightMapWidth is the width of the buffer image.
  21028. * @param heightMapHeight is the height of the buffer image.
  21029. * @param minHeight is the lower limit of the displacement.
  21030. * @param maxHeight is the upper limit of the displacement.
  21031. * @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.
  21032. * @param uvOffset is an optional vector2 used to offset UV.
  21033. * @param uvScale is an optional vector2 used to scale UV.
  21034. * @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.
  21035. * @returns the Mesh.
  21036. */
  21037. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21038. /**
  21039. * Modify the mesh to get a flat shading rendering.
  21040. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21041. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21042. * @returns current mesh
  21043. */
  21044. convertToFlatShadedMesh(): Mesh;
  21045. /**
  21046. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21047. * In other words, more vertices, no more indices and a single bigger VBO.
  21048. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21049. * @returns current mesh
  21050. */
  21051. convertToUnIndexedMesh(): Mesh;
  21052. /**
  21053. * Inverses facet orientations.
  21054. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21055. * @param flipNormals will also inverts the normals
  21056. * @returns current mesh
  21057. */
  21058. flipFaces(flipNormals?: boolean): Mesh;
  21059. /** @hidden */
  21060. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21061. /** @hidden */
  21062. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21063. /**
  21064. * Creates a new InstancedMesh object from the mesh model.
  21065. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21066. * @param name defines the name of the new instance
  21067. * @returns a new InstancedMesh
  21068. */
  21069. createInstance(name: string): InstancedMesh;
  21070. /**
  21071. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21072. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21073. * @returns the current mesh
  21074. */
  21075. synchronizeInstances(): Mesh;
  21076. /**
  21077. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21078. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21079. * This should be used together with the simplification to avoid disappearing triangles.
  21080. * @param successCallback an optional success callback to be called after the optimization finished.
  21081. * @returns the current mesh
  21082. */
  21083. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21084. /**
  21085. * Serialize current mesh
  21086. * @param serializationObject defines the object which will receive the serialization data
  21087. */
  21088. serialize(serializationObject: any): void;
  21089. /** @hidden */
  21090. _syncGeometryWithMorphTargetManager(): void;
  21091. /** @hidden */
  21092. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21093. /**
  21094. * Returns a new Mesh object parsed from the source provided.
  21095. * @param parsedMesh is the source
  21096. * @param scene defines the hosting scene
  21097. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21098. * @returns a new Mesh
  21099. */
  21100. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21101. /**
  21102. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21103. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21104. * @param name defines the name of the mesh to create
  21105. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21106. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21107. * @param closePath creates a seam between the first and the last points of each path of the path array
  21108. * @param offset is taken in account only if the `pathArray` is containing a single path
  21109. * @param scene defines the hosting scene
  21110. * @param updatable defines if the mesh must be flagged as updatable
  21111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21112. * @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)
  21113. * @returns a new Mesh
  21114. */
  21115. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21116. /**
  21117. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21118. * @param name defines the name of the mesh to create
  21119. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21120. * @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
  21121. * @param scene defines the hosting scene
  21122. * @param updatable defines if the mesh must be flagged as updatable
  21123. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21124. * @returns a new Mesh
  21125. */
  21126. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21127. /**
  21128. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21129. * @param name defines the name of the mesh to create
  21130. * @param size sets the size (float) of each box side (default 1)
  21131. * @param scene defines the hosting scene
  21132. * @param updatable defines if the mesh must be flagged as updatable
  21133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21134. * @returns a new Mesh
  21135. */
  21136. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21137. /**
  21138. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21139. * @param name defines the name of the mesh to create
  21140. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21141. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21142. * @param scene defines the hosting scene
  21143. * @param updatable defines if the mesh must be flagged as updatable
  21144. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21145. * @returns a new Mesh
  21146. */
  21147. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21148. /**
  21149. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21150. * @param name defines the name of the mesh to create
  21151. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21152. * @param diameterTop set the top cap diameter (floats, default 1)
  21153. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21154. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21155. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21156. * @param scene defines the hosting scene
  21157. * @param updatable defines if the mesh must be flagged as updatable
  21158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21159. * @returns a new Mesh
  21160. */
  21161. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21162. /**
  21163. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21164. * @param name defines the name of the mesh to create
  21165. * @param diameter sets the diameter size (float) of the torus (default 1)
  21166. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21167. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21168. * @param scene defines the hosting scene
  21169. * @param updatable defines if the mesh must be flagged as updatable
  21170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21171. * @returns a new Mesh
  21172. */
  21173. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21174. /**
  21175. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21176. * @param name defines the name of the mesh to create
  21177. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21178. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21179. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21180. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21181. * @param p the number of windings on X axis (positive integers, default 2)
  21182. * @param q the number of windings on Y axis (positive integers, default 3)
  21183. * @param scene defines the hosting scene
  21184. * @param updatable defines if the mesh must be flagged as updatable
  21185. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21186. * @returns a new Mesh
  21187. */
  21188. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21189. /**
  21190. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21191. * @param name defines the name of the mesh to create
  21192. * @param points is an array successive Vector3
  21193. * @param scene defines the hosting scene
  21194. * @param updatable defines if the mesh must be flagged as updatable
  21195. * @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).
  21196. * @returns a new Mesh
  21197. */
  21198. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21199. /**
  21200. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21201. * @param name defines the name of the mesh to create
  21202. * @param points is an array successive Vector3
  21203. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21204. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21205. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21206. * @param scene defines the hosting scene
  21207. * @param updatable defines if the mesh must be flagged as updatable
  21208. * @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)
  21209. * @returns a new Mesh
  21210. */
  21211. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21212. /**
  21213. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21214. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21215. * 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.
  21216. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21217. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21218. * Remember you can only change the shape positions, not their number when updating a polygon.
  21219. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21220. * @param name defines the name of the mesh to create
  21221. * @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
  21222. * @param scene defines the hosting scene
  21223. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21224. * @param updatable defines if the mesh must be flagged as updatable
  21225. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21226. * @param earcutInjection can be used to inject your own earcut reference
  21227. * @returns a new Mesh
  21228. */
  21229. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21230. /**
  21231. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21232. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21233. * @param name defines the name of the mesh to create
  21234. * @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
  21235. * @param depth defines the height of extrusion
  21236. * @param scene defines the hosting scene
  21237. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21238. * @param updatable defines if the mesh must be flagged as updatable
  21239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21240. * @param earcutInjection can be used to inject your own earcut reference
  21241. * @returns a new Mesh
  21242. */
  21243. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21244. /**
  21245. * Creates an extruded shape mesh.
  21246. * 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
  21247. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21248. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21249. * @param name defines the name of the mesh to create
  21250. * @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
  21251. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21252. * @param scale is the value to scale the shape
  21253. * @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
  21254. * @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
  21255. * @param scene defines the hosting scene
  21256. * @param updatable defines if the mesh must be flagged as updatable
  21257. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21258. * @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)
  21259. * @returns a new Mesh
  21260. */
  21261. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21262. /**
  21263. * Creates an custom extruded shape mesh.
  21264. * The custom extrusion is a parametric shape.
  21265. * It has no predefined shape. Its final shape will depend on the input parameters.
  21266. * Please consider using the same method from the MeshBuilder class instead
  21267. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21268. * @param name defines the name of the mesh to create
  21269. * @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
  21270. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21271. * @param scaleFunction is a custom Javascript function called on each path point
  21272. * @param rotationFunction is a custom Javascript function called on each path point
  21273. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21274. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21275. * @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
  21276. * @param scene defines the hosting scene
  21277. * @param updatable defines if the mesh must be flagged as updatable
  21278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21279. * @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)
  21280. * @returns a new Mesh
  21281. */
  21282. 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;
  21283. /**
  21284. * Creates lathe mesh.
  21285. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21286. * Please consider using the same method from the MeshBuilder class instead
  21287. * @param name defines the name of the mesh to create
  21288. * @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
  21289. * @param radius is the radius value of the lathe
  21290. * @param tessellation is the side number of the lathe.
  21291. * @param scene defines the hosting scene
  21292. * @param updatable defines if the mesh must be flagged as updatable
  21293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21294. * @returns a new Mesh
  21295. */
  21296. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21297. /**
  21298. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21299. * @param name defines the name of the mesh to create
  21300. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21301. * @param scene defines the hosting scene
  21302. * @param updatable defines if the mesh must be flagged as updatable
  21303. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21304. * @returns a new Mesh
  21305. */
  21306. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21307. /**
  21308. * Creates a ground mesh.
  21309. * Please consider using the same method from the MeshBuilder class instead
  21310. * @param name defines the name of the mesh to create
  21311. * @param width set the width of the ground
  21312. * @param height set the height of the ground
  21313. * @param subdivisions sets the number of subdivisions per side
  21314. * @param scene defines the hosting scene
  21315. * @param updatable defines if the mesh must be flagged as updatable
  21316. * @returns a new Mesh
  21317. */
  21318. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21319. /**
  21320. * Creates a tiled ground mesh.
  21321. * Please consider using the same method from the MeshBuilder class instead
  21322. * @param name defines the name of the mesh to create
  21323. * @param xmin set the ground minimum X coordinate
  21324. * @param zmin set the ground minimum Y coordinate
  21325. * @param xmax set the ground maximum X coordinate
  21326. * @param zmax set the ground maximum Z coordinate
  21327. * @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
  21328. * @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
  21329. * @param scene defines the hosting scene
  21330. * @param updatable defines if the mesh must be flagged as updatable
  21331. * @returns a new Mesh
  21332. */
  21333. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21334. w: number;
  21335. h: number;
  21336. }, precision: {
  21337. w: number;
  21338. h: number;
  21339. }, scene: Scene, updatable?: boolean): Mesh;
  21340. /**
  21341. * Creates a ground mesh from a height map.
  21342. * Please consider using the same method from the MeshBuilder class instead
  21343. * @see http://doc.babylonjs.com/babylon101/height_map
  21344. * @param name defines the name of the mesh to create
  21345. * @param url sets the URL of the height map image resource
  21346. * @param width set the ground width size
  21347. * @param height set the ground height size
  21348. * @param subdivisions sets the number of subdivision per side
  21349. * @param minHeight is the minimum altitude on the ground
  21350. * @param maxHeight is the maximum altitude on the ground
  21351. * @param scene defines the hosting scene
  21352. * @param updatable defines if the mesh must be flagged as updatable
  21353. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21354. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21355. * @returns a new Mesh
  21356. */
  21357. 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;
  21358. /**
  21359. * Creates a tube mesh.
  21360. * The tube is a parametric shape.
  21361. * It has no predefined shape. Its final shape will depend on the input parameters.
  21362. * Please consider using the same method from the MeshBuilder class instead
  21363. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21364. * @param name defines the name of the mesh to create
  21365. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21366. * @param radius sets the tube radius size
  21367. * @param tessellation is the number of sides on the tubular surface
  21368. * @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
  21369. * @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
  21370. * @param scene defines the hosting scene
  21371. * @param updatable defines if the mesh must be flagged as updatable
  21372. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21373. * @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)
  21374. * @returns a new Mesh
  21375. */
  21376. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21377. (i: number, distance: number): number;
  21378. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21379. /**
  21380. * Creates a polyhedron mesh.
  21381. * Please consider using the same method from the MeshBuilder class instead.
  21382. * * 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
  21383. * * The parameter `size` (positive float, default 1) sets the polygon size
  21384. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21385. * * 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`
  21386. * * 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
  21387. * * 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)`)
  21388. * * 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
  21389. * * 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
  21390. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21391. * * If you create a double-sided mesh, you can choose what parts of 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
  21392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21393. * @param name defines the name of the mesh to create
  21394. * @param options defines the options used to create the mesh
  21395. * @param scene defines the hosting scene
  21396. * @returns a new Mesh
  21397. */
  21398. static CreatePolyhedron(name: string, options: {
  21399. type?: number;
  21400. size?: number;
  21401. sizeX?: number;
  21402. sizeY?: number;
  21403. sizeZ?: number;
  21404. custom?: any;
  21405. faceUV?: Vector4[];
  21406. faceColors?: Color4[];
  21407. updatable?: boolean;
  21408. sideOrientation?: number;
  21409. }, scene: Scene): Mesh;
  21410. /**
  21411. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21412. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21413. * * 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`)
  21414. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21415. * * 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
  21416. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21417. * * If you create a double-sided mesh, you can choose what parts of 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
  21418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21419. * @param name defines the name of the mesh
  21420. * @param options defines the options used to create the mesh
  21421. * @param scene defines the hosting scene
  21422. * @returns a new Mesh
  21423. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21424. */
  21425. static CreateIcoSphere(name: string, options: {
  21426. radius?: number;
  21427. flat?: boolean;
  21428. subdivisions?: number;
  21429. sideOrientation?: number;
  21430. updatable?: boolean;
  21431. }, scene: Scene): Mesh;
  21432. /**
  21433. * Creates a decal mesh.
  21434. * Please consider using the same method from the MeshBuilder class instead.
  21435. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21436. * @param name defines the name of the mesh
  21437. * @param sourceMesh defines the mesh receiving the decal
  21438. * @param position sets the position of the decal in world coordinates
  21439. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21440. * @param size sets the decal scaling
  21441. * @param angle sets the angle to rotate the decal
  21442. * @returns a new Mesh
  21443. */
  21444. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21445. /**
  21446. * Prepare internal position array for software CPU skinning
  21447. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21448. */
  21449. setPositionsForCPUSkinning(): Float32Array;
  21450. /**
  21451. * Prepare internal normal array for software CPU skinning
  21452. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21453. */
  21454. setNormalsForCPUSkinning(): Float32Array;
  21455. /**
  21456. * Updates the vertex buffer by applying transformation from the bones
  21457. * @param skeleton defines the skeleton to apply to current mesh
  21458. * @returns the current mesh
  21459. */
  21460. applySkeleton(skeleton: Skeleton): Mesh;
  21461. /**
  21462. * 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
  21463. * @param meshes defines the list of meshes to scan
  21464. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21465. */
  21466. static MinMax(meshes: AbstractMesh[]): {
  21467. min: Vector3;
  21468. max: Vector3;
  21469. };
  21470. /**
  21471. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21472. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21473. * @returns a vector3
  21474. */
  21475. static Center(meshesOrMinMaxVector: {
  21476. min: Vector3;
  21477. max: Vector3;
  21478. } | AbstractMesh[]): Vector3;
  21479. /**
  21480. * Merge the array of meshes into a single mesh for performance reasons.
  21481. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21482. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21483. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21484. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21485. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21486. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21487. * @returns a new mesh
  21488. */
  21489. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21490. /** @hidden */
  21491. addInstance(instance: InstancedMesh): void;
  21492. /** @hidden */
  21493. removeInstance(instance: InstancedMesh): void;
  21494. }
  21495. }
  21496. declare module "babylonjs/Materials/material" {
  21497. import { IAnimatable } from "babylonjs/Misc/tools";
  21498. import { SmartArray } from "babylonjs/Misc/smartArray";
  21499. import { Observable } from "babylonjs/Misc/observable";
  21500. import { Nullable } from "babylonjs/types";
  21501. import { Scene } from "babylonjs/scene";
  21502. import { Matrix } from "babylonjs/Maths/math";
  21503. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21505. import { Mesh } from "babylonjs/Meshes/mesh";
  21506. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21507. import { Effect } from "babylonjs/Materials/effect";
  21508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21509. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21510. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21511. import { Animation } from "babylonjs/Animations/animation";
  21512. /**
  21513. * Base class for the main features of a material in Babylon.js
  21514. */
  21515. export class Material implements IAnimatable {
  21516. /**
  21517. * Returns the triangle fill mode
  21518. */
  21519. static readonly TriangleFillMode: number;
  21520. /**
  21521. * Returns the wireframe mode
  21522. */
  21523. static readonly WireFrameFillMode: number;
  21524. /**
  21525. * Returns the point fill mode
  21526. */
  21527. static readonly PointFillMode: number;
  21528. /**
  21529. * Returns the point list draw mode
  21530. */
  21531. static readonly PointListDrawMode: number;
  21532. /**
  21533. * Returns the line list draw mode
  21534. */
  21535. static readonly LineListDrawMode: number;
  21536. /**
  21537. * Returns the line loop draw mode
  21538. */
  21539. static readonly LineLoopDrawMode: number;
  21540. /**
  21541. * Returns the line strip draw mode
  21542. */
  21543. static readonly LineStripDrawMode: number;
  21544. /**
  21545. * Returns the triangle strip draw mode
  21546. */
  21547. static readonly TriangleStripDrawMode: number;
  21548. /**
  21549. * Returns the triangle fan draw mode
  21550. */
  21551. static readonly TriangleFanDrawMode: number;
  21552. /**
  21553. * Stores the clock-wise side orientation
  21554. */
  21555. static readonly ClockWiseSideOrientation: number;
  21556. /**
  21557. * Stores the counter clock-wise side orientation
  21558. */
  21559. static readonly CounterClockWiseSideOrientation: number;
  21560. /**
  21561. * The dirty texture flag value
  21562. */
  21563. static readonly TextureDirtyFlag: number;
  21564. /**
  21565. * The dirty light flag value
  21566. */
  21567. static readonly LightDirtyFlag: number;
  21568. /**
  21569. * The dirty fresnel flag value
  21570. */
  21571. static readonly FresnelDirtyFlag: number;
  21572. /**
  21573. * The dirty attribute flag value
  21574. */
  21575. static readonly AttributesDirtyFlag: number;
  21576. /**
  21577. * The dirty misc flag value
  21578. */
  21579. static readonly MiscDirtyFlag: number;
  21580. /**
  21581. * The all dirty flag value
  21582. */
  21583. static readonly AllDirtyFlag: number;
  21584. /**
  21585. * The ID of the material
  21586. */
  21587. id: string;
  21588. /**
  21589. * Gets or sets the unique id of the material
  21590. */
  21591. uniqueId: number;
  21592. /**
  21593. * The name of the material
  21594. */
  21595. name: string;
  21596. /**
  21597. * Gets or sets user defined metadata
  21598. */
  21599. metadata: any;
  21600. /**
  21601. * For internal use only. Please do not use.
  21602. */
  21603. reservedDataStore: any;
  21604. /**
  21605. * Specifies if the ready state should be checked on each call
  21606. */
  21607. checkReadyOnEveryCall: boolean;
  21608. /**
  21609. * Specifies if the ready state should be checked once
  21610. */
  21611. checkReadyOnlyOnce: boolean;
  21612. /**
  21613. * The state of the material
  21614. */
  21615. state: string;
  21616. /**
  21617. * The alpha value of the material
  21618. */
  21619. protected _alpha: number;
  21620. /**
  21621. * Sets the alpha value of the material
  21622. */
  21623. /**
  21624. * Gets the alpha value of the material
  21625. */
  21626. alpha: number;
  21627. /**
  21628. * Specifies if back face culling is enabled
  21629. */
  21630. protected _backFaceCulling: boolean;
  21631. /**
  21632. * Sets the back-face culling state
  21633. */
  21634. /**
  21635. * Gets the back-face culling state
  21636. */
  21637. backFaceCulling: boolean;
  21638. /**
  21639. * Stores the value for side orientation
  21640. */
  21641. sideOrientation: number;
  21642. /**
  21643. * Callback triggered when the material is compiled
  21644. */
  21645. onCompiled: (effect: Effect) => void;
  21646. /**
  21647. * Callback triggered when an error occurs
  21648. */
  21649. onError: (effect: Effect, errors: string) => void;
  21650. /**
  21651. * Callback triggered to get the render target textures
  21652. */
  21653. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21654. /**
  21655. * Gets a boolean indicating that current material needs to register RTT
  21656. */
  21657. readonly hasRenderTargetTextures: boolean;
  21658. /**
  21659. * Specifies if the material should be serialized
  21660. */
  21661. doNotSerialize: boolean;
  21662. /**
  21663. * @hidden
  21664. */
  21665. _storeEffectOnSubMeshes: boolean;
  21666. /**
  21667. * Stores the animations for the material
  21668. */
  21669. animations: Array<Animation>;
  21670. /**
  21671. * An event triggered when the material is disposed
  21672. */
  21673. onDisposeObservable: Observable<Material>;
  21674. /**
  21675. * An observer which watches for dispose events
  21676. */
  21677. private _onDisposeObserver;
  21678. private _onUnBindObservable;
  21679. /**
  21680. * Called during a dispose event
  21681. */
  21682. onDispose: () => void;
  21683. private _onBindObservable;
  21684. /**
  21685. * An event triggered when the material is bound
  21686. */
  21687. readonly onBindObservable: Observable<AbstractMesh>;
  21688. /**
  21689. * An observer which watches for bind events
  21690. */
  21691. private _onBindObserver;
  21692. /**
  21693. * Called during a bind event
  21694. */
  21695. onBind: (Mesh: AbstractMesh) => void;
  21696. /**
  21697. * An event triggered when the material is unbound
  21698. */
  21699. readonly onUnBindObservable: Observable<Material>;
  21700. /**
  21701. * Stores the value of the alpha mode
  21702. */
  21703. private _alphaMode;
  21704. /**
  21705. * Sets the value of the alpha mode.
  21706. *
  21707. * | Value | Type | Description |
  21708. * | --- | --- | --- |
  21709. * | 0 | ALPHA_DISABLE | |
  21710. * | 1 | ALPHA_ADD | |
  21711. * | 2 | ALPHA_COMBINE | |
  21712. * | 3 | ALPHA_SUBTRACT | |
  21713. * | 4 | ALPHA_MULTIPLY | |
  21714. * | 5 | ALPHA_MAXIMIZED | |
  21715. * | 6 | ALPHA_ONEONE | |
  21716. * | 7 | ALPHA_PREMULTIPLIED | |
  21717. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21718. * | 9 | ALPHA_INTERPOLATE | |
  21719. * | 10 | ALPHA_SCREENMODE | |
  21720. *
  21721. */
  21722. /**
  21723. * Gets the value of the alpha mode
  21724. */
  21725. alphaMode: number;
  21726. /**
  21727. * Stores the state of the need depth pre-pass value
  21728. */
  21729. private _needDepthPrePass;
  21730. /**
  21731. * Sets the need depth pre-pass value
  21732. */
  21733. /**
  21734. * Gets the depth pre-pass value
  21735. */
  21736. needDepthPrePass: boolean;
  21737. /**
  21738. * Specifies if depth writing should be disabled
  21739. */
  21740. disableDepthWrite: boolean;
  21741. /**
  21742. * Specifies if depth writing should be forced
  21743. */
  21744. forceDepthWrite: boolean;
  21745. /**
  21746. * Specifies if there should be a separate pass for culling
  21747. */
  21748. separateCullingPass: boolean;
  21749. /**
  21750. * Stores the state specifing if fog should be enabled
  21751. */
  21752. private _fogEnabled;
  21753. /**
  21754. * Sets the state for enabling fog
  21755. */
  21756. /**
  21757. * Gets the value of the fog enabled state
  21758. */
  21759. fogEnabled: boolean;
  21760. /**
  21761. * Stores the size of points
  21762. */
  21763. pointSize: number;
  21764. /**
  21765. * Stores the z offset value
  21766. */
  21767. zOffset: number;
  21768. /**
  21769. * Gets a value specifying if wireframe mode is enabled
  21770. */
  21771. /**
  21772. * Sets the state of wireframe mode
  21773. */
  21774. wireframe: boolean;
  21775. /**
  21776. * Gets the value specifying if point clouds are enabled
  21777. */
  21778. /**
  21779. * Sets the state of point cloud mode
  21780. */
  21781. pointsCloud: boolean;
  21782. /**
  21783. * Gets the material fill mode
  21784. */
  21785. /**
  21786. * Sets the material fill mode
  21787. */
  21788. fillMode: number;
  21789. /**
  21790. * @hidden
  21791. * Stores the effects for the material
  21792. */
  21793. _effect: Nullable<Effect>;
  21794. /**
  21795. * @hidden
  21796. * Specifies if the material was previously ready
  21797. */
  21798. _wasPreviouslyReady: boolean;
  21799. /**
  21800. * Specifies if uniform buffers should be used
  21801. */
  21802. private _useUBO;
  21803. /**
  21804. * Stores a reference to the scene
  21805. */
  21806. private _scene;
  21807. /**
  21808. * Stores the fill mode state
  21809. */
  21810. private _fillMode;
  21811. /**
  21812. * Specifies if the depth write state should be cached
  21813. */
  21814. private _cachedDepthWriteState;
  21815. /**
  21816. * Stores the uniform buffer
  21817. */
  21818. protected _uniformBuffer: UniformBuffer;
  21819. /** @hidden */
  21820. _indexInSceneMaterialArray: number;
  21821. /** @hidden */
  21822. meshMap: Nullable<{
  21823. [id: string]: AbstractMesh | undefined;
  21824. }>;
  21825. /**
  21826. * Creates a material instance
  21827. * @param name defines the name of the material
  21828. * @param scene defines the scene to reference
  21829. * @param doNotAdd specifies if the material should be added to the scene
  21830. */
  21831. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21832. /**
  21833. * Returns a string representation of the current material
  21834. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21835. * @returns a string with material information
  21836. */
  21837. toString(fullDetails?: boolean): string;
  21838. /**
  21839. * Gets the class name of the material
  21840. * @returns a string with the class name of the material
  21841. */
  21842. getClassName(): string;
  21843. /**
  21844. * Specifies if updates for the material been locked
  21845. */
  21846. readonly isFrozen: boolean;
  21847. /**
  21848. * Locks updates for the material
  21849. */
  21850. freeze(): void;
  21851. /**
  21852. * Unlocks updates for the material
  21853. */
  21854. unfreeze(): void;
  21855. /**
  21856. * Specifies if the material is ready to be used
  21857. * @param mesh defines the mesh to check
  21858. * @param useInstances specifies if instances should be used
  21859. * @returns a boolean indicating if the material is ready to be used
  21860. */
  21861. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21862. /**
  21863. * Specifies that the submesh is ready to be used
  21864. * @param mesh defines the mesh to check
  21865. * @param subMesh defines which submesh to check
  21866. * @param useInstances specifies that instances should be used
  21867. * @returns a boolean indicating that the submesh is ready or not
  21868. */
  21869. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21870. /**
  21871. * Returns the material effect
  21872. * @returns the effect associated with the material
  21873. */
  21874. getEffect(): Nullable<Effect>;
  21875. /**
  21876. * Returns the current scene
  21877. * @returns a Scene
  21878. */
  21879. getScene(): Scene;
  21880. /**
  21881. * Specifies if the material will require alpha blending
  21882. * @returns a boolean specifying if alpha blending is needed
  21883. */
  21884. needAlphaBlending(): boolean;
  21885. /**
  21886. * Specifies if the mesh will require alpha blending
  21887. * @param mesh defines the mesh to check
  21888. * @returns a boolean specifying if alpha blending is needed for the mesh
  21889. */
  21890. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21891. /**
  21892. * Specifies if this material should be rendered in alpha test mode
  21893. * @returns a boolean specifying if an alpha test is needed.
  21894. */
  21895. needAlphaTesting(): boolean;
  21896. /**
  21897. * Gets the texture used for the alpha test
  21898. * @returns the texture to use for alpha testing
  21899. */
  21900. getAlphaTestTexture(): Nullable<BaseTexture>;
  21901. /**
  21902. * Marks the material to indicate that it needs to be re-calculated
  21903. */
  21904. markDirty(): void;
  21905. /** @hidden */
  21906. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21907. /**
  21908. * Binds the material to the mesh
  21909. * @param world defines the world transformation matrix
  21910. * @param mesh defines the mesh to bind the material to
  21911. */
  21912. bind(world: Matrix, mesh?: Mesh): void;
  21913. /**
  21914. * Binds the submesh to the material
  21915. * @param world defines the world transformation matrix
  21916. * @param mesh defines the mesh containing the submesh
  21917. * @param subMesh defines the submesh to bind the material to
  21918. */
  21919. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21920. /**
  21921. * Binds the world matrix to the material
  21922. * @param world defines the world transformation matrix
  21923. */
  21924. bindOnlyWorldMatrix(world: Matrix): void;
  21925. /**
  21926. * Binds the scene's uniform buffer to the effect.
  21927. * @param effect defines the effect to bind to the scene uniform buffer
  21928. * @param sceneUbo defines the uniform buffer storing scene data
  21929. */
  21930. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21931. /**
  21932. * Binds the view matrix to the effect
  21933. * @param effect defines the effect to bind the view matrix to
  21934. */
  21935. bindView(effect: Effect): void;
  21936. /**
  21937. * Binds the view projection matrix to the effect
  21938. * @param effect defines the effect to bind the view projection matrix to
  21939. */
  21940. bindViewProjection(effect: Effect): void;
  21941. /**
  21942. * Specifies if material alpha testing should be turned on for the mesh
  21943. * @param mesh defines the mesh to check
  21944. */
  21945. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21946. /**
  21947. * Processes to execute after binding the material to a mesh
  21948. * @param mesh defines the rendered mesh
  21949. */
  21950. protected _afterBind(mesh?: Mesh): void;
  21951. /**
  21952. * Unbinds the material from the mesh
  21953. */
  21954. unbind(): void;
  21955. /**
  21956. * Gets the active textures from the material
  21957. * @returns an array of textures
  21958. */
  21959. getActiveTextures(): BaseTexture[];
  21960. /**
  21961. * Specifies if the material uses a texture
  21962. * @param texture defines the texture to check against the material
  21963. * @returns a boolean specifying if the material uses the texture
  21964. */
  21965. hasTexture(texture: BaseTexture): boolean;
  21966. /**
  21967. * Makes a duplicate of the material, and gives it a new name
  21968. * @param name defines the new name for the duplicated material
  21969. * @returns the cloned material
  21970. */
  21971. clone(name: string): Nullable<Material>;
  21972. /**
  21973. * Gets the meshes bound to the material
  21974. * @returns an array of meshes bound to the material
  21975. */
  21976. getBindedMeshes(): AbstractMesh[];
  21977. /**
  21978. * Force shader compilation
  21979. * @param mesh defines the mesh associated with this material
  21980. * @param onCompiled defines a function to execute once the material is compiled
  21981. * @param options defines the options to configure the compilation
  21982. */
  21983. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21984. clipPlane: boolean;
  21985. }>): void;
  21986. /**
  21987. * Force shader compilation
  21988. * @param mesh defines the mesh that will use this material
  21989. * @param options defines additional options for compiling the shaders
  21990. * @returns a promise that resolves when the compilation completes
  21991. */
  21992. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21993. clipPlane: boolean;
  21994. }>): Promise<void>;
  21995. private static readonly _ImageProcessingDirtyCallBack;
  21996. private static readonly _TextureDirtyCallBack;
  21997. private static readonly _FresnelDirtyCallBack;
  21998. private static readonly _MiscDirtyCallBack;
  21999. private static readonly _LightsDirtyCallBack;
  22000. private static readonly _AttributeDirtyCallBack;
  22001. private static _FresnelAndMiscDirtyCallBack;
  22002. private static _TextureAndMiscDirtyCallBack;
  22003. private static readonly _DirtyCallbackArray;
  22004. private static readonly _RunDirtyCallBacks;
  22005. /**
  22006. * Marks a define in the material to indicate that it needs to be re-computed
  22007. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22008. */
  22009. markAsDirty(flag: number): void;
  22010. /**
  22011. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22012. * @param func defines a function which checks material defines against the submeshes
  22013. */
  22014. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22015. /**
  22016. * Indicates that image processing needs to be re-calculated for all submeshes
  22017. */
  22018. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22019. /**
  22020. * Indicates that textures need to be re-calculated for all submeshes
  22021. */
  22022. protected _markAllSubMeshesAsTexturesDirty(): void;
  22023. /**
  22024. * Indicates that fresnel needs to be re-calculated for all submeshes
  22025. */
  22026. protected _markAllSubMeshesAsFresnelDirty(): void;
  22027. /**
  22028. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22029. */
  22030. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22031. /**
  22032. * Indicates that lights need to be re-calculated for all submeshes
  22033. */
  22034. protected _markAllSubMeshesAsLightsDirty(): void;
  22035. /**
  22036. * Indicates that attributes need to be re-calculated for all submeshes
  22037. */
  22038. protected _markAllSubMeshesAsAttributesDirty(): void;
  22039. /**
  22040. * Indicates that misc needs to be re-calculated for all submeshes
  22041. */
  22042. protected _markAllSubMeshesAsMiscDirty(): void;
  22043. /**
  22044. * Indicates that textures and misc need to be re-calculated for all submeshes
  22045. */
  22046. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22047. /**
  22048. * Disposes the material
  22049. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22050. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22051. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22052. */
  22053. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22054. /** @hidden */
  22055. private releaseVertexArrayObject;
  22056. /**
  22057. * Serializes this material
  22058. * @returns the serialized material object
  22059. */
  22060. serialize(): any;
  22061. /**
  22062. * Creates a material from parsed material data
  22063. * @param parsedMaterial defines parsed material data
  22064. * @param scene defines the hosting scene
  22065. * @param rootUrl defines the root URL to use to load textures
  22066. * @returns a new material
  22067. */
  22068. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22069. }
  22070. }
  22071. declare module "babylonjs/Meshes/subMesh" {
  22072. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22073. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22074. import { Engine } from "babylonjs/Engines/engine";
  22075. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22076. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22077. import { Effect } from "babylonjs/Materials/effect";
  22078. import { Collider } from "babylonjs/Collisions/collider";
  22079. import { Material } from "babylonjs/Materials/material";
  22080. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22082. import { Mesh } from "babylonjs/Meshes/mesh";
  22083. import { Ray } from "babylonjs/Culling/ray";
  22084. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22085. /**
  22086. * Base class for submeshes
  22087. */
  22088. export class BaseSubMesh {
  22089. /** @hidden */
  22090. _materialDefines: Nullable<MaterialDefines>;
  22091. /** @hidden */
  22092. _materialEffect: Nullable<Effect>;
  22093. /**
  22094. * Gets associated effect
  22095. */
  22096. readonly effect: Nullable<Effect>;
  22097. /**
  22098. * Sets associated effect (effect used to render this submesh)
  22099. * @param effect defines the effect to associate with
  22100. * @param defines defines the set of defines used to compile this effect
  22101. */
  22102. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22103. }
  22104. /**
  22105. * Defines a subdivision inside a mesh
  22106. */
  22107. export class SubMesh extends BaseSubMesh implements ICullable {
  22108. /** the material index to use */
  22109. materialIndex: number;
  22110. /** vertex index start */
  22111. verticesStart: number;
  22112. /** vertices count */
  22113. verticesCount: number;
  22114. /** index start */
  22115. indexStart: number;
  22116. /** indices count */
  22117. indexCount: number;
  22118. /** @hidden */
  22119. _linesIndexCount: number;
  22120. private _mesh;
  22121. private _renderingMesh;
  22122. private _boundingInfo;
  22123. private _linesIndexBuffer;
  22124. /** @hidden */
  22125. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22126. /** @hidden */
  22127. _trianglePlanes: Plane[];
  22128. /** @hidden */
  22129. _lastColliderTransformMatrix: Matrix;
  22130. /** @hidden */
  22131. _renderId: number;
  22132. /** @hidden */
  22133. _alphaIndex: number;
  22134. /** @hidden */
  22135. _distanceToCamera: number;
  22136. /** @hidden */
  22137. _id: number;
  22138. private _currentMaterial;
  22139. /**
  22140. * Add a new submesh to a mesh
  22141. * @param materialIndex defines the material index to use
  22142. * @param verticesStart defines vertex index start
  22143. * @param verticesCount defines vertices count
  22144. * @param indexStart defines index start
  22145. * @param indexCount defines indices count
  22146. * @param mesh defines the parent mesh
  22147. * @param renderingMesh defines an optional rendering mesh
  22148. * @param createBoundingBox defines if bounding box should be created for this submesh
  22149. * @returns the new submesh
  22150. */
  22151. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22152. /**
  22153. * Creates a new submesh
  22154. * @param materialIndex defines the material index to use
  22155. * @param verticesStart defines vertex index start
  22156. * @param verticesCount defines vertices count
  22157. * @param indexStart defines index start
  22158. * @param indexCount defines indices count
  22159. * @param mesh defines the parent mesh
  22160. * @param renderingMesh defines an optional rendering mesh
  22161. * @param createBoundingBox defines if bounding box should be created for this submesh
  22162. */
  22163. constructor(
  22164. /** the material index to use */
  22165. materialIndex: number,
  22166. /** vertex index start */
  22167. verticesStart: number,
  22168. /** vertices count */
  22169. verticesCount: number,
  22170. /** index start */
  22171. indexStart: number,
  22172. /** indices count */
  22173. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22174. /**
  22175. * Returns true if this submesh covers the entire parent mesh
  22176. * @ignorenaming
  22177. */
  22178. readonly IsGlobal: boolean;
  22179. /**
  22180. * Returns the submesh BoudingInfo object
  22181. * @returns current bounding info (or mesh's one if the submesh is global)
  22182. */
  22183. getBoundingInfo(): BoundingInfo;
  22184. /**
  22185. * Sets the submesh BoundingInfo
  22186. * @param boundingInfo defines the new bounding info to use
  22187. * @returns the SubMesh
  22188. */
  22189. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22190. /**
  22191. * Returns the mesh of the current submesh
  22192. * @return the parent mesh
  22193. */
  22194. getMesh(): AbstractMesh;
  22195. /**
  22196. * Returns the rendering mesh of the submesh
  22197. * @returns the rendering mesh (could be different from parent mesh)
  22198. */
  22199. getRenderingMesh(): Mesh;
  22200. /**
  22201. * Returns the submesh material
  22202. * @returns null or the current material
  22203. */
  22204. getMaterial(): Nullable<Material>;
  22205. /**
  22206. * Sets a new updated BoundingInfo object to the submesh
  22207. * @returns the SubMesh
  22208. */
  22209. refreshBoundingInfo(): SubMesh;
  22210. /** @hidden */
  22211. _checkCollision(collider: Collider): boolean;
  22212. /**
  22213. * Updates the submesh BoundingInfo
  22214. * @param world defines the world matrix to use to update the bounding info
  22215. * @returns the submesh
  22216. */
  22217. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22218. /**
  22219. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22220. * @param frustumPlanes defines the frustum planes
  22221. * @returns true if the submesh is intersecting with the frustum
  22222. */
  22223. isInFrustum(frustumPlanes: Plane[]): boolean;
  22224. /**
  22225. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22226. * @param frustumPlanes defines the frustum planes
  22227. * @returns true if the submesh is inside the frustum
  22228. */
  22229. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22230. /**
  22231. * Renders the submesh
  22232. * @param enableAlphaMode defines if alpha needs to be used
  22233. * @returns the submesh
  22234. */
  22235. render(enableAlphaMode: boolean): SubMesh;
  22236. /**
  22237. * @hidden
  22238. */
  22239. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22240. /**
  22241. * Checks if the submesh intersects with a ray
  22242. * @param ray defines the ray to test
  22243. * @returns true is the passed ray intersects the submesh bounding box
  22244. */
  22245. canIntersects(ray: Ray): boolean;
  22246. /**
  22247. * Intersects current submesh with a ray
  22248. * @param ray defines the ray to test
  22249. * @param positions defines mesh's positions array
  22250. * @param indices defines mesh's indices array
  22251. * @param fastCheck defines if only bounding info should be used
  22252. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22253. * @returns intersection info or null if no intersection
  22254. */
  22255. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22256. /** @hidden */
  22257. private _intersectLines;
  22258. /** @hidden */
  22259. private _intersectTriangles;
  22260. /** @hidden */
  22261. _rebuild(): void;
  22262. /**
  22263. * Creates a new submesh from the passed mesh
  22264. * @param newMesh defines the new hosting mesh
  22265. * @param newRenderingMesh defines an optional rendering mesh
  22266. * @returns the new submesh
  22267. */
  22268. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22269. /**
  22270. * Release associated resources
  22271. */
  22272. dispose(): void;
  22273. /**
  22274. * Gets the class name
  22275. * @returns the string "SubMesh".
  22276. */
  22277. getClassName(): string;
  22278. /**
  22279. * Creates a new submesh from indices data
  22280. * @param materialIndex the index of the main mesh material
  22281. * @param startIndex the index where to start the copy in the mesh indices array
  22282. * @param indexCount the number of indices to copy then from the startIndex
  22283. * @param mesh the main mesh to create the submesh from
  22284. * @param renderingMesh the optional rendering mesh
  22285. * @returns a new submesh
  22286. */
  22287. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22288. }
  22289. }
  22290. declare module "babylonjs/Meshes/geometry" {
  22291. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22292. import { Scene } from "babylonjs/scene";
  22293. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22294. import { Engine } from "babylonjs/Engines/engine";
  22295. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22296. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22297. import { Effect } from "babylonjs/Materials/effect";
  22298. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22299. import { Mesh } from "babylonjs/Meshes/mesh";
  22300. /**
  22301. * Class used to store geometry data (vertex buffers + index buffer)
  22302. */
  22303. export class Geometry implements IGetSetVerticesData {
  22304. /**
  22305. * Gets or sets the ID of the geometry
  22306. */
  22307. id: string;
  22308. /**
  22309. * Gets or sets the unique ID of the geometry
  22310. */
  22311. uniqueId: number;
  22312. /**
  22313. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22314. */
  22315. delayLoadState: number;
  22316. /**
  22317. * Gets the file containing the data to load when running in delay load state
  22318. */
  22319. delayLoadingFile: Nullable<string>;
  22320. /**
  22321. * Callback called when the geometry is updated
  22322. */
  22323. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22324. private _scene;
  22325. private _engine;
  22326. private _meshes;
  22327. private _totalVertices;
  22328. /** @hidden */
  22329. _indices: IndicesArray;
  22330. /** @hidden */
  22331. _vertexBuffers: {
  22332. [key: string]: VertexBuffer;
  22333. };
  22334. private _isDisposed;
  22335. private _extend;
  22336. private _boundingBias;
  22337. /** @hidden */
  22338. _delayInfo: Array<string>;
  22339. private _indexBuffer;
  22340. private _indexBufferIsUpdatable;
  22341. /** @hidden */
  22342. _boundingInfo: Nullable<BoundingInfo>;
  22343. /** @hidden */
  22344. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22345. /** @hidden */
  22346. _softwareSkinningFrameId: number;
  22347. private _vertexArrayObjects;
  22348. private _updatable;
  22349. /** @hidden */
  22350. _positions: Nullable<Vector3[]>;
  22351. /**
  22352. * 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
  22353. */
  22354. /**
  22355. * 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
  22356. */
  22357. boundingBias: Vector2;
  22358. /**
  22359. * Static function used to attach a new empty geometry to a mesh
  22360. * @param mesh defines the mesh to attach the geometry to
  22361. * @returns the new Geometry
  22362. */
  22363. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22364. /**
  22365. * Creates a new geometry
  22366. * @param id defines the unique ID
  22367. * @param scene defines the hosting scene
  22368. * @param vertexData defines the VertexData used to get geometry data
  22369. * @param updatable defines if geometry must be updatable (false by default)
  22370. * @param mesh defines the mesh that will be associated with the geometry
  22371. */
  22372. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22373. /**
  22374. * Gets the current extend of the geometry
  22375. */
  22376. readonly extend: {
  22377. minimum: Vector3;
  22378. maximum: Vector3;
  22379. };
  22380. /**
  22381. * Gets the hosting scene
  22382. * @returns the hosting Scene
  22383. */
  22384. getScene(): Scene;
  22385. /**
  22386. * Gets the hosting engine
  22387. * @returns the hosting Engine
  22388. */
  22389. getEngine(): Engine;
  22390. /**
  22391. * Defines if the geometry is ready to use
  22392. * @returns true if the geometry is ready to be used
  22393. */
  22394. isReady(): boolean;
  22395. /**
  22396. * Gets a value indicating that the geometry should not be serialized
  22397. */
  22398. readonly doNotSerialize: boolean;
  22399. /** @hidden */
  22400. _rebuild(): void;
  22401. /**
  22402. * Affects all geometry data in one call
  22403. * @param vertexData defines the geometry data
  22404. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22405. */
  22406. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22407. /**
  22408. * Set specific vertex data
  22409. * @param kind defines the data kind (Position, normal, etc...)
  22410. * @param data defines the vertex data to use
  22411. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22412. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22413. */
  22414. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22415. /**
  22416. * Removes a specific vertex data
  22417. * @param kind defines the data kind (Position, normal, etc...)
  22418. */
  22419. removeVerticesData(kind: string): void;
  22420. /**
  22421. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22422. * @param buffer defines the vertex buffer to use
  22423. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22424. */
  22425. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22426. /**
  22427. * Update a specific vertex buffer
  22428. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22429. * It will do nothing if the buffer is not updatable
  22430. * @param kind defines the data kind (Position, normal, etc...)
  22431. * @param data defines the data to use
  22432. * @param offset defines the offset in the target buffer where to store the data
  22433. * @param useBytes set to true if the offset is in bytes
  22434. */
  22435. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22436. /**
  22437. * Update a specific vertex buffer
  22438. * This function will create a new buffer if the current one is not updatable
  22439. * @param kind defines the data kind (Position, normal, etc...)
  22440. * @param data defines the data to use
  22441. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22442. */
  22443. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22444. private _updateBoundingInfo;
  22445. /** @hidden */
  22446. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22447. /**
  22448. * Gets total number of vertices
  22449. * @returns the total number of vertices
  22450. */
  22451. getTotalVertices(): number;
  22452. /**
  22453. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22454. * @param kind defines the data kind (Position, normal, etc...)
  22455. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22456. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22457. * @returns a float array containing vertex data
  22458. */
  22459. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22460. /**
  22461. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22462. * @param kind defines the data kind (Position, normal, etc...)
  22463. * @returns true if the vertex buffer with the specified kind is updatable
  22464. */
  22465. isVertexBufferUpdatable(kind: string): boolean;
  22466. /**
  22467. * Gets a specific vertex buffer
  22468. * @param kind defines the data kind (Position, normal, etc...)
  22469. * @returns a VertexBuffer
  22470. */
  22471. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22472. /**
  22473. * Returns all vertex buffers
  22474. * @return an object holding all vertex buffers indexed by kind
  22475. */
  22476. getVertexBuffers(): Nullable<{
  22477. [key: string]: VertexBuffer;
  22478. }>;
  22479. /**
  22480. * Gets a boolean indicating if specific vertex buffer is present
  22481. * @param kind defines the data kind (Position, normal, etc...)
  22482. * @returns true if data is present
  22483. */
  22484. isVerticesDataPresent(kind: string): boolean;
  22485. /**
  22486. * Gets a list of all attached data kinds (Position, normal, etc...)
  22487. * @returns a list of string containing all kinds
  22488. */
  22489. getVerticesDataKinds(): string[];
  22490. /**
  22491. * Update index buffer
  22492. * @param indices defines the indices to store in the index buffer
  22493. * @param offset defines the offset in the target buffer where to store the data
  22494. * @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)
  22495. */
  22496. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22497. /**
  22498. * Creates a new index buffer
  22499. * @param indices defines the indices to store in the index buffer
  22500. * @param totalVertices defines the total number of vertices (could be null)
  22501. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22502. */
  22503. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22504. /**
  22505. * Return the total number of indices
  22506. * @returns the total number of indices
  22507. */
  22508. getTotalIndices(): number;
  22509. /**
  22510. * Gets the index buffer array
  22511. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22512. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22513. * @returns the index buffer array
  22514. */
  22515. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22516. /**
  22517. * Gets the index buffer
  22518. * @return the index buffer
  22519. */
  22520. getIndexBuffer(): Nullable<WebGLBuffer>;
  22521. /** @hidden */
  22522. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22523. /**
  22524. * Release the associated resources for a specific mesh
  22525. * @param mesh defines the source mesh
  22526. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22527. */
  22528. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22529. /**
  22530. * Apply current geometry to a given mesh
  22531. * @param mesh defines the mesh to apply geometry to
  22532. */
  22533. applyToMesh(mesh: Mesh): void;
  22534. private _updateExtend;
  22535. private _applyToMesh;
  22536. private notifyUpdate;
  22537. /**
  22538. * Load the geometry if it was flagged as delay loaded
  22539. * @param scene defines the hosting scene
  22540. * @param onLoaded defines a callback called when the geometry is loaded
  22541. */
  22542. load(scene: Scene, onLoaded?: () => void): void;
  22543. private _queueLoad;
  22544. /**
  22545. * Invert the geometry to move from a right handed system to a left handed one.
  22546. */
  22547. toLeftHanded(): void;
  22548. /** @hidden */
  22549. _resetPointsArrayCache(): void;
  22550. /** @hidden */
  22551. _generatePointsArray(): boolean;
  22552. /**
  22553. * Gets a value indicating if the geometry is disposed
  22554. * @returns true if the geometry was disposed
  22555. */
  22556. isDisposed(): boolean;
  22557. private _disposeVertexArrayObjects;
  22558. /**
  22559. * Free all associated resources
  22560. */
  22561. dispose(): void;
  22562. /**
  22563. * Clone the current geometry into a new geometry
  22564. * @param id defines the unique ID of the new geometry
  22565. * @returns a new geometry object
  22566. */
  22567. copy(id: string): Geometry;
  22568. /**
  22569. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22570. * @return a JSON representation of the current geometry data (without the vertices data)
  22571. */
  22572. serialize(): any;
  22573. private toNumberArray;
  22574. /**
  22575. * Serialize all vertices data into a JSON oject
  22576. * @returns a JSON representation of the current geometry data
  22577. */
  22578. serializeVerticeData(): any;
  22579. /**
  22580. * Extracts a clone of a mesh geometry
  22581. * @param mesh defines the source mesh
  22582. * @param id defines the unique ID of the new geometry object
  22583. * @returns the new geometry object
  22584. */
  22585. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22586. /**
  22587. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22588. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22589. * Be aware Math.random() could cause collisions, but:
  22590. * "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"
  22591. * @returns a string containing a new GUID
  22592. */
  22593. static RandomId(): string;
  22594. /** @hidden */
  22595. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22596. private static _CleanMatricesWeights;
  22597. /**
  22598. * Create a new geometry from persisted data (Using .babylon file format)
  22599. * @param parsedVertexData defines the persisted data
  22600. * @param scene defines the hosting scene
  22601. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22602. * @returns the new geometry object
  22603. */
  22604. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22605. }
  22606. }
  22607. declare module "babylonjs/Meshes/mesh.vertexData" {
  22608. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22609. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22610. import { Geometry } from "babylonjs/Meshes/geometry";
  22611. import { Mesh } from "babylonjs/Meshes/mesh";
  22612. /**
  22613. * Define an interface for all classes that will get and set the data on vertices
  22614. */
  22615. export interface IGetSetVerticesData {
  22616. /**
  22617. * Gets a boolean indicating if specific vertex data is present
  22618. * @param kind defines the vertex data kind to use
  22619. * @returns true is data kind is present
  22620. */
  22621. isVerticesDataPresent(kind: string): boolean;
  22622. /**
  22623. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22624. * @param kind defines the data kind (Position, normal, etc...)
  22625. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22626. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22627. * @returns a float array containing vertex data
  22628. */
  22629. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22630. /**
  22631. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22632. * @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.
  22633. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22634. * @returns the indices array or an empty array if the mesh has no geometry
  22635. */
  22636. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22637. /**
  22638. * Set specific vertex data
  22639. * @param kind defines the data kind (Position, normal, etc...)
  22640. * @param data defines the vertex data to use
  22641. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22642. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22643. */
  22644. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22645. /**
  22646. * Update a specific associated vertex buffer
  22647. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22648. * - VertexBuffer.PositionKind
  22649. * - VertexBuffer.UVKind
  22650. * - VertexBuffer.UV2Kind
  22651. * - VertexBuffer.UV3Kind
  22652. * - VertexBuffer.UV4Kind
  22653. * - VertexBuffer.UV5Kind
  22654. * - VertexBuffer.UV6Kind
  22655. * - VertexBuffer.ColorKind
  22656. * - VertexBuffer.MatricesIndicesKind
  22657. * - VertexBuffer.MatricesIndicesExtraKind
  22658. * - VertexBuffer.MatricesWeightsKind
  22659. * - VertexBuffer.MatricesWeightsExtraKind
  22660. * @param data defines the data source
  22661. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22662. * @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)
  22663. */
  22664. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22665. /**
  22666. * Creates a new index buffer
  22667. * @param indices defines the indices to store in the index buffer
  22668. * @param totalVertices defines the total number of vertices (could be null)
  22669. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22670. */
  22671. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22672. }
  22673. /**
  22674. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22675. */
  22676. export class VertexData {
  22677. /**
  22678. * Mesh side orientation : usually the external or front surface
  22679. */
  22680. static readonly FRONTSIDE: number;
  22681. /**
  22682. * Mesh side orientation : usually the internal or back surface
  22683. */
  22684. static readonly BACKSIDE: number;
  22685. /**
  22686. * Mesh side orientation : both internal and external or front and back surfaces
  22687. */
  22688. static readonly DOUBLESIDE: number;
  22689. /**
  22690. * Mesh side orientation : by default, `FRONTSIDE`
  22691. */
  22692. static readonly DEFAULTSIDE: number;
  22693. /**
  22694. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22695. */
  22696. positions: Nullable<FloatArray>;
  22697. /**
  22698. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22699. */
  22700. normals: Nullable<FloatArray>;
  22701. /**
  22702. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22703. */
  22704. tangents: Nullable<FloatArray>;
  22705. /**
  22706. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22707. */
  22708. uvs: Nullable<FloatArray>;
  22709. /**
  22710. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22711. */
  22712. uvs2: Nullable<FloatArray>;
  22713. /**
  22714. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22715. */
  22716. uvs3: Nullable<FloatArray>;
  22717. /**
  22718. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22719. */
  22720. uvs4: Nullable<FloatArray>;
  22721. /**
  22722. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22723. */
  22724. uvs5: Nullable<FloatArray>;
  22725. /**
  22726. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22727. */
  22728. uvs6: Nullable<FloatArray>;
  22729. /**
  22730. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22731. */
  22732. colors: Nullable<FloatArray>;
  22733. /**
  22734. * 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).
  22735. */
  22736. matricesIndices: Nullable<FloatArray>;
  22737. /**
  22738. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22739. */
  22740. matricesWeights: Nullable<FloatArray>;
  22741. /**
  22742. * An array extending the number of possible indices
  22743. */
  22744. matricesIndicesExtra: Nullable<FloatArray>;
  22745. /**
  22746. * An array extending the number of possible weights when the number of indices is extended
  22747. */
  22748. matricesWeightsExtra: Nullable<FloatArray>;
  22749. /**
  22750. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22751. */
  22752. indices: Nullable<IndicesArray>;
  22753. /**
  22754. * Uses the passed data array to set the set the values for the specified kind of data
  22755. * @param data a linear array of floating numbers
  22756. * @param kind the type of data that is being set, eg positions, colors etc
  22757. */
  22758. set(data: FloatArray, kind: string): void;
  22759. /**
  22760. * Associates the vertexData to the passed Mesh.
  22761. * Sets it as updatable or not (default `false`)
  22762. * @param mesh the mesh the vertexData is applied to
  22763. * @param updatable when used and having the value true allows new data to update the vertexData
  22764. * @returns the VertexData
  22765. */
  22766. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22767. /**
  22768. * Associates the vertexData to the passed Geometry.
  22769. * Sets it as updatable or not (default `false`)
  22770. * @param geometry the geometry the vertexData is applied to
  22771. * @param updatable when used and having the value true allows new data to update the vertexData
  22772. * @returns VertexData
  22773. */
  22774. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22775. /**
  22776. * Updates the associated mesh
  22777. * @param mesh the mesh to be updated
  22778. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22779. * @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
  22780. * @returns VertexData
  22781. */
  22782. updateMesh(mesh: Mesh): VertexData;
  22783. /**
  22784. * Updates the associated geometry
  22785. * @param geometry the geometry to be updated
  22786. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22787. * @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
  22788. * @returns VertexData.
  22789. */
  22790. updateGeometry(geometry: Geometry): VertexData;
  22791. private _applyTo;
  22792. private _update;
  22793. /**
  22794. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22795. * @param matrix the transforming matrix
  22796. * @returns the VertexData
  22797. */
  22798. transform(matrix: Matrix): VertexData;
  22799. /**
  22800. * Merges the passed VertexData into the current one
  22801. * @param other the VertexData to be merged into the current one
  22802. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22803. * @returns the modified VertexData
  22804. */
  22805. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22806. private _mergeElement;
  22807. private _validate;
  22808. /**
  22809. * Serializes the VertexData
  22810. * @returns a serialized object
  22811. */
  22812. serialize(): any;
  22813. /**
  22814. * Extracts the vertexData from a mesh
  22815. * @param mesh the mesh from which to extract the VertexData
  22816. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22817. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22818. * @returns the object VertexData associated to the passed mesh
  22819. */
  22820. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22821. /**
  22822. * Extracts the vertexData from the geometry
  22823. * @param geometry the geometry from which to extract the VertexData
  22824. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22825. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22826. * @returns the object VertexData associated to the passed mesh
  22827. */
  22828. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22829. private static _ExtractFrom;
  22830. /**
  22831. * Creates the VertexData for a Ribbon
  22832. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22833. * * pathArray array of paths, each of which an array of successive Vector3
  22834. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22835. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22836. * * 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
  22837. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22838. * * 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)
  22839. * * 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)
  22840. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22841. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22842. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22843. * @returns the VertexData of the ribbon
  22844. */
  22845. static CreateRibbon(options: {
  22846. pathArray: Vector3[][];
  22847. closeArray?: boolean;
  22848. closePath?: boolean;
  22849. offset?: number;
  22850. sideOrientation?: number;
  22851. frontUVs?: Vector4;
  22852. backUVs?: Vector4;
  22853. invertUV?: boolean;
  22854. uvs?: Vector2[];
  22855. colors?: Color4[];
  22856. }): VertexData;
  22857. /**
  22858. * Creates the VertexData for a box
  22859. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22860. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22861. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22862. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22863. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22864. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22865. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22866. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22867. * * 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)
  22868. * * 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)
  22869. * @returns the VertexData of the box
  22870. */
  22871. static CreateBox(options: {
  22872. size?: number;
  22873. width?: number;
  22874. height?: number;
  22875. depth?: number;
  22876. faceUV?: Vector4[];
  22877. faceColors?: Color4[];
  22878. sideOrientation?: number;
  22879. frontUVs?: Vector4;
  22880. backUVs?: Vector4;
  22881. }): VertexData;
  22882. /**
  22883. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22884. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22885. * * segments sets the number of horizontal strips optional, default 32
  22886. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22887. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22888. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22889. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22890. * * 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
  22891. * * 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
  22892. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22893. * * 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)
  22894. * * 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)
  22895. * @returns the VertexData of the ellipsoid
  22896. */
  22897. static CreateSphere(options: {
  22898. segments?: number;
  22899. diameter?: number;
  22900. diameterX?: number;
  22901. diameterY?: number;
  22902. diameterZ?: number;
  22903. arc?: number;
  22904. slice?: number;
  22905. sideOrientation?: number;
  22906. frontUVs?: Vector4;
  22907. backUVs?: Vector4;
  22908. }): VertexData;
  22909. /**
  22910. * Creates the VertexData for a cylinder, cone or prism
  22911. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22912. * * height sets the height (y direction) of the cylinder, optional, default 2
  22913. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22914. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22915. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22916. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22917. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22918. * * 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
  22919. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22920. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22921. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22922. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22923. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22924. * * 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)
  22925. * * 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)
  22926. * @returns the VertexData of the cylinder, cone or prism
  22927. */
  22928. static CreateCylinder(options: {
  22929. height?: number;
  22930. diameterTop?: number;
  22931. diameterBottom?: number;
  22932. diameter?: number;
  22933. tessellation?: number;
  22934. subdivisions?: number;
  22935. arc?: number;
  22936. faceColors?: Color4[];
  22937. faceUV?: Vector4[];
  22938. hasRings?: boolean;
  22939. enclose?: boolean;
  22940. sideOrientation?: number;
  22941. frontUVs?: Vector4;
  22942. backUVs?: Vector4;
  22943. }): VertexData;
  22944. /**
  22945. * Creates the VertexData for a torus
  22946. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22947. * * diameter the diameter of the torus, optional default 1
  22948. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22949. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22950. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22951. * * 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)
  22952. * * 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)
  22953. * @returns the VertexData of the torus
  22954. */
  22955. static CreateTorus(options: {
  22956. diameter?: number;
  22957. thickness?: number;
  22958. tessellation?: number;
  22959. sideOrientation?: number;
  22960. frontUVs?: Vector4;
  22961. backUVs?: Vector4;
  22962. }): VertexData;
  22963. /**
  22964. * Creates the VertexData of the LineSystem
  22965. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22966. * - lines an array of lines, each line being an array of successive Vector3
  22967. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22968. * @returns the VertexData of the LineSystem
  22969. */
  22970. static CreateLineSystem(options: {
  22971. lines: Vector3[][];
  22972. colors?: Nullable<Color4[][]>;
  22973. }): VertexData;
  22974. /**
  22975. * Create the VertexData for a DashedLines
  22976. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22977. * - points an array successive Vector3
  22978. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22979. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22980. * - dashNb the intended total number of dashes, optional, default 200
  22981. * @returns the VertexData for the DashedLines
  22982. */
  22983. static CreateDashedLines(options: {
  22984. points: Vector3[];
  22985. dashSize?: number;
  22986. gapSize?: number;
  22987. dashNb?: number;
  22988. }): VertexData;
  22989. /**
  22990. * Creates the VertexData for a Ground
  22991. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22992. * - width the width (x direction) of the ground, optional, default 1
  22993. * - height the height (z direction) of the ground, optional, default 1
  22994. * - subdivisions the number of subdivisions per side, optional, default 1
  22995. * @returns the VertexData of the Ground
  22996. */
  22997. static CreateGround(options: {
  22998. width?: number;
  22999. height?: number;
  23000. subdivisions?: number;
  23001. subdivisionsX?: number;
  23002. subdivisionsY?: number;
  23003. }): VertexData;
  23004. /**
  23005. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23006. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23007. * * xmin the ground minimum X coordinate, optional, default -1
  23008. * * zmin the ground minimum Z coordinate, optional, default -1
  23009. * * xmax the ground maximum X coordinate, optional, default 1
  23010. * * zmax the ground maximum Z coordinate, optional, default 1
  23011. * * 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}
  23012. * * 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}
  23013. * @returns the VertexData of the TiledGround
  23014. */
  23015. static CreateTiledGround(options: {
  23016. xmin: number;
  23017. zmin: number;
  23018. xmax: number;
  23019. zmax: number;
  23020. subdivisions?: {
  23021. w: number;
  23022. h: number;
  23023. };
  23024. precision?: {
  23025. w: number;
  23026. h: number;
  23027. };
  23028. }): VertexData;
  23029. /**
  23030. * Creates the VertexData of the Ground designed from a heightmap
  23031. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23032. * * width the width (x direction) of the ground
  23033. * * height the height (z direction) of the ground
  23034. * * subdivisions the number of subdivisions per side
  23035. * * minHeight the minimum altitude on the ground, optional, default 0
  23036. * * maxHeight the maximum altitude on the ground, optional default 1
  23037. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23038. * * buffer the array holding the image color data
  23039. * * bufferWidth the width of image
  23040. * * bufferHeight the height of image
  23041. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23042. * @returns the VertexData of the Ground designed from a heightmap
  23043. */
  23044. static CreateGroundFromHeightMap(options: {
  23045. width: number;
  23046. height: number;
  23047. subdivisions: number;
  23048. minHeight: number;
  23049. maxHeight: number;
  23050. colorFilter: Color3;
  23051. buffer: Uint8Array;
  23052. bufferWidth: number;
  23053. bufferHeight: number;
  23054. alphaFilter: number;
  23055. }): VertexData;
  23056. /**
  23057. * Creates the VertexData for a Plane
  23058. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23059. * * size sets the width and height of the plane to the value of size, optional default 1
  23060. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23061. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23062. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23063. * * 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)
  23064. * * 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)
  23065. * @returns the VertexData of the box
  23066. */
  23067. static CreatePlane(options: {
  23068. size?: number;
  23069. width?: number;
  23070. height?: number;
  23071. sideOrientation?: number;
  23072. frontUVs?: Vector4;
  23073. backUVs?: Vector4;
  23074. }): VertexData;
  23075. /**
  23076. * Creates the VertexData of the Disc or regular Polygon
  23077. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23078. * * radius the radius of the disc, optional default 0.5
  23079. * * tessellation the number of polygon sides, optional, default 64
  23080. * * 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
  23081. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23082. * * 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)
  23083. * * 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)
  23084. * @returns the VertexData of the box
  23085. */
  23086. static CreateDisc(options: {
  23087. radius?: number;
  23088. tessellation?: number;
  23089. arc?: number;
  23090. sideOrientation?: number;
  23091. frontUVs?: Vector4;
  23092. backUVs?: Vector4;
  23093. }): VertexData;
  23094. /**
  23095. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23096. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23097. * @param polygon a mesh built from polygonTriangulation.build()
  23098. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23099. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23100. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23101. * @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)
  23102. * @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)
  23103. * @returns the VertexData of the Polygon
  23104. */
  23105. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23106. /**
  23107. * Creates the VertexData of the IcoSphere
  23108. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23109. * * radius the radius of the IcoSphere, optional default 1
  23110. * * radiusX allows stretching in the x direction, optional, default radius
  23111. * * radiusY allows stretching in the y direction, optional, default radius
  23112. * * radiusZ allows stretching in the z direction, optional, default radius
  23113. * * flat when true creates a flat shaded mesh, optional, default true
  23114. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23116. * * 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)
  23117. * * 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)
  23118. * @returns the VertexData of the IcoSphere
  23119. */
  23120. static CreateIcoSphere(options: {
  23121. radius?: number;
  23122. radiusX?: number;
  23123. radiusY?: number;
  23124. radiusZ?: number;
  23125. flat?: boolean;
  23126. subdivisions?: number;
  23127. sideOrientation?: number;
  23128. frontUVs?: Vector4;
  23129. backUVs?: Vector4;
  23130. }): VertexData;
  23131. /**
  23132. * Creates the VertexData for a Polyhedron
  23133. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23134. * * type provided types are:
  23135. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23136. * * 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)
  23137. * * size the size of the IcoSphere, optional default 1
  23138. * * sizeX allows stretching in the x direction, optional, default size
  23139. * * sizeY allows stretching in the y direction, optional, default size
  23140. * * sizeZ allows stretching in the z direction, optional, default size
  23141. * * 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
  23142. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23143. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23144. * * flat when true creates a flat shaded mesh, optional, default true
  23145. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23147. * * 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)
  23148. * * 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)
  23149. * @returns the VertexData of the Polyhedron
  23150. */
  23151. static CreatePolyhedron(options: {
  23152. type?: number;
  23153. size?: number;
  23154. sizeX?: number;
  23155. sizeY?: number;
  23156. sizeZ?: number;
  23157. custom?: any;
  23158. faceUV?: Vector4[];
  23159. faceColors?: Color4[];
  23160. flat?: boolean;
  23161. sideOrientation?: number;
  23162. frontUVs?: Vector4;
  23163. backUVs?: Vector4;
  23164. }): VertexData;
  23165. /**
  23166. * Creates the VertexData for a TorusKnot
  23167. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23168. * * radius the radius of the torus knot, optional, default 2
  23169. * * tube the thickness of the tube, optional, default 0.5
  23170. * * radialSegments the number of sides on each tube segments, optional, default 32
  23171. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23172. * * p the number of windings around the z axis, optional, default 2
  23173. * * q the number of windings around the x axis, optional, default 3
  23174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23175. * * 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)
  23176. * * 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)
  23177. * @returns the VertexData of the Torus Knot
  23178. */
  23179. static CreateTorusKnot(options: {
  23180. radius?: number;
  23181. tube?: number;
  23182. radialSegments?: number;
  23183. tubularSegments?: number;
  23184. p?: number;
  23185. q?: number;
  23186. sideOrientation?: number;
  23187. frontUVs?: Vector4;
  23188. backUVs?: Vector4;
  23189. }): VertexData;
  23190. /**
  23191. * Compute normals for given positions and indices
  23192. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23193. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23194. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23195. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23196. * * facetNormals : optional array of facet normals (vector3)
  23197. * * facetPositions : optional array of facet positions (vector3)
  23198. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23199. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23200. * * bInfo : optional bounding info, required for facetPartitioning computation
  23201. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23202. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23203. * * useRightHandedSystem: optional boolean to for right handed system computation
  23204. * * depthSort : optional boolean to enable the facet depth sort computation
  23205. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23206. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23207. */
  23208. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23209. facetNormals?: any;
  23210. facetPositions?: any;
  23211. facetPartitioning?: any;
  23212. ratio?: number;
  23213. bInfo?: any;
  23214. bbSize?: Vector3;
  23215. subDiv?: any;
  23216. useRightHandedSystem?: boolean;
  23217. depthSort?: boolean;
  23218. distanceTo?: Vector3;
  23219. depthSortedFacets?: any;
  23220. }): void;
  23221. /** @hidden */
  23222. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23223. /**
  23224. * Applies VertexData created from the imported parameters to the geometry
  23225. * @param parsedVertexData the parsed data from an imported file
  23226. * @param geometry the geometry to apply the VertexData to
  23227. */
  23228. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23229. }
  23230. }
  23231. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23232. import { Nullable } from "babylonjs/types";
  23233. import { Scene } from "babylonjs/scene";
  23234. import { Vector4 } from "babylonjs/Maths/math";
  23235. import { Mesh } from "babylonjs/Meshes/mesh";
  23236. /**
  23237. * Class containing static functions to help procedurally build meshes
  23238. */
  23239. export class DiscBuilder {
  23240. /**
  23241. * Creates a plane polygonal mesh. By default, this is a disc
  23242. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23243. * * 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
  23244. * * 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
  23245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23248. * @param name defines the name of the mesh
  23249. * @param options defines the options used to create the mesh
  23250. * @param scene defines the hosting scene
  23251. * @returns the plane polygonal mesh
  23252. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23253. */
  23254. static CreateDisc(name: string, options: {
  23255. radius?: number;
  23256. tessellation?: number;
  23257. arc?: number;
  23258. updatable?: boolean;
  23259. sideOrientation?: number;
  23260. frontUVs?: Vector4;
  23261. backUVs?: Vector4;
  23262. }, scene?: Nullable<Scene>): Mesh;
  23263. }
  23264. }
  23265. declare module "babylonjs/Particles/solidParticleSystem" {
  23266. import { Vector3 } from "babylonjs/Maths/math";
  23267. import { Mesh } from "babylonjs/Meshes/mesh";
  23268. import { Scene, IDisposable } from "babylonjs/scene";
  23269. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23270. /**
  23271. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23272. *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.
  23273. * The SPS is also a particle system. It provides some methods to manage the particles.
  23274. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23275. *
  23276. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23277. */
  23278. export class SolidParticleSystem implements IDisposable {
  23279. /**
  23280. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23281. * Example : var p = SPS.particles[i];
  23282. */
  23283. particles: SolidParticle[];
  23284. /**
  23285. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23286. */
  23287. nbParticles: number;
  23288. /**
  23289. * If the particles must ever face the camera (default false). Useful for planar particles.
  23290. */
  23291. billboard: boolean;
  23292. /**
  23293. * Recompute normals when adding a shape
  23294. */
  23295. recomputeNormals: boolean;
  23296. /**
  23297. * This a counter ofr your own usage. It's not set by any SPS functions.
  23298. */
  23299. counter: number;
  23300. /**
  23301. * The SPS name. This name is also given to the underlying mesh.
  23302. */
  23303. name: string;
  23304. /**
  23305. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23306. */
  23307. mesh: Mesh;
  23308. /**
  23309. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23310. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23311. */
  23312. vars: any;
  23313. /**
  23314. * This array is populated when the SPS is set as 'pickable'.
  23315. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23316. * Each element of this array is an object `{idx: int, faceId: int}`.
  23317. * `idx` is the picked particle index in the `SPS.particles` array
  23318. * `faceId` is the picked face index counted within this particle.
  23319. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23320. */
  23321. pickedParticles: {
  23322. idx: number;
  23323. faceId: number;
  23324. }[];
  23325. /**
  23326. * This array is populated when `enableDepthSort` is set to true.
  23327. * Each element of this array is an instance of the class DepthSortedParticle.
  23328. */
  23329. depthSortedParticles: DepthSortedParticle[];
  23330. /**
  23331. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23332. * @hidden
  23333. */
  23334. _bSphereOnly: boolean;
  23335. /**
  23336. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23337. * @hidden
  23338. */
  23339. _bSphereRadiusFactor: number;
  23340. private _scene;
  23341. private _positions;
  23342. private _indices;
  23343. private _normals;
  23344. private _colors;
  23345. private _uvs;
  23346. private _indices32;
  23347. private _positions32;
  23348. private _normals32;
  23349. private _fixedNormal32;
  23350. private _colors32;
  23351. private _uvs32;
  23352. private _index;
  23353. private _updatable;
  23354. private _pickable;
  23355. private _isVisibilityBoxLocked;
  23356. private _alwaysVisible;
  23357. private _depthSort;
  23358. private _shapeCounter;
  23359. private _copy;
  23360. private _color;
  23361. private _computeParticleColor;
  23362. private _computeParticleTexture;
  23363. private _computeParticleRotation;
  23364. private _computeParticleVertex;
  23365. private _computeBoundingBox;
  23366. private _depthSortParticles;
  23367. private _camera;
  23368. private _mustUnrotateFixedNormals;
  23369. private _particlesIntersect;
  23370. private _needs32Bits;
  23371. /**
  23372. * Creates a SPS (Solid Particle System) object.
  23373. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23374. * @param scene (Scene) is the scene in which the SPS is added.
  23375. * @param options defines the options of the sps e.g.
  23376. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23377. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23378. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23379. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23380. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23381. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23382. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23383. */
  23384. constructor(name: string, scene: Scene, options?: {
  23385. updatable?: boolean;
  23386. isPickable?: boolean;
  23387. enableDepthSort?: boolean;
  23388. particleIntersection?: boolean;
  23389. boundingSphereOnly?: boolean;
  23390. bSphereRadiusFactor?: number;
  23391. });
  23392. /**
  23393. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23394. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23395. * @returns the created mesh
  23396. */
  23397. buildMesh(): Mesh;
  23398. /**
  23399. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23400. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23401. * Thus the particles generated from `digest()` have their property `position` set yet.
  23402. * @param mesh ( Mesh ) is the mesh to be digested
  23403. * @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
  23404. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23405. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23406. * @returns the current SPS
  23407. */
  23408. digest(mesh: Mesh, options?: {
  23409. facetNb?: number;
  23410. number?: number;
  23411. delta?: number;
  23412. }): SolidParticleSystem;
  23413. private _unrotateFixedNormals;
  23414. private _resetCopy;
  23415. private _meshBuilder;
  23416. private _posToShape;
  23417. private _uvsToShapeUV;
  23418. private _addParticle;
  23419. /**
  23420. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23421. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23422. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23423. * @param nb (positive integer) the number of particles to be created from this model
  23424. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23425. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23426. * @returns the number of shapes in the system
  23427. */
  23428. addShape(mesh: Mesh, nb: number, options?: {
  23429. positionFunction?: any;
  23430. vertexFunction?: any;
  23431. }): number;
  23432. private _rebuildParticle;
  23433. /**
  23434. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23435. * @returns the SPS.
  23436. */
  23437. rebuildMesh(): SolidParticleSystem;
  23438. /**
  23439. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23440. * This method calls `updateParticle()` for each particle of the SPS.
  23441. * For an animated SPS, it is usually called within the render loop.
  23442. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23443. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23444. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23445. * @returns the SPS.
  23446. */
  23447. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23448. /**
  23449. * Disposes the SPS.
  23450. */
  23451. dispose(): void;
  23452. /**
  23453. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23454. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23455. * @returns the SPS.
  23456. */
  23457. refreshVisibleSize(): SolidParticleSystem;
  23458. /**
  23459. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23460. * @param size the size (float) of the visibility box
  23461. * note : this doesn't lock the SPS mesh bounding box.
  23462. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23463. */
  23464. setVisibilityBox(size: number): void;
  23465. /**
  23466. * Gets whether the SPS as always visible or not
  23467. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23468. */
  23469. /**
  23470. * Sets the SPS as always visible or not
  23471. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23472. */
  23473. isAlwaysVisible: boolean;
  23474. /**
  23475. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23476. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23477. */
  23478. /**
  23479. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23480. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23481. */
  23482. isVisibilityBoxLocked: boolean;
  23483. /**
  23484. * Tells to `setParticles()` to compute the particle rotations or not.
  23485. * Default value : true. The SPS is faster when it's set to false.
  23486. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23487. */
  23488. /**
  23489. * Gets if `setParticles()` computes the particle rotations or not.
  23490. * Default value : true. The SPS is faster when it's set to false.
  23491. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23492. */
  23493. computeParticleRotation: boolean;
  23494. /**
  23495. * Tells to `setParticles()` to compute the particle colors or not.
  23496. * Default value : true. The SPS is faster when it's set to false.
  23497. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23498. */
  23499. /**
  23500. * Gets if `setParticles()` computes the particle colors or not.
  23501. * Default value : true. The SPS is faster when it's set to false.
  23502. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23503. */
  23504. computeParticleColor: boolean;
  23505. /**
  23506. * Gets if `setParticles()` computes the particle textures or not.
  23507. * Default value : true. The SPS is faster when it's set to false.
  23508. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23509. */
  23510. computeParticleTexture: boolean;
  23511. /**
  23512. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23513. * Default value : false. The SPS is faster when it's set to false.
  23514. * Note : the particle custom vertex positions aren't stored values.
  23515. */
  23516. /**
  23517. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23518. * Default value : false. The SPS is faster when it's set to false.
  23519. * Note : the particle custom vertex positions aren't stored values.
  23520. */
  23521. computeParticleVertex: boolean;
  23522. /**
  23523. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23524. */
  23525. /**
  23526. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23527. */
  23528. computeBoundingBox: boolean;
  23529. /**
  23530. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23531. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23532. * Default : `true`
  23533. */
  23534. /**
  23535. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23536. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23537. * Default : `true`
  23538. */
  23539. depthSortParticles: boolean;
  23540. /**
  23541. * This function does nothing. It may be overwritten to set all the particle first values.
  23542. * The SPS doesn't call this function, you may have to call it by your own.
  23543. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23544. */
  23545. initParticles(): void;
  23546. /**
  23547. * This function does nothing. It may be overwritten to recycle a particle.
  23548. * The SPS doesn't call this function, you may have to call it by your own.
  23549. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23550. * @param particle The particle to recycle
  23551. * @returns the recycled particle
  23552. */
  23553. recycleParticle(particle: SolidParticle): SolidParticle;
  23554. /**
  23555. * Updates a particle : this function should be overwritten by the user.
  23556. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23557. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23558. * @example : just set a particle position or velocity and recycle conditions
  23559. * @param particle The particle to update
  23560. * @returns the updated particle
  23561. */
  23562. updateParticle(particle: SolidParticle): SolidParticle;
  23563. /**
  23564. * Updates a vertex of a particle : it can be overwritten by the user.
  23565. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23566. * @param particle the current particle
  23567. * @param vertex the current index of the current particle
  23568. * @param pt the index of the current vertex in the particle shape
  23569. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23570. * @example : just set a vertex particle position
  23571. * @returns the updated vertex
  23572. */
  23573. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23574. /**
  23575. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23576. * This does nothing and may be overwritten by the user.
  23577. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23578. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23579. * @param update the boolean update value actually passed to setParticles()
  23580. */
  23581. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23582. /**
  23583. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23584. * This will be passed three parameters.
  23585. * This does nothing and may be overwritten by the user.
  23586. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23587. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23588. * @param update the boolean update value actually passed to setParticles()
  23589. */
  23590. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23591. }
  23592. }
  23593. declare module "babylonjs/Particles/solidParticle" {
  23594. import { Nullable } from "babylonjs/types";
  23595. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23596. import { Mesh } from "babylonjs/Meshes/mesh";
  23597. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23598. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23599. /**
  23600. * Represents one particle of a solid particle system.
  23601. */
  23602. export class SolidParticle {
  23603. /**
  23604. * particle global index
  23605. */
  23606. idx: number;
  23607. /**
  23608. * The color of the particle
  23609. */
  23610. color: Nullable<Color4>;
  23611. /**
  23612. * The world space position of the particle.
  23613. */
  23614. position: Vector3;
  23615. /**
  23616. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23617. */
  23618. rotation: Vector3;
  23619. /**
  23620. * The world space rotation quaternion of the particle.
  23621. */
  23622. rotationQuaternion: Nullable<Quaternion>;
  23623. /**
  23624. * The scaling of the particle.
  23625. */
  23626. scaling: Vector3;
  23627. /**
  23628. * The uvs of the particle.
  23629. */
  23630. uvs: Vector4;
  23631. /**
  23632. * The current speed of the particle.
  23633. */
  23634. velocity: Vector3;
  23635. /**
  23636. * The pivot point in the particle local space.
  23637. */
  23638. pivot: Vector3;
  23639. /**
  23640. * Must the particle be translated from its pivot point in its local space ?
  23641. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23642. * Default : false
  23643. */
  23644. translateFromPivot: boolean;
  23645. /**
  23646. * Is the particle active or not ?
  23647. */
  23648. alive: boolean;
  23649. /**
  23650. * Is the particle visible or not ?
  23651. */
  23652. isVisible: boolean;
  23653. /**
  23654. * Index of this particle in the global "positions" array (Internal use)
  23655. * @hidden
  23656. */
  23657. _pos: number;
  23658. /**
  23659. * @hidden Index of this particle in the global "indices" array (Internal use)
  23660. */
  23661. _ind: number;
  23662. /**
  23663. * @hidden ModelShape of this particle (Internal use)
  23664. */
  23665. _model: ModelShape;
  23666. /**
  23667. * ModelShape id of this particle
  23668. */
  23669. shapeId: number;
  23670. /**
  23671. * Index of the particle in its shape id (Internal use)
  23672. */
  23673. idxInShape: number;
  23674. /**
  23675. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23676. */
  23677. _modelBoundingInfo: BoundingInfo;
  23678. /**
  23679. * @hidden Particle BoundingInfo object (Internal use)
  23680. */
  23681. _boundingInfo: BoundingInfo;
  23682. /**
  23683. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23684. */
  23685. _sps: SolidParticleSystem;
  23686. /**
  23687. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23688. */
  23689. _stillInvisible: boolean;
  23690. /**
  23691. * @hidden Last computed particle rotation matrix
  23692. */
  23693. _rotationMatrix: number[];
  23694. /**
  23695. * Parent particle Id, if any.
  23696. * Default null.
  23697. */
  23698. parentId: Nullable<number>;
  23699. /**
  23700. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23701. * The possible values are :
  23702. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23703. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23704. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23705. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23706. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23707. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23708. * */
  23709. cullingStrategy: number;
  23710. /**
  23711. * @hidden Internal global position in the SPS.
  23712. */
  23713. _globalPosition: Vector3;
  23714. /**
  23715. * Creates a Solid Particle object.
  23716. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23717. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23718. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23719. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23720. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23721. * @param shapeId (integer) is the model shape identifier in the SPS.
  23722. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23723. * @param sps defines the sps it is associated to
  23724. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23725. */
  23726. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23727. /**
  23728. * Legacy support, changed scale to scaling
  23729. */
  23730. /**
  23731. * Legacy support, changed scale to scaling
  23732. */
  23733. scale: Vector3;
  23734. /**
  23735. * Legacy support, changed quaternion to rotationQuaternion
  23736. */
  23737. /**
  23738. * Legacy support, changed quaternion to rotationQuaternion
  23739. */
  23740. quaternion: Nullable<Quaternion>;
  23741. /**
  23742. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23743. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23744. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23745. * @returns true if it intersects
  23746. */
  23747. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23748. /**
  23749. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23750. * A particle is in the frustum if its bounding box intersects the frustum
  23751. * @param frustumPlanes defines the frustum to test
  23752. * @returns true if the particle is in the frustum planes
  23753. */
  23754. isInFrustum(frustumPlanes: Plane[]): boolean;
  23755. /**
  23756. * get the rotation matrix of the particle
  23757. * @hidden
  23758. */
  23759. getRotationMatrix(m: Matrix): void;
  23760. }
  23761. /**
  23762. * Represents the shape of the model used by one particle of a solid particle system.
  23763. * SPS internal tool, don't use it manually.
  23764. */
  23765. export class ModelShape {
  23766. /**
  23767. * The shape id
  23768. * @hidden
  23769. */
  23770. shapeID: number;
  23771. /**
  23772. * flat array of model positions (internal use)
  23773. * @hidden
  23774. */
  23775. _shape: Vector3[];
  23776. /**
  23777. * flat array of model UVs (internal use)
  23778. * @hidden
  23779. */
  23780. _shapeUV: number[];
  23781. /**
  23782. * length of the shape in the model indices array (internal use)
  23783. * @hidden
  23784. */
  23785. _indicesLength: number;
  23786. /**
  23787. * Custom position function (internal use)
  23788. * @hidden
  23789. */
  23790. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23791. /**
  23792. * Custom vertex function (internal use)
  23793. * @hidden
  23794. */
  23795. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23796. /**
  23797. * 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.
  23798. * SPS internal tool, don't use it manually.
  23799. * @hidden
  23800. */
  23801. 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>);
  23802. }
  23803. /**
  23804. * Represents a Depth Sorted Particle in the solid particle system.
  23805. */
  23806. export class DepthSortedParticle {
  23807. /**
  23808. * Index of the particle in the "indices" array
  23809. */
  23810. ind: number;
  23811. /**
  23812. * Length of the particle shape in the "indices" array
  23813. */
  23814. indicesLength: number;
  23815. /**
  23816. * Squared distance from the particle to the camera
  23817. */
  23818. sqDistance: number;
  23819. }
  23820. }
  23821. declare module "babylonjs/Meshes/abstractMesh" {
  23822. import { Observable } from "babylonjs/Misc/observable";
  23823. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23824. import { Camera } from "babylonjs/Cameras/camera";
  23825. import { Scene, IDisposable } from "babylonjs/scene";
  23826. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23827. import { Node } from "babylonjs/node";
  23828. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23829. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23830. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23831. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23832. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23833. import { Material } from "babylonjs/Materials/material";
  23834. import { Light } from "babylonjs/Lights/light";
  23835. import { Skeleton } from "babylonjs/Bones/skeleton";
  23836. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23837. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23838. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23839. import { Ray } from "babylonjs/Culling/ray";
  23840. import { Collider } from "babylonjs/Collisions/collider";
  23841. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23842. /**
  23843. * Class used to store all common mesh properties
  23844. */
  23845. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23846. /** No occlusion */
  23847. static OCCLUSION_TYPE_NONE: number;
  23848. /** Occlusion set to optimisitic */
  23849. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23850. /** Occlusion set to strict */
  23851. static OCCLUSION_TYPE_STRICT: number;
  23852. /** Use an accurante occlusion algorithm */
  23853. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23854. /** Use a conservative occlusion algorithm */
  23855. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23856. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23857. * Test order :
  23858. * Is the bounding sphere outside the frustum ?
  23859. * If not, are the bounding box vertices outside the frustum ?
  23860. * It not, then the cullable object is in the frustum.
  23861. */
  23862. static readonly CULLINGSTRATEGY_STANDARD: number;
  23863. /** Culling strategy : Bounding Sphere Only.
  23864. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23865. * It's also less accurate than the standard because some not visible objects can still be selected.
  23866. * Test : is the bounding sphere outside the frustum ?
  23867. * If not, then the cullable object is in the frustum.
  23868. */
  23869. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23870. /** Culling strategy : Optimistic Inclusion.
  23871. * This in an inclusion test first, then the standard exclusion test.
  23872. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23873. * 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.
  23874. * Anyway, it's as accurate as the standard strategy.
  23875. * Test :
  23876. * Is the cullable object bounding sphere center in the frustum ?
  23877. * If not, apply the default culling strategy.
  23878. */
  23879. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23880. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23881. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23882. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23883. * 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.
  23884. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23885. * Test :
  23886. * Is the cullable object bounding sphere center in the frustum ?
  23887. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23888. */
  23889. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23890. /**
  23891. * No billboard
  23892. */
  23893. static readonly BILLBOARDMODE_NONE: number;
  23894. /** Billboard on X axis */
  23895. static readonly BILLBOARDMODE_X: number;
  23896. /** Billboard on Y axis */
  23897. static readonly BILLBOARDMODE_Y: number;
  23898. /** Billboard on Z axis */
  23899. static readonly BILLBOARDMODE_Z: number;
  23900. /** Billboard on all axes */
  23901. static readonly BILLBOARDMODE_ALL: number;
  23902. private _facetData;
  23903. /**
  23904. * The culling strategy to use to check whether the mesh must be rendered or not.
  23905. * This value can be changed at any time and will be used on the next render mesh selection.
  23906. * The possible values are :
  23907. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23908. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23909. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23910. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23911. * Please read each static variable documentation to get details about the culling process.
  23912. * */
  23913. cullingStrategy: number;
  23914. /**
  23915. * Gets the number of facets in the mesh
  23916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23917. */
  23918. readonly facetNb: number;
  23919. /**
  23920. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23922. */
  23923. partitioningSubdivisions: number;
  23924. /**
  23925. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23926. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23928. */
  23929. partitioningBBoxRatio: number;
  23930. /**
  23931. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23932. * Works only for updatable meshes.
  23933. * Doesn't work with multi-materials
  23934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23935. */
  23936. mustDepthSortFacets: boolean;
  23937. /**
  23938. * The location (Vector3) where the facet depth sort must be computed from.
  23939. * By default, the active camera position.
  23940. * Used only when facet depth sort is enabled
  23941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23942. */
  23943. facetDepthSortFrom: Vector3;
  23944. /**
  23945. * gets a boolean indicating if facetData is enabled
  23946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23947. */
  23948. readonly isFacetDataEnabled: boolean;
  23949. /** @hidden */
  23950. _updateNonUniformScalingState(value: boolean): boolean;
  23951. /**
  23952. * An event triggered when this mesh collides with another one
  23953. */
  23954. onCollideObservable: Observable<AbstractMesh>;
  23955. private _onCollideObserver;
  23956. /** Set a function to call when this mesh collides with another one */
  23957. onCollide: () => void;
  23958. /**
  23959. * An event triggered when the collision's position changes
  23960. */
  23961. onCollisionPositionChangeObservable: Observable<Vector3>;
  23962. private _onCollisionPositionChangeObserver;
  23963. /** Set a function to call when the collision's position changes */
  23964. onCollisionPositionChange: () => void;
  23965. /**
  23966. * An event triggered when material is changed
  23967. */
  23968. onMaterialChangedObservable: Observable<AbstractMesh>;
  23969. /**
  23970. * Gets or sets the orientation for POV movement & rotation
  23971. */
  23972. definedFacingForward: boolean;
  23973. /** @hidden */
  23974. _occlusionQuery: Nullable<WebGLQuery>;
  23975. private _visibility;
  23976. /**
  23977. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23978. */
  23979. /**
  23980. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23981. */
  23982. visibility: number;
  23983. /** Gets or sets the alpha index used to sort transparent meshes
  23984. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23985. */
  23986. alphaIndex: number;
  23987. /**
  23988. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23989. */
  23990. isVisible: boolean;
  23991. /**
  23992. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23993. */
  23994. isPickable: boolean;
  23995. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23996. showSubMeshesBoundingBox: boolean;
  23997. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23998. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23999. */
  24000. isBlocker: boolean;
  24001. /**
  24002. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24003. */
  24004. enablePointerMoveEvents: boolean;
  24005. /**
  24006. * Specifies the rendering group id for this mesh (0 by default)
  24007. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24008. */
  24009. renderingGroupId: number;
  24010. private _material;
  24011. /** Gets or sets current material */
  24012. material: Nullable<Material>;
  24013. private _receiveShadows;
  24014. /**
  24015. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24016. * @see http://doc.babylonjs.com/babylon101/shadows
  24017. */
  24018. receiveShadows: boolean;
  24019. /** Defines color to use when rendering outline */
  24020. outlineColor: Color3;
  24021. /** Define width to use when rendering outline */
  24022. outlineWidth: number;
  24023. /** Defines color to use when rendering overlay */
  24024. overlayColor: Color3;
  24025. /** Defines alpha to use when rendering overlay */
  24026. overlayAlpha: number;
  24027. private _hasVertexAlpha;
  24028. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24029. hasVertexAlpha: boolean;
  24030. private _useVertexColors;
  24031. /** 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) */
  24032. useVertexColors: boolean;
  24033. private _computeBonesUsingShaders;
  24034. /**
  24035. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24036. */
  24037. computeBonesUsingShaders: boolean;
  24038. private _numBoneInfluencers;
  24039. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24040. numBoneInfluencers: number;
  24041. private _applyFog;
  24042. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24043. applyFog: boolean;
  24044. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24045. useOctreeForRenderingSelection: boolean;
  24046. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24047. useOctreeForPicking: boolean;
  24048. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24049. useOctreeForCollisions: boolean;
  24050. private _layerMask;
  24051. /**
  24052. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24053. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24054. */
  24055. layerMask: number;
  24056. /**
  24057. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24058. */
  24059. alwaysSelectAsActiveMesh: boolean;
  24060. /**
  24061. * Gets or sets the current action manager
  24062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24063. */
  24064. actionManager: Nullable<AbstractActionManager>;
  24065. private _checkCollisions;
  24066. private _collisionMask;
  24067. private _collisionGroup;
  24068. /**
  24069. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24070. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24071. */
  24072. ellipsoid: Vector3;
  24073. /**
  24074. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24076. */
  24077. ellipsoidOffset: Vector3;
  24078. private _collider;
  24079. private _oldPositionForCollisions;
  24080. private _diffPositionForCollisions;
  24081. /**
  24082. * Gets or sets a collision mask used to mask collisions (default is -1).
  24083. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24084. */
  24085. collisionMask: number;
  24086. /**
  24087. * Gets or sets the current collision group mask (-1 by default).
  24088. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24089. */
  24090. collisionGroup: number;
  24091. /**
  24092. * Defines edge width used when edgesRenderer is enabled
  24093. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24094. */
  24095. edgesWidth: number;
  24096. /**
  24097. * Defines edge color used when edgesRenderer is enabled
  24098. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24099. */
  24100. edgesColor: Color4;
  24101. /** @hidden */
  24102. _edgesRenderer: Nullable<IEdgesRenderer>;
  24103. /** @hidden */
  24104. _masterMesh: Nullable<AbstractMesh>;
  24105. /** @hidden */
  24106. _boundingInfo: Nullable<BoundingInfo>;
  24107. /** @hidden */
  24108. _renderId: number;
  24109. /**
  24110. * Gets or sets the list of subMeshes
  24111. * @see http://doc.babylonjs.com/how_to/multi_materials
  24112. */
  24113. subMeshes: SubMesh[];
  24114. /** @hidden */
  24115. _intersectionsInProgress: AbstractMesh[];
  24116. /** @hidden */
  24117. _unIndexed: boolean;
  24118. /** @hidden */
  24119. _lightSources: Light[];
  24120. /** @hidden */
  24121. readonly _positions: Nullable<Vector3[]>;
  24122. /** @hidden */
  24123. _waitingActions: any;
  24124. /** @hidden */
  24125. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24126. private _skeleton;
  24127. /** @hidden */
  24128. _bonesTransformMatrices: Nullable<Float32Array>;
  24129. /**
  24130. * Gets or sets a skeleton to apply skining transformations
  24131. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24132. */
  24133. skeleton: Nullable<Skeleton>;
  24134. /**
  24135. * An event triggered when the mesh is rebuilt.
  24136. */
  24137. onRebuildObservable: Observable<AbstractMesh>;
  24138. /**
  24139. * Creates a new AbstractMesh
  24140. * @param name defines the name of the mesh
  24141. * @param scene defines the hosting scene
  24142. */
  24143. constructor(name: string, scene?: Nullable<Scene>);
  24144. /**
  24145. * Returns the string "AbstractMesh"
  24146. * @returns "AbstractMesh"
  24147. */
  24148. getClassName(): string;
  24149. /**
  24150. * Gets a string representation of the current mesh
  24151. * @param fullDetails defines a boolean indicating if full details must be included
  24152. * @returns a string representation of the current mesh
  24153. */
  24154. toString(fullDetails?: boolean): string;
  24155. /** @hidden */
  24156. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24157. /** @hidden */
  24158. _rebuild(): void;
  24159. /** @hidden */
  24160. _resyncLightSources(): void;
  24161. /** @hidden */
  24162. _resyncLighSource(light: Light): void;
  24163. /** @hidden */
  24164. _unBindEffect(): void;
  24165. /** @hidden */
  24166. _removeLightSource(light: Light): void;
  24167. private _markSubMeshesAsDirty;
  24168. /** @hidden */
  24169. _markSubMeshesAsLightDirty(): void;
  24170. /** @hidden */
  24171. _markSubMeshesAsAttributesDirty(): void;
  24172. /** @hidden */
  24173. _markSubMeshesAsMiscDirty(): void;
  24174. /**
  24175. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24176. */
  24177. scaling: Vector3;
  24178. /**
  24179. * Returns true if the mesh is blocked. Implemented by child classes
  24180. */
  24181. readonly isBlocked: boolean;
  24182. /**
  24183. * Returns the mesh itself by default. Implemented by child classes
  24184. * @param camera defines the camera to use to pick the right LOD level
  24185. * @returns the currentAbstractMesh
  24186. */
  24187. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24188. /**
  24189. * Returns 0 by default. Implemented by child classes
  24190. * @returns an integer
  24191. */
  24192. getTotalVertices(): number;
  24193. /**
  24194. * Returns a positive integer : the total number of indices in this mesh geometry.
  24195. * @returns the numner of indices or zero if the mesh has no geometry.
  24196. */
  24197. getTotalIndices(): number;
  24198. /**
  24199. * Returns null by default. Implemented by child classes
  24200. * @returns null
  24201. */
  24202. getIndices(): Nullable<IndicesArray>;
  24203. /**
  24204. * Returns the array of the requested vertex data kind. Implemented by child classes
  24205. * @param kind defines the vertex data kind to use
  24206. * @returns null
  24207. */
  24208. getVerticesData(kind: string): Nullable<FloatArray>;
  24209. /**
  24210. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24211. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24212. * Note that a new underlying VertexBuffer object is created each call.
  24213. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24214. * @param kind defines vertex data kind:
  24215. * * VertexBuffer.PositionKind
  24216. * * VertexBuffer.UVKind
  24217. * * VertexBuffer.UV2Kind
  24218. * * VertexBuffer.UV3Kind
  24219. * * VertexBuffer.UV4Kind
  24220. * * VertexBuffer.UV5Kind
  24221. * * VertexBuffer.UV6Kind
  24222. * * VertexBuffer.ColorKind
  24223. * * VertexBuffer.MatricesIndicesKind
  24224. * * VertexBuffer.MatricesIndicesExtraKind
  24225. * * VertexBuffer.MatricesWeightsKind
  24226. * * VertexBuffer.MatricesWeightsExtraKind
  24227. * @param data defines the data source
  24228. * @param updatable defines if the data must be flagged as updatable (or static)
  24229. * @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
  24230. * @returns the current mesh
  24231. */
  24232. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24233. /**
  24234. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24235. * If the mesh has no geometry, it is simply returned as it is.
  24236. * @param kind defines vertex data kind:
  24237. * * VertexBuffer.PositionKind
  24238. * * VertexBuffer.UVKind
  24239. * * VertexBuffer.UV2Kind
  24240. * * VertexBuffer.UV3Kind
  24241. * * VertexBuffer.UV4Kind
  24242. * * VertexBuffer.UV5Kind
  24243. * * VertexBuffer.UV6Kind
  24244. * * VertexBuffer.ColorKind
  24245. * * VertexBuffer.MatricesIndicesKind
  24246. * * VertexBuffer.MatricesIndicesExtraKind
  24247. * * VertexBuffer.MatricesWeightsKind
  24248. * * VertexBuffer.MatricesWeightsExtraKind
  24249. * @param data defines the data source
  24250. * @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
  24251. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24252. * @returns the current mesh
  24253. */
  24254. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24255. /**
  24256. * Sets the mesh indices,
  24257. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24258. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24259. * @param totalVertices Defines the total number of vertices
  24260. * @returns the current mesh
  24261. */
  24262. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24263. /**
  24264. * Gets a boolean indicating if specific vertex data is present
  24265. * @param kind defines the vertex data kind to use
  24266. * @returns true is data kind is present
  24267. */
  24268. isVerticesDataPresent(kind: string): boolean;
  24269. /**
  24270. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24271. * @returns a BoundingInfo
  24272. */
  24273. getBoundingInfo(): BoundingInfo;
  24274. /**
  24275. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24276. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24277. * @returns the current mesh
  24278. */
  24279. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24280. /**
  24281. * Overwrite the current bounding info
  24282. * @param boundingInfo defines the new bounding info
  24283. * @returns the current mesh
  24284. */
  24285. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24286. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24287. readonly useBones: boolean;
  24288. /** @hidden */
  24289. _preActivate(): void;
  24290. /** @hidden */
  24291. _preActivateForIntermediateRendering(renderId: number): void;
  24292. /** @hidden */
  24293. _activate(renderId: number): void;
  24294. /**
  24295. * Gets the current world matrix
  24296. * @returns a Matrix
  24297. */
  24298. getWorldMatrix(): Matrix;
  24299. /** @hidden */
  24300. _getWorldMatrixDeterminant(): number;
  24301. /**
  24302. * Perform relative position change from the point of view of behind the front of the mesh.
  24303. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24304. * Supports definition of mesh facing forward or backward
  24305. * @param amountRight defines the distance on the right axis
  24306. * @param amountUp defines the distance on the up axis
  24307. * @param amountForward defines the distance on the forward axis
  24308. * @returns the current mesh
  24309. */
  24310. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24311. /**
  24312. * Calculate relative position change from the point of view of behind the front of the mesh.
  24313. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24314. * Supports definition of mesh facing forward or backward
  24315. * @param amountRight defines the distance on the right axis
  24316. * @param amountUp defines the distance on the up axis
  24317. * @param amountForward defines the distance on the forward axis
  24318. * @returns the new displacement vector
  24319. */
  24320. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24321. /**
  24322. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24323. * Supports definition of mesh facing forward or backward
  24324. * @param flipBack defines the flip
  24325. * @param twirlClockwise defines the twirl
  24326. * @param tiltRight defines the tilt
  24327. * @returns the current mesh
  24328. */
  24329. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24330. /**
  24331. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24332. * Supports definition of mesh facing forward or backward.
  24333. * @param flipBack defines the flip
  24334. * @param twirlClockwise defines the twirl
  24335. * @param tiltRight defines the tilt
  24336. * @returns the new rotation vector
  24337. */
  24338. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24339. /**
  24340. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24341. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24342. * @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
  24343. * @returns the new bounding vectors
  24344. */
  24345. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24346. min: Vector3;
  24347. max: Vector3;
  24348. };
  24349. /**
  24350. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24351. * This means the mesh underlying bounding box and sphere are recomputed.
  24352. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24353. * @returns the current mesh
  24354. */
  24355. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24356. /** @hidden */
  24357. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24358. /** @hidden */
  24359. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24360. /** @hidden */
  24361. _updateBoundingInfo(): AbstractMesh;
  24362. /** @hidden */
  24363. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24364. /** @hidden */
  24365. protected _afterComputeWorldMatrix(): void;
  24366. /**
  24367. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24368. * A mesh is in the frustum if its bounding box intersects the frustum
  24369. * @param frustumPlanes defines the frustum to test
  24370. * @returns true if the mesh is in the frustum planes
  24371. */
  24372. isInFrustum(frustumPlanes: Plane[]): boolean;
  24373. /**
  24374. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24375. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24376. * @param frustumPlanes defines the frustum to test
  24377. * @returns true if the mesh is completely in the frustum planes
  24378. */
  24379. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24380. /**
  24381. * True if the mesh intersects another mesh or a SolidParticle object
  24382. * @param mesh defines a target mesh or SolidParticle to test
  24383. * @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)
  24384. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24385. * @returns true if there is an intersection
  24386. */
  24387. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24388. /**
  24389. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24390. * @param point defines the point to test
  24391. * @returns true if there is an intersection
  24392. */
  24393. intersectsPoint(point: Vector3): boolean;
  24394. /**
  24395. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24396. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24397. */
  24398. checkCollisions: boolean;
  24399. /**
  24400. * Gets Collider object used to compute collisions (not physics)
  24401. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24402. */
  24403. readonly collider: Collider;
  24404. /**
  24405. * Move the mesh using collision engine
  24406. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24407. * @param displacement defines the requested displacement vector
  24408. * @returns the current mesh
  24409. */
  24410. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24411. private _onCollisionPositionChange;
  24412. /** @hidden */
  24413. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24414. /** @hidden */
  24415. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24416. /** @hidden */
  24417. _checkCollision(collider: Collider): AbstractMesh;
  24418. /** @hidden */
  24419. _generatePointsArray(): boolean;
  24420. /**
  24421. * Checks if the passed Ray intersects with the mesh
  24422. * @param ray defines the ray to use
  24423. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24424. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24425. * @returns the picking info
  24426. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24427. */
  24428. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24429. /**
  24430. * Clones the current mesh
  24431. * @param name defines the mesh name
  24432. * @param newParent defines the new mesh parent
  24433. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24434. * @returns the new mesh
  24435. */
  24436. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24437. /**
  24438. * Disposes all the submeshes of the current meshnp
  24439. * @returns the current mesh
  24440. */
  24441. releaseSubMeshes(): AbstractMesh;
  24442. /**
  24443. * Releases resources associated with this abstract mesh.
  24444. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24445. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24446. */
  24447. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24448. /**
  24449. * Adds the passed mesh as a child to the current mesh
  24450. * @param mesh defines the child mesh
  24451. * @returns the current mesh
  24452. */
  24453. addChild(mesh: AbstractMesh): AbstractMesh;
  24454. /**
  24455. * Removes the passed mesh from the current mesh children list
  24456. * @param mesh defines the child mesh
  24457. * @returns the current mesh
  24458. */
  24459. removeChild(mesh: AbstractMesh): AbstractMesh;
  24460. /** @hidden */
  24461. private _initFacetData;
  24462. /**
  24463. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24464. * This method can be called within the render loop.
  24465. * 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
  24466. * @returns the current mesh
  24467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24468. */
  24469. updateFacetData(): AbstractMesh;
  24470. /**
  24471. * Returns the facetLocalNormals array.
  24472. * The normals are expressed in the mesh local spac
  24473. * @returns an array of Vector3
  24474. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24475. */
  24476. getFacetLocalNormals(): Vector3[];
  24477. /**
  24478. * Returns the facetLocalPositions array.
  24479. * The facet positions are expressed in the mesh local space
  24480. * @returns an array of Vector3
  24481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24482. */
  24483. getFacetLocalPositions(): Vector3[];
  24484. /**
  24485. * Returns the facetLocalPartioning array
  24486. * @returns an array of array of numbers
  24487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24488. */
  24489. getFacetLocalPartitioning(): number[][];
  24490. /**
  24491. * Returns the i-th facet position in the world system.
  24492. * This method allocates a new Vector3 per call
  24493. * @param i defines the facet index
  24494. * @returns a new Vector3
  24495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24496. */
  24497. getFacetPosition(i: number): Vector3;
  24498. /**
  24499. * Sets the reference Vector3 with the i-th facet position in the world system
  24500. * @param i defines the facet index
  24501. * @param ref defines the target vector
  24502. * @returns the current mesh
  24503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24504. */
  24505. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24506. /**
  24507. * Returns the i-th facet normal in the world system.
  24508. * This method allocates a new Vector3 per call
  24509. * @param i defines the facet index
  24510. * @returns a new Vector3
  24511. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24512. */
  24513. getFacetNormal(i: number): Vector3;
  24514. /**
  24515. * Sets the reference Vector3 with the i-th facet normal in the world system
  24516. * @param i defines the facet index
  24517. * @param ref defines the target vector
  24518. * @returns the current mesh
  24519. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24520. */
  24521. getFacetNormalToRef(i: number, ref: Vector3): this;
  24522. /**
  24523. * 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)
  24524. * @param x defines x coordinate
  24525. * @param y defines y coordinate
  24526. * @param z defines z coordinate
  24527. * @returns the array of facet indexes
  24528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24529. */
  24530. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24531. /**
  24532. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24533. * @param projected sets as the (x,y,z) world projection on the facet
  24534. * @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
  24535. * @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
  24536. * @param x defines x coordinate
  24537. * @param y defines y coordinate
  24538. * @param z defines z coordinate
  24539. * @returns the face index if found (or null instead)
  24540. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24541. */
  24542. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24543. /**
  24544. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24545. * @param projected sets as the (x,y,z) local projection on the facet
  24546. * @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
  24547. * @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
  24548. * @param x defines x coordinate
  24549. * @param y defines y coordinate
  24550. * @param z defines z coordinate
  24551. * @returns the face index if found (or null instead)
  24552. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24553. */
  24554. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24555. /**
  24556. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24557. * @returns the parameters
  24558. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24559. */
  24560. getFacetDataParameters(): any;
  24561. /**
  24562. * Disables the feature FacetData and frees the related memory
  24563. * @returns the current mesh
  24564. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24565. */
  24566. disableFacetData(): AbstractMesh;
  24567. /**
  24568. * Updates the AbstractMesh indices array
  24569. * @param indices defines the data source
  24570. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24571. * @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)
  24572. * @returns the current mesh
  24573. */
  24574. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24575. /**
  24576. * Creates new normals data for the mesh
  24577. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24578. * @returns the current mesh
  24579. */
  24580. createNormals(updatable: boolean): AbstractMesh;
  24581. /**
  24582. * Align the mesh with a normal
  24583. * @param normal defines the normal to use
  24584. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24585. * @returns the current mesh
  24586. */
  24587. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24588. /** @hidden */
  24589. _checkOcclusionQuery(): boolean;
  24590. }
  24591. }
  24592. declare module "babylonjs/Actions/actionEvent" {
  24593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24594. import { Nullable } from "babylonjs/types";
  24595. import { Sprite } from "babylonjs/Sprites/sprite";
  24596. import { Scene } from "babylonjs/scene";
  24597. import { Vector2 } from "babylonjs/Maths/math";
  24598. /**
  24599. * Interface used to define ActionEvent
  24600. */
  24601. export interface IActionEvent {
  24602. /** The mesh or sprite that triggered the action */
  24603. source: any;
  24604. /** The X mouse cursor position at the time of the event */
  24605. pointerX: number;
  24606. /** The Y mouse cursor position at the time of the event */
  24607. pointerY: number;
  24608. /** The mesh that is currently pointed at (can be null) */
  24609. meshUnderPointer: Nullable<AbstractMesh>;
  24610. /** the original (browser) event that triggered the ActionEvent */
  24611. sourceEvent?: any;
  24612. /** additional data for the event */
  24613. additionalData?: any;
  24614. }
  24615. /**
  24616. * ActionEvent is the event being sent when an action is triggered.
  24617. */
  24618. export class ActionEvent implements IActionEvent {
  24619. /** The mesh or sprite that triggered the action */
  24620. source: any;
  24621. /** The X mouse cursor position at the time of the event */
  24622. pointerX: number;
  24623. /** The Y mouse cursor position at the time of the event */
  24624. pointerY: number;
  24625. /** The mesh that is currently pointed at (can be null) */
  24626. meshUnderPointer: Nullable<AbstractMesh>;
  24627. /** the original (browser) event that triggered the ActionEvent */
  24628. sourceEvent?: any;
  24629. /** additional data for the event */
  24630. additionalData?: any;
  24631. /**
  24632. * Creates a new ActionEvent
  24633. * @param source The mesh or sprite that triggered the action
  24634. * @param pointerX The X mouse cursor position at the time of the event
  24635. * @param pointerY The Y mouse cursor position at the time of the event
  24636. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24637. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24638. * @param additionalData additional data for the event
  24639. */
  24640. constructor(
  24641. /** The mesh or sprite that triggered the action */
  24642. source: any,
  24643. /** The X mouse cursor position at the time of the event */
  24644. pointerX: number,
  24645. /** The Y mouse cursor position at the time of the event */
  24646. pointerY: number,
  24647. /** The mesh that is currently pointed at (can be null) */
  24648. meshUnderPointer: Nullable<AbstractMesh>,
  24649. /** the original (browser) event that triggered the ActionEvent */
  24650. sourceEvent?: any,
  24651. /** additional data for the event */
  24652. additionalData?: any);
  24653. /**
  24654. * Helper function to auto-create an ActionEvent from a source mesh.
  24655. * @param source The source mesh that triggered the event
  24656. * @param evt The original (browser) event
  24657. * @param additionalData additional data for the event
  24658. * @returns the new ActionEvent
  24659. */
  24660. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24661. /**
  24662. * Helper function to auto-create an ActionEvent from a source sprite
  24663. * @param source The source sprite that triggered the event
  24664. * @param scene Scene associated with the sprite
  24665. * @param evt The original (browser) event
  24666. * @param additionalData additional data for the event
  24667. * @returns the new ActionEvent
  24668. */
  24669. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24670. /**
  24671. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24672. * @param scene the scene where the event occurred
  24673. * @param evt The original (browser) event
  24674. * @returns the new ActionEvent
  24675. */
  24676. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24677. /**
  24678. * Helper function to auto-create an ActionEvent from a primitive
  24679. * @param prim defines the target primitive
  24680. * @param pointerPos defines the pointer position
  24681. * @param evt The original (browser) event
  24682. * @param additionalData additional data for the event
  24683. * @returns the new ActionEvent
  24684. */
  24685. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24686. }
  24687. }
  24688. declare module "babylonjs/Actions/abstractActionManager" {
  24689. import { IDisposable } from "babylonjs/scene";
  24690. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  24691. import { IAction } from "babylonjs/Actions/action";
  24692. import { Nullable } from "babylonjs/types";
  24693. /**
  24694. * Abstract class used to decouple action Manager from scene and meshes.
  24695. * Do not instantiate.
  24696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24697. */
  24698. export abstract class AbstractActionManager implements IDisposable {
  24699. /** Gets the list of active triggers */
  24700. static Triggers: {
  24701. [key: string]: number;
  24702. };
  24703. /** Gets the cursor to use when hovering items */
  24704. hoverCursor: string;
  24705. /** Gets the list of actions */
  24706. actions: IAction[];
  24707. /**
  24708. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24709. */
  24710. isRecursive: boolean;
  24711. /**
  24712. * Releases all associated resources
  24713. */
  24714. abstract dispose(): void;
  24715. /**
  24716. * Does this action manager has pointer triggers
  24717. */
  24718. abstract readonly hasPointerTriggers: boolean;
  24719. /**
  24720. * Does this action manager has pick triggers
  24721. */
  24722. abstract readonly hasPickTriggers: boolean;
  24723. /**
  24724. * Process a specific trigger
  24725. * @param trigger defines the trigger to process
  24726. * @param evt defines the event details to be processed
  24727. */
  24728. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24729. /**
  24730. * Does this action manager handles actions of any of the given triggers
  24731. * @param triggers defines the triggers to be tested
  24732. * @return a boolean indicating whether one (or more) of the triggers is handled
  24733. */
  24734. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24735. /**
  24736. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24737. * speed.
  24738. * @param triggerA defines the trigger to be tested
  24739. * @param triggerB defines the trigger to be tested
  24740. * @return a boolean indicating whether one (or more) of the triggers is handled
  24741. */
  24742. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24743. /**
  24744. * Does this action manager handles actions of a given trigger
  24745. * @param trigger defines the trigger to be tested
  24746. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24747. * @return whether the trigger is handled
  24748. */
  24749. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24750. /**
  24751. * Serialize this manager to a JSON object
  24752. * @param name defines the property name to store this manager
  24753. * @returns a JSON representation of this manager
  24754. */
  24755. abstract serialize(name: string): any;
  24756. /**
  24757. * Registers an action to this action manager
  24758. * @param action defines the action to be registered
  24759. * @return the action amended (prepared) after registration
  24760. */
  24761. abstract registerAction(action: IAction): Nullable<IAction>;
  24762. /**
  24763. * Unregisters an action to this action manager
  24764. * @param action defines the action to be unregistered
  24765. * @return a boolean indicating whether the action has been unregistered
  24766. */
  24767. abstract unregisterAction(action: IAction): Boolean;
  24768. /**
  24769. * Does exist one action manager with at least one trigger
  24770. **/
  24771. static readonly HasTriggers: boolean;
  24772. /**
  24773. * Does exist one action manager with at least one pick trigger
  24774. **/
  24775. static readonly HasPickTriggers: boolean;
  24776. /**
  24777. * Does exist one action manager that handles actions of a given trigger
  24778. * @param trigger defines the trigger to be tested
  24779. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24780. **/
  24781. static HasSpecificTrigger(trigger: number): boolean;
  24782. }
  24783. }
  24784. declare module "babylonjs/node" {
  24785. import { Scene } from "babylonjs/scene";
  24786. import { Nullable } from "babylonjs/types";
  24787. import { Matrix } from "babylonjs/Maths/math";
  24788. import { Engine } from "babylonjs/Engines/engine";
  24789. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24790. import { Observable } from "babylonjs/Misc/observable";
  24791. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24792. import { Animatable } from "babylonjs/Animations/animatable";
  24793. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24794. import { Animation } from "babylonjs/Animations/animation";
  24795. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24797. /**
  24798. * Defines how a node can be built from a string name.
  24799. */
  24800. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24801. /**
  24802. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24803. */
  24804. export class Node implements IBehaviorAware<Node> {
  24805. /** @hidden */
  24806. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24807. private static _NodeConstructors;
  24808. /**
  24809. * Add a new node constructor
  24810. * @param type defines the type name of the node to construct
  24811. * @param constructorFunc defines the constructor function
  24812. */
  24813. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24814. /**
  24815. * Returns a node constructor based on type name
  24816. * @param type defines the type name
  24817. * @param name defines the new node name
  24818. * @param scene defines the hosting scene
  24819. * @param options defines optional options to transmit to constructors
  24820. * @returns the new constructor or null
  24821. */
  24822. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24823. /**
  24824. * Gets or sets the name of the node
  24825. */
  24826. name: string;
  24827. /**
  24828. * Gets or sets the id of the node
  24829. */
  24830. id: string;
  24831. /**
  24832. * Gets or sets the unique id of the node
  24833. */
  24834. uniqueId: number;
  24835. /**
  24836. * Gets or sets a string used to store user defined state for the node
  24837. */
  24838. state: string;
  24839. /**
  24840. * Gets or sets an object used to store user defined information for the node
  24841. */
  24842. metadata: any;
  24843. /**
  24844. * For internal use only. Please do not use.
  24845. */
  24846. reservedDataStore: any;
  24847. /**
  24848. * Gets or sets a boolean used to define if the node must be serialized
  24849. */
  24850. doNotSerialize: boolean;
  24851. /** @hidden */
  24852. _isDisposed: boolean;
  24853. /**
  24854. * Gets a list of Animations associated with the node
  24855. */
  24856. animations: import("babylonjs/Animations/animation").Animation[];
  24857. protected _ranges: {
  24858. [name: string]: Nullable<AnimationRange>;
  24859. };
  24860. /**
  24861. * Callback raised when the node is ready to be used
  24862. */
  24863. onReady: (node: Node) => void;
  24864. private _isEnabled;
  24865. private _isParentEnabled;
  24866. private _isReady;
  24867. /** @hidden */
  24868. _currentRenderId: number;
  24869. private _parentRenderId;
  24870. protected _childRenderId: number;
  24871. /** @hidden */
  24872. _waitingParentId: Nullable<string>;
  24873. /** @hidden */
  24874. _scene: Scene;
  24875. /** @hidden */
  24876. _cache: any;
  24877. private _parentNode;
  24878. private _children;
  24879. /** @hidden */
  24880. _worldMatrix: Matrix;
  24881. /** @hidden */
  24882. _worldMatrixDeterminant: number;
  24883. /** @hidden */
  24884. private _sceneRootNodesIndex;
  24885. /**
  24886. * Gets a boolean indicating if the node has been disposed
  24887. * @returns true if the node was disposed
  24888. */
  24889. isDisposed(): boolean;
  24890. /**
  24891. * Gets or sets the parent of the node
  24892. */
  24893. parent: Nullable<Node>;
  24894. private addToSceneRootNodes;
  24895. private removeFromSceneRootNodes;
  24896. private _animationPropertiesOverride;
  24897. /**
  24898. * Gets or sets the animation properties override
  24899. */
  24900. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24901. /**
  24902. * Gets a string idenfifying the name of the class
  24903. * @returns "Node" string
  24904. */
  24905. getClassName(): string;
  24906. /** @hidden */
  24907. readonly _isNode: boolean;
  24908. /**
  24909. * An event triggered when the mesh is disposed
  24910. */
  24911. onDisposeObservable: Observable<Node>;
  24912. private _onDisposeObserver;
  24913. /**
  24914. * Sets a callback that will be raised when the node will be disposed
  24915. */
  24916. onDispose: () => void;
  24917. /**
  24918. * Creates a new Node
  24919. * @param name the name and id to be given to this node
  24920. * @param scene the scene this node will be added to
  24921. * @param addToRootNodes the node will be added to scene.rootNodes
  24922. */
  24923. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24924. /**
  24925. * Gets the scene of the node
  24926. * @returns a scene
  24927. */
  24928. getScene(): Scene;
  24929. /**
  24930. * Gets the engine of the node
  24931. * @returns a Engine
  24932. */
  24933. getEngine(): Engine;
  24934. private _behaviors;
  24935. /**
  24936. * Attach a behavior to the node
  24937. * @see http://doc.babylonjs.com/features/behaviour
  24938. * @param behavior defines the behavior to attach
  24939. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24940. * @returns the current Node
  24941. */
  24942. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24943. /**
  24944. * Remove an attached behavior
  24945. * @see http://doc.babylonjs.com/features/behaviour
  24946. * @param behavior defines the behavior to attach
  24947. * @returns the current Node
  24948. */
  24949. removeBehavior(behavior: Behavior<Node>): Node;
  24950. /**
  24951. * Gets the list of attached behaviors
  24952. * @see http://doc.babylonjs.com/features/behaviour
  24953. */
  24954. readonly behaviors: Behavior<Node>[];
  24955. /**
  24956. * Gets an attached behavior by name
  24957. * @param name defines the name of the behavior to look for
  24958. * @see http://doc.babylonjs.com/features/behaviour
  24959. * @returns null if behavior was not found else the requested behavior
  24960. */
  24961. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24962. /**
  24963. * Returns the latest update of the World matrix
  24964. * @returns a Matrix
  24965. */
  24966. getWorldMatrix(): Matrix;
  24967. /** @hidden */
  24968. _getWorldMatrixDeterminant(): number;
  24969. /**
  24970. * Returns directly the latest state of the mesh World matrix.
  24971. * A Matrix is returned.
  24972. */
  24973. readonly worldMatrixFromCache: Matrix;
  24974. /** @hidden */
  24975. _initCache(): void;
  24976. /** @hidden */
  24977. updateCache(force?: boolean): void;
  24978. /** @hidden */
  24979. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24980. /** @hidden */
  24981. _updateCache(ignoreParentClass?: boolean): void;
  24982. /** @hidden */
  24983. _isSynchronized(): boolean;
  24984. /** @hidden */
  24985. _markSyncedWithParent(): void;
  24986. /** @hidden */
  24987. isSynchronizedWithParent(): boolean;
  24988. /** @hidden */
  24989. isSynchronized(): boolean;
  24990. /**
  24991. * Is this node ready to be used/rendered
  24992. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24993. * @return true if the node is ready
  24994. */
  24995. isReady(completeCheck?: boolean): boolean;
  24996. /**
  24997. * Is this node enabled?
  24998. * 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
  24999. * @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
  25000. * @return whether this node (and its parent) is enabled
  25001. */
  25002. isEnabled(checkAncestors?: boolean): boolean;
  25003. /** @hidden */
  25004. protected _syncParentEnabledState(): void;
  25005. /**
  25006. * Set the enabled state of this node
  25007. * @param value defines the new enabled state
  25008. */
  25009. setEnabled(value: boolean): void;
  25010. /**
  25011. * Is this node a descendant of the given node?
  25012. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25013. * @param ancestor defines the parent node to inspect
  25014. * @returns a boolean indicating if this node is a descendant of the given node
  25015. */
  25016. isDescendantOf(ancestor: Node): boolean;
  25017. /** @hidden */
  25018. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25019. /**
  25020. * Will return all nodes that have this node as ascendant
  25021. * @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
  25022. * @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
  25023. * @return all children nodes of all types
  25024. */
  25025. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25026. /**
  25027. * Get all child-meshes of this node
  25028. * @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)
  25029. * @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
  25030. * @returns an array of AbstractMesh
  25031. */
  25032. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25033. /**
  25034. * Get all direct children of this node
  25035. * @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
  25036. * @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)
  25037. * @returns an array of Node
  25038. */
  25039. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25040. /** @hidden */
  25041. _setReady(state: boolean): void;
  25042. /**
  25043. * Get an animation by name
  25044. * @param name defines the name of the animation to look for
  25045. * @returns null if not found else the requested animation
  25046. */
  25047. getAnimationByName(name: string): Nullable<Animation>;
  25048. /**
  25049. * Creates an animation range for this node
  25050. * @param name defines the name of the range
  25051. * @param from defines the starting key
  25052. * @param to defines the end key
  25053. */
  25054. createAnimationRange(name: string, from: number, to: number): void;
  25055. /**
  25056. * Delete a specific animation range
  25057. * @param name defines the name of the range to delete
  25058. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25059. */
  25060. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25061. /**
  25062. * Get an animation range by name
  25063. * @param name defines the name of the animation range to look for
  25064. * @returns null if not found else the requested animation range
  25065. */
  25066. getAnimationRange(name: string): Nullable<AnimationRange>;
  25067. /**
  25068. * Gets the list of all animation ranges defined on this node
  25069. * @returns an array
  25070. */
  25071. getAnimationRanges(): Nullable<AnimationRange>[];
  25072. /**
  25073. * Will start the animation sequence
  25074. * @param name defines the range frames for animation sequence
  25075. * @param loop defines if the animation should loop (false by default)
  25076. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25077. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25078. * @returns the object created for this animation. If range does not exist, it will return null
  25079. */
  25080. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25081. /**
  25082. * Serialize animation ranges into a JSON compatible object
  25083. * @returns serialization object
  25084. */
  25085. serializeAnimationRanges(): any;
  25086. /**
  25087. * Computes the world matrix of the node
  25088. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25089. * @returns the world matrix
  25090. */
  25091. computeWorldMatrix(force?: boolean): Matrix;
  25092. /**
  25093. * Releases resources associated with this node.
  25094. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25095. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25096. */
  25097. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25098. /**
  25099. * Parse animation range data from a serialization object and store them into a given node
  25100. * @param node defines where to store the animation ranges
  25101. * @param parsedNode defines the serialization object to read data from
  25102. * @param scene defines the hosting scene
  25103. */
  25104. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25105. }
  25106. }
  25107. declare module "babylonjs/Animations/animation" {
  25108. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25109. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25110. import { Nullable } from "babylonjs/types";
  25111. import { Scene } from "babylonjs/scene";
  25112. import { IAnimatable } from "babylonjs/Misc/tools";
  25113. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25114. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25115. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25116. import { Node } from "babylonjs/node";
  25117. import { Animatable } from "babylonjs/Animations/animatable";
  25118. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25119. /**
  25120. * Class used to store any kind of animation
  25121. */
  25122. export class Animation {
  25123. /**Name of the animation */
  25124. name: string;
  25125. /**Property to animate */
  25126. targetProperty: string;
  25127. /**The frames per second of the animation */
  25128. framePerSecond: number;
  25129. /**The data type of the animation */
  25130. dataType: number;
  25131. /**The loop mode of the animation */
  25132. loopMode?: number | undefined;
  25133. /**Specifies if blending should be enabled */
  25134. enableBlending?: boolean | undefined;
  25135. /**
  25136. * Use matrix interpolation instead of using direct key value when animating matrices
  25137. */
  25138. static AllowMatricesInterpolation: boolean;
  25139. /**
  25140. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25141. */
  25142. static AllowMatrixDecomposeForInterpolation: boolean;
  25143. /**
  25144. * Stores the key frames of the animation
  25145. */
  25146. private _keys;
  25147. /**
  25148. * Stores the easing function of the animation
  25149. */
  25150. private _easingFunction;
  25151. /**
  25152. * @hidden Internal use only
  25153. */
  25154. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25155. /**
  25156. * The set of event that will be linked to this animation
  25157. */
  25158. private _events;
  25159. /**
  25160. * Stores an array of target property paths
  25161. */
  25162. targetPropertyPath: string[];
  25163. /**
  25164. * Stores the blending speed of the animation
  25165. */
  25166. blendingSpeed: number;
  25167. /**
  25168. * Stores the animation ranges for the animation
  25169. */
  25170. private _ranges;
  25171. /**
  25172. * @hidden Internal use
  25173. */
  25174. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25175. /**
  25176. * Sets up an animation
  25177. * @param property The property to animate
  25178. * @param animationType The animation type to apply
  25179. * @param framePerSecond The frames per second of the animation
  25180. * @param easingFunction The easing function used in the animation
  25181. * @returns The created animation
  25182. */
  25183. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25184. /**
  25185. * Create and start an animation on a node
  25186. * @param name defines the name of the global animation that will be run on all nodes
  25187. * @param node defines the root node where the animation will take place
  25188. * @param targetProperty defines property to animate
  25189. * @param framePerSecond defines the number of frame per second yo use
  25190. * @param totalFrame defines the number of frames in total
  25191. * @param from defines the initial value
  25192. * @param to defines the final value
  25193. * @param loopMode defines which loop mode you want to use (off by default)
  25194. * @param easingFunction defines the easing function to use (linear by default)
  25195. * @param onAnimationEnd defines the callback to call when animation end
  25196. * @returns the animatable created for this animation
  25197. */
  25198. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25199. /**
  25200. * Create and start an animation on a node and its descendants
  25201. * @param name defines the name of the global animation that will be run on all nodes
  25202. * @param node defines the root node where the animation will take place
  25203. * @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
  25204. * @param targetProperty defines property to animate
  25205. * @param framePerSecond defines the number of frame per second to use
  25206. * @param totalFrame defines the number of frames in total
  25207. * @param from defines the initial value
  25208. * @param to defines the final value
  25209. * @param loopMode defines which loop mode you want to use (off by default)
  25210. * @param easingFunction defines the easing function to use (linear by default)
  25211. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25212. * @returns the list of animatables created for all nodes
  25213. * @example https://www.babylonjs-playground.com/#MH0VLI
  25214. */
  25215. 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[]>;
  25216. /**
  25217. * Creates a new animation, merges it with the existing animations and starts it
  25218. * @param name Name of the animation
  25219. * @param node Node which contains the scene that begins the animations
  25220. * @param targetProperty Specifies which property to animate
  25221. * @param framePerSecond The frames per second of the animation
  25222. * @param totalFrame The total number of frames
  25223. * @param from The frame at the beginning of the animation
  25224. * @param to The frame at the end of the animation
  25225. * @param loopMode Specifies the loop mode of the animation
  25226. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25227. * @param onAnimationEnd Callback to run once the animation is complete
  25228. * @returns Nullable animation
  25229. */
  25230. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25231. /**
  25232. * Transition property of an host to the target Value
  25233. * @param property The property to transition
  25234. * @param targetValue The target Value of the property
  25235. * @param host The object where the property to animate belongs
  25236. * @param scene Scene used to run the animation
  25237. * @param frameRate Framerate (in frame/s) to use
  25238. * @param transition The transition type we want to use
  25239. * @param duration The duration of the animation, in milliseconds
  25240. * @param onAnimationEnd Callback trigger at the end of the animation
  25241. * @returns Nullable animation
  25242. */
  25243. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25244. /**
  25245. * Return the array of runtime animations currently using this animation
  25246. */
  25247. readonly runtimeAnimations: RuntimeAnimation[];
  25248. /**
  25249. * Specifies if any of the runtime animations are currently running
  25250. */
  25251. readonly hasRunningRuntimeAnimations: boolean;
  25252. /**
  25253. * Initializes the animation
  25254. * @param name Name of the animation
  25255. * @param targetProperty Property to animate
  25256. * @param framePerSecond The frames per second of the animation
  25257. * @param dataType The data type of the animation
  25258. * @param loopMode The loop mode of the animation
  25259. * @param enableBlending Specifies if blending should be enabled
  25260. */
  25261. constructor(
  25262. /**Name of the animation */
  25263. name: string,
  25264. /**Property to animate */
  25265. targetProperty: string,
  25266. /**The frames per second of the animation */
  25267. framePerSecond: number,
  25268. /**The data type of the animation */
  25269. dataType: number,
  25270. /**The loop mode of the animation */
  25271. loopMode?: number | undefined,
  25272. /**Specifies if blending should be enabled */
  25273. enableBlending?: boolean | undefined);
  25274. /**
  25275. * Converts the animation to a string
  25276. * @param fullDetails support for multiple levels of logging within scene loading
  25277. * @returns String form of the animation
  25278. */
  25279. toString(fullDetails?: boolean): string;
  25280. /**
  25281. * Add an event to this animation
  25282. * @param event Event to add
  25283. */
  25284. addEvent(event: AnimationEvent): void;
  25285. /**
  25286. * Remove all events found at the given frame
  25287. * @param frame The frame to remove events from
  25288. */
  25289. removeEvents(frame: number): void;
  25290. /**
  25291. * Retrieves all the events from the animation
  25292. * @returns Events from the animation
  25293. */
  25294. getEvents(): AnimationEvent[];
  25295. /**
  25296. * Creates an animation range
  25297. * @param name Name of the animation range
  25298. * @param from Starting frame of the animation range
  25299. * @param to Ending frame of the animation
  25300. */
  25301. createRange(name: string, from: number, to: number): void;
  25302. /**
  25303. * Deletes an animation range by name
  25304. * @param name Name of the animation range to delete
  25305. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25306. */
  25307. deleteRange(name: string, deleteFrames?: boolean): void;
  25308. /**
  25309. * Gets the animation range by name, or null if not defined
  25310. * @param name Name of the animation range
  25311. * @returns Nullable animation range
  25312. */
  25313. getRange(name: string): Nullable<AnimationRange>;
  25314. /**
  25315. * Gets the key frames from the animation
  25316. * @returns The key frames of the animation
  25317. */
  25318. getKeys(): Array<IAnimationKey>;
  25319. /**
  25320. * Gets the highest frame rate of the animation
  25321. * @returns Highest frame rate of the animation
  25322. */
  25323. getHighestFrame(): number;
  25324. /**
  25325. * Gets the easing function of the animation
  25326. * @returns Easing function of the animation
  25327. */
  25328. getEasingFunction(): IEasingFunction;
  25329. /**
  25330. * Sets the easing function of the animation
  25331. * @param easingFunction A custom mathematical formula for animation
  25332. */
  25333. setEasingFunction(easingFunction: EasingFunction): void;
  25334. /**
  25335. * Interpolates a scalar linearly
  25336. * @param startValue Start value of the animation curve
  25337. * @param endValue End value of the animation curve
  25338. * @param gradient Scalar amount to interpolate
  25339. * @returns Interpolated scalar value
  25340. */
  25341. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25342. /**
  25343. * Interpolates a scalar cubically
  25344. * @param startValue Start value of the animation curve
  25345. * @param outTangent End tangent of the animation
  25346. * @param endValue End value of the animation curve
  25347. * @param inTangent Start tangent of the animation curve
  25348. * @param gradient Scalar amount to interpolate
  25349. * @returns Interpolated scalar value
  25350. */
  25351. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25352. /**
  25353. * Interpolates a quaternion using a spherical linear interpolation
  25354. * @param startValue Start value of the animation curve
  25355. * @param endValue End value of the animation curve
  25356. * @param gradient Scalar amount to interpolate
  25357. * @returns Interpolated quaternion value
  25358. */
  25359. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25360. /**
  25361. * Interpolates a quaternion cubically
  25362. * @param startValue Start value of the animation curve
  25363. * @param outTangent End tangent of the animation curve
  25364. * @param endValue End value of the animation curve
  25365. * @param inTangent Start tangent of the animation curve
  25366. * @param gradient Scalar amount to interpolate
  25367. * @returns Interpolated quaternion value
  25368. */
  25369. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25370. /**
  25371. * Interpolates a Vector3 linearl
  25372. * @param startValue Start value of the animation curve
  25373. * @param endValue End value of the animation curve
  25374. * @param gradient Scalar amount to interpolate
  25375. * @returns Interpolated scalar value
  25376. */
  25377. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25378. /**
  25379. * Interpolates a Vector3 cubically
  25380. * @param startValue Start value of the animation curve
  25381. * @param outTangent End tangent of the animation
  25382. * @param endValue End value of the animation curve
  25383. * @param inTangent Start tangent of the animation curve
  25384. * @param gradient Scalar amount to interpolate
  25385. * @returns InterpolatedVector3 value
  25386. */
  25387. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25388. /**
  25389. * Interpolates a Vector2 linearly
  25390. * @param startValue Start value of the animation curve
  25391. * @param endValue End value of the animation curve
  25392. * @param gradient Scalar amount to interpolate
  25393. * @returns Interpolated Vector2 value
  25394. */
  25395. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25396. /**
  25397. * Interpolates a Vector2 cubically
  25398. * @param startValue Start value of the animation curve
  25399. * @param outTangent End tangent of the animation
  25400. * @param endValue End value of the animation curve
  25401. * @param inTangent Start tangent of the animation curve
  25402. * @param gradient Scalar amount to interpolate
  25403. * @returns Interpolated Vector2 value
  25404. */
  25405. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25406. /**
  25407. * Interpolates a size linearly
  25408. * @param startValue Start value of the animation curve
  25409. * @param endValue End value of the animation curve
  25410. * @param gradient Scalar amount to interpolate
  25411. * @returns Interpolated Size value
  25412. */
  25413. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25414. /**
  25415. * Interpolates a Color3 linearly
  25416. * @param startValue Start value of the animation curve
  25417. * @param endValue End value of the animation curve
  25418. * @param gradient Scalar amount to interpolate
  25419. * @returns Interpolated Color3 value
  25420. */
  25421. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25422. /**
  25423. * @hidden Internal use only
  25424. */
  25425. _getKeyValue(value: any): any;
  25426. /**
  25427. * @hidden Internal use only
  25428. */
  25429. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25430. /**
  25431. * Defines the function to use to interpolate matrices
  25432. * @param startValue defines the start matrix
  25433. * @param endValue defines the end matrix
  25434. * @param gradient defines the gradient between both matrices
  25435. * @param result defines an optional target matrix where to store the interpolation
  25436. * @returns the interpolated matrix
  25437. */
  25438. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25439. /**
  25440. * Makes a copy of the animation
  25441. * @returns Cloned animation
  25442. */
  25443. clone(): Animation;
  25444. /**
  25445. * Sets the key frames of the animation
  25446. * @param values The animation key frames to set
  25447. */
  25448. setKeys(values: Array<IAnimationKey>): void;
  25449. /**
  25450. * Serializes the animation to an object
  25451. * @returns Serialized object
  25452. */
  25453. serialize(): any;
  25454. /**
  25455. * Float animation type
  25456. */
  25457. private static _ANIMATIONTYPE_FLOAT;
  25458. /**
  25459. * Vector3 animation type
  25460. */
  25461. private static _ANIMATIONTYPE_VECTOR3;
  25462. /**
  25463. * Quaternion animation type
  25464. */
  25465. private static _ANIMATIONTYPE_QUATERNION;
  25466. /**
  25467. * Matrix animation type
  25468. */
  25469. private static _ANIMATIONTYPE_MATRIX;
  25470. /**
  25471. * Color3 animation type
  25472. */
  25473. private static _ANIMATIONTYPE_COLOR3;
  25474. /**
  25475. * Vector2 animation type
  25476. */
  25477. private static _ANIMATIONTYPE_VECTOR2;
  25478. /**
  25479. * Size animation type
  25480. */
  25481. private static _ANIMATIONTYPE_SIZE;
  25482. /**
  25483. * Relative Loop Mode
  25484. */
  25485. private static _ANIMATIONLOOPMODE_RELATIVE;
  25486. /**
  25487. * Cycle Loop Mode
  25488. */
  25489. private static _ANIMATIONLOOPMODE_CYCLE;
  25490. /**
  25491. * Constant Loop Mode
  25492. */
  25493. private static _ANIMATIONLOOPMODE_CONSTANT;
  25494. /**
  25495. * Get the float animation type
  25496. */
  25497. static readonly ANIMATIONTYPE_FLOAT: number;
  25498. /**
  25499. * Get the Vector3 animation type
  25500. */
  25501. static readonly ANIMATIONTYPE_VECTOR3: number;
  25502. /**
  25503. * Get the Vector2 animation type
  25504. */
  25505. static readonly ANIMATIONTYPE_VECTOR2: number;
  25506. /**
  25507. * Get the Size animation type
  25508. */
  25509. static readonly ANIMATIONTYPE_SIZE: number;
  25510. /**
  25511. * Get the Quaternion animation type
  25512. */
  25513. static readonly ANIMATIONTYPE_QUATERNION: number;
  25514. /**
  25515. * Get the Matrix animation type
  25516. */
  25517. static readonly ANIMATIONTYPE_MATRIX: number;
  25518. /**
  25519. * Get the Color3 animation type
  25520. */
  25521. static readonly ANIMATIONTYPE_COLOR3: number;
  25522. /**
  25523. * Get the Relative Loop Mode
  25524. */
  25525. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25526. /**
  25527. * Get the Cycle Loop Mode
  25528. */
  25529. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25530. /**
  25531. * Get the Constant Loop Mode
  25532. */
  25533. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25534. /** @hidden */
  25535. static _UniversalLerp(left: any, right: any, amount: number): any;
  25536. /**
  25537. * Parses an animation object and creates an animation
  25538. * @param parsedAnimation Parsed animation object
  25539. * @returns Animation object
  25540. */
  25541. static Parse(parsedAnimation: any): Animation;
  25542. /**
  25543. * Appends the serialized animations from the source animations
  25544. * @param source Source containing the animations
  25545. * @param destination Target to store the animations
  25546. */
  25547. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25548. }
  25549. }
  25550. declare module "babylonjs/Materials/Textures/baseTexture" {
  25551. import { Observable } from "babylonjs/Misc/observable";
  25552. import { IAnimatable } from "babylonjs/Misc/tools";
  25553. import { Nullable } from "babylonjs/types";
  25554. import { Scene } from "babylonjs/scene";
  25555. import { Matrix, ISize } from "babylonjs/Maths/math";
  25556. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25557. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25558. /**
  25559. * Base class of all the textures in babylon.
  25560. * It groups all the common properties the materials, post process, lights... might need
  25561. * in order to make a correct use of the texture.
  25562. */
  25563. export class BaseTexture implements IAnimatable {
  25564. /**
  25565. * Default anisotropic filtering level for the application.
  25566. * It is set to 4 as a good tradeoff between perf and quality.
  25567. */
  25568. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25569. /**
  25570. * Gets or sets the unique id of the texture
  25571. */
  25572. uniqueId: number;
  25573. /**
  25574. * Define the name of the texture.
  25575. */
  25576. name: string;
  25577. /**
  25578. * Gets or sets an object used to store user defined information.
  25579. */
  25580. metadata: any;
  25581. /**
  25582. * For internal use only. Please do not use.
  25583. */
  25584. reservedDataStore: any;
  25585. private _hasAlpha;
  25586. /**
  25587. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25588. */
  25589. hasAlpha: boolean;
  25590. /**
  25591. * Defines if the alpha value should be determined via the rgb values.
  25592. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25593. */
  25594. getAlphaFromRGB: boolean;
  25595. /**
  25596. * Intensity or strength of the texture.
  25597. * It is commonly used by materials to fine tune the intensity of the texture
  25598. */
  25599. level: number;
  25600. /**
  25601. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25602. * This is part of the texture as textures usually maps to one uv set.
  25603. */
  25604. coordinatesIndex: number;
  25605. private _coordinatesMode;
  25606. /**
  25607. * How a texture is mapped.
  25608. *
  25609. * | Value | Type | Description |
  25610. * | ----- | ----------------------------------- | ----------- |
  25611. * | 0 | EXPLICIT_MODE | |
  25612. * | 1 | SPHERICAL_MODE | |
  25613. * | 2 | PLANAR_MODE | |
  25614. * | 3 | CUBIC_MODE | |
  25615. * | 4 | PROJECTION_MODE | |
  25616. * | 5 | SKYBOX_MODE | |
  25617. * | 6 | INVCUBIC_MODE | |
  25618. * | 7 | EQUIRECTANGULAR_MODE | |
  25619. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25620. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25621. */
  25622. coordinatesMode: number;
  25623. /**
  25624. * | Value | Type | Description |
  25625. * | ----- | ------------------ | ----------- |
  25626. * | 0 | CLAMP_ADDRESSMODE | |
  25627. * | 1 | WRAP_ADDRESSMODE | |
  25628. * | 2 | MIRROR_ADDRESSMODE | |
  25629. */
  25630. wrapU: number;
  25631. /**
  25632. * | Value | Type | Description |
  25633. * | ----- | ------------------ | ----------- |
  25634. * | 0 | CLAMP_ADDRESSMODE | |
  25635. * | 1 | WRAP_ADDRESSMODE | |
  25636. * | 2 | MIRROR_ADDRESSMODE | |
  25637. */
  25638. wrapV: number;
  25639. /**
  25640. * | Value | Type | Description |
  25641. * | ----- | ------------------ | ----------- |
  25642. * | 0 | CLAMP_ADDRESSMODE | |
  25643. * | 1 | WRAP_ADDRESSMODE | |
  25644. * | 2 | MIRROR_ADDRESSMODE | |
  25645. */
  25646. wrapR: number;
  25647. /**
  25648. * With compliant hardware and browser (supporting anisotropic filtering)
  25649. * this defines the level of anisotropic filtering in the texture.
  25650. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25651. */
  25652. anisotropicFilteringLevel: number;
  25653. /**
  25654. * Define if the texture is a cube texture or if false a 2d texture.
  25655. */
  25656. isCube: boolean;
  25657. /**
  25658. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25659. */
  25660. is3D: boolean;
  25661. /**
  25662. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25663. * HDR texture are usually stored in linear space.
  25664. * This only impacts the PBR and Background materials
  25665. */
  25666. gammaSpace: boolean;
  25667. /**
  25668. * Gets whether or not the texture contains RGBD data.
  25669. */
  25670. readonly isRGBD: boolean;
  25671. /**
  25672. * Is Z inverted in the texture (useful in a cube texture).
  25673. */
  25674. invertZ: boolean;
  25675. /**
  25676. * Are mip maps generated for this texture or not.
  25677. */
  25678. readonly noMipmap: boolean;
  25679. /**
  25680. * @hidden
  25681. */
  25682. lodLevelInAlpha: boolean;
  25683. /**
  25684. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25685. */
  25686. lodGenerationOffset: number;
  25687. /**
  25688. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25689. */
  25690. lodGenerationScale: number;
  25691. /**
  25692. * Define if the texture is a render target.
  25693. */
  25694. isRenderTarget: boolean;
  25695. /**
  25696. * Define the unique id of the texture in the scene.
  25697. */
  25698. readonly uid: string;
  25699. /**
  25700. * Return a string representation of the texture.
  25701. * @returns the texture as a string
  25702. */
  25703. toString(): string;
  25704. /**
  25705. * Get the class name of the texture.
  25706. * @returns "BaseTexture"
  25707. */
  25708. getClassName(): string;
  25709. /**
  25710. * Define the list of animation attached to the texture.
  25711. */
  25712. animations: import("babylonjs/Animations/animation").Animation[];
  25713. /**
  25714. * An event triggered when the texture is disposed.
  25715. */
  25716. onDisposeObservable: Observable<BaseTexture>;
  25717. private _onDisposeObserver;
  25718. /**
  25719. * Callback triggered when the texture has been disposed.
  25720. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25721. */
  25722. onDispose: () => void;
  25723. /**
  25724. * Define the current state of the loading sequence when in delayed load mode.
  25725. */
  25726. delayLoadState: number;
  25727. private _scene;
  25728. /** @hidden */
  25729. _texture: Nullable<InternalTexture>;
  25730. private _uid;
  25731. /**
  25732. * Define if the texture is preventinga material to render or not.
  25733. * If not and the texture is not ready, the engine will use a default black texture instead.
  25734. */
  25735. readonly isBlocking: boolean;
  25736. /**
  25737. * Instantiates a new BaseTexture.
  25738. * Base class of all the textures in babylon.
  25739. * It groups all the common properties the materials, post process, lights... might need
  25740. * in order to make a correct use of the texture.
  25741. * @param scene Define the scene the texture blongs to
  25742. */
  25743. constructor(scene: Nullable<Scene>);
  25744. /**
  25745. * Get the scene the texture belongs to.
  25746. * @returns the scene or null if undefined
  25747. */
  25748. getScene(): Nullable<Scene>;
  25749. /**
  25750. * Get the texture transform matrix used to offset tile the texture for istance.
  25751. * @returns the transformation matrix
  25752. */
  25753. getTextureMatrix(): Matrix;
  25754. /**
  25755. * Get the texture reflection matrix used to rotate/transform the reflection.
  25756. * @returns the reflection matrix
  25757. */
  25758. getReflectionTextureMatrix(): Matrix;
  25759. /**
  25760. * Get the underlying lower level texture from Babylon.
  25761. * @returns the insternal texture
  25762. */
  25763. getInternalTexture(): Nullable<InternalTexture>;
  25764. /**
  25765. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25766. * @returns true if ready or not blocking
  25767. */
  25768. isReadyOrNotBlocking(): boolean;
  25769. /**
  25770. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25771. * @returns true if fully ready
  25772. */
  25773. isReady(): boolean;
  25774. private _cachedSize;
  25775. /**
  25776. * Get the size of the texture.
  25777. * @returns the texture size.
  25778. */
  25779. getSize(): ISize;
  25780. /**
  25781. * Get the base size of the texture.
  25782. * It can be different from the size if the texture has been resized for POT for instance
  25783. * @returns the base size
  25784. */
  25785. getBaseSize(): ISize;
  25786. /**
  25787. * Update the sampling mode of the texture.
  25788. * Default is Trilinear mode.
  25789. *
  25790. * | Value | Type | Description |
  25791. * | ----- | ------------------ | ----------- |
  25792. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25793. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25794. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25795. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25796. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25797. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25798. * | 7 | NEAREST_LINEAR | |
  25799. * | 8 | NEAREST_NEAREST | |
  25800. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25801. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25802. * | 11 | LINEAR_LINEAR | |
  25803. * | 12 | LINEAR_NEAREST | |
  25804. *
  25805. * > _mag_: magnification filter (close to the viewer)
  25806. * > _min_: minification filter (far from the viewer)
  25807. * > _mip_: filter used between mip map levels
  25808. *@param samplingMode Define the new sampling mode of the texture
  25809. */
  25810. updateSamplingMode(samplingMode: number): void;
  25811. /**
  25812. * Scales the texture if is `canRescale()`
  25813. * @param ratio the resize factor we want to use to rescale
  25814. */
  25815. scale(ratio: number): void;
  25816. /**
  25817. * Get if the texture can rescale.
  25818. */
  25819. readonly canRescale: boolean;
  25820. /** @hidden */
  25821. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25822. /** @hidden */
  25823. _rebuild(): void;
  25824. /**
  25825. * Triggers the load sequence in delayed load mode.
  25826. */
  25827. delayLoad(): void;
  25828. /**
  25829. * Clones the texture.
  25830. * @returns the cloned texture
  25831. */
  25832. clone(): Nullable<BaseTexture>;
  25833. /**
  25834. * Get the texture underlying type (INT, FLOAT...)
  25835. */
  25836. readonly textureType: number;
  25837. /**
  25838. * Get the texture underlying format (RGB, RGBA...)
  25839. */
  25840. readonly textureFormat: number;
  25841. /**
  25842. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25843. * This will returns an RGBA array buffer containing either in values (0-255) or
  25844. * float values (0-1) depending of the underlying buffer type.
  25845. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25846. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25847. * @param buffer defines a user defined buffer to fill with data (can be null)
  25848. * @returns The Array buffer containing the pixels data.
  25849. */
  25850. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25851. /**
  25852. * Release and destroy the underlying lower level texture aka internalTexture.
  25853. */
  25854. releaseInternalTexture(): void;
  25855. /**
  25856. * Get the polynomial representation of the texture data.
  25857. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25858. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25859. */
  25860. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25861. /** @hidden */
  25862. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25863. /** @hidden */
  25864. readonly _lodTextureMid: Nullable<BaseTexture>;
  25865. /** @hidden */
  25866. readonly _lodTextureLow: Nullable<BaseTexture>;
  25867. /**
  25868. * Dispose the texture and release its associated resources.
  25869. */
  25870. dispose(): void;
  25871. /**
  25872. * Serialize the texture into a JSON representation that can be parsed later on.
  25873. * @returns the JSON representation of the texture
  25874. */
  25875. serialize(): any;
  25876. /**
  25877. * Helper function to be called back once a list of texture contains only ready textures.
  25878. * @param textures Define the list of textures to wait for
  25879. * @param callback Define the callback triggered once the entire list will be ready
  25880. */
  25881. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25882. }
  25883. }
  25884. declare module "babylonjs/Materials/uniformBuffer" {
  25885. import { Nullable, FloatArray } from "babylonjs/types";
  25886. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25887. import { Engine } from "babylonjs/Engines/engine";
  25888. import { Effect } from "babylonjs/Materials/effect";
  25889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25890. /**
  25891. * Uniform buffer objects.
  25892. *
  25893. * Handles blocks of uniform on the GPU.
  25894. *
  25895. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25896. *
  25897. * For more information, please refer to :
  25898. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25899. */
  25900. export class UniformBuffer {
  25901. private _engine;
  25902. private _buffer;
  25903. private _data;
  25904. private _bufferData;
  25905. private _dynamic?;
  25906. private _uniformLocations;
  25907. private _uniformSizes;
  25908. private _uniformLocationPointer;
  25909. private _needSync;
  25910. private _noUBO;
  25911. private _currentEffect;
  25912. private static _MAX_UNIFORM_SIZE;
  25913. private static _tempBuffer;
  25914. /**
  25915. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25916. * This is dynamic to allow compat with webgl 1 and 2.
  25917. * You will need to pass the name of the uniform as well as the value.
  25918. */
  25919. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25920. /**
  25921. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25922. * This is dynamic to allow compat with webgl 1 and 2.
  25923. * You will need to pass the name of the uniform as well as the value.
  25924. */
  25925. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25926. /**
  25927. * Lambda to Update a single float in a uniform buffer.
  25928. * This is dynamic to allow compat with webgl 1 and 2.
  25929. * You will need to pass the name of the uniform as well as the value.
  25930. */
  25931. updateFloat: (name: string, x: number) => void;
  25932. /**
  25933. * Lambda to Update a vec2 of float in a uniform buffer.
  25934. * This is dynamic to allow compat with webgl 1 and 2.
  25935. * You will need to pass the name of the uniform as well as the value.
  25936. */
  25937. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25938. /**
  25939. * Lambda to Update a vec3 of float in a uniform buffer.
  25940. * This is dynamic to allow compat with webgl 1 and 2.
  25941. * You will need to pass the name of the uniform as well as the value.
  25942. */
  25943. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25944. /**
  25945. * Lambda to Update a vec4 of float in a uniform buffer.
  25946. * This is dynamic to allow compat with webgl 1 and 2.
  25947. * You will need to pass the name of the uniform as well as the value.
  25948. */
  25949. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25950. /**
  25951. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25952. * This is dynamic to allow compat with webgl 1 and 2.
  25953. * You will need to pass the name of the uniform as well as the value.
  25954. */
  25955. updateMatrix: (name: string, mat: Matrix) => void;
  25956. /**
  25957. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25958. * This is dynamic to allow compat with webgl 1 and 2.
  25959. * You will need to pass the name of the uniform as well as the value.
  25960. */
  25961. updateVector3: (name: string, vector: Vector3) => void;
  25962. /**
  25963. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25964. * This is dynamic to allow compat with webgl 1 and 2.
  25965. * You will need to pass the name of the uniform as well as the value.
  25966. */
  25967. updateVector4: (name: string, vector: Vector4) => void;
  25968. /**
  25969. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25970. * This is dynamic to allow compat with webgl 1 and 2.
  25971. * You will need to pass the name of the uniform as well as the value.
  25972. */
  25973. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25974. /**
  25975. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25976. * This is dynamic to allow compat with webgl 1 and 2.
  25977. * You will need to pass the name of the uniform as well as the value.
  25978. */
  25979. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25980. /**
  25981. * Instantiates a new Uniform buffer objects.
  25982. *
  25983. * Handles blocks of uniform on the GPU.
  25984. *
  25985. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25986. *
  25987. * For more information, please refer to :
  25988. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25989. * @param engine Define the engine the buffer is associated with
  25990. * @param data Define the data contained in the buffer
  25991. * @param dynamic Define if the buffer is updatable
  25992. */
  25993. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25994. /**
  25995. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25996. * or just falling back on setUniformXXX calls.
  25997. */
  25998. readonly useUbo: boolean;
  25999. /**
  26000. * Indicates if the WebGL underlying uniform buffer is in sync
  26001. * with the javascript cache data.
  26002. */
  26003. readonly isSync: boolean;
  26004. /**
  26005. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26006. * Also, a dynamic UniformBuffer will disable cache verification and always
  26007. * update the underlying WebGL uniform buffer to the GPU.
  26008. * @returns if Dynamic, otherwise false
  26009. */
  26010. isDynamic(): boolean;
  26011. /**
  26012. * The data cache on JS side.
  26013. * @returns the underlying data as a float array
  26014. */
  26015. getData(): Float32Array;
  26016. /**
  26017. * The underlying WebGL Uniform buffer.
  26018. * @returns the webgl buffer
  26019. */
  26020. getBuffer(): Nullable<WebGLBuffer>;
  26021. /**
  26022. * std140 layout specifies how to align data within an UBO structure.
  26023. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26024. * for specs.
  26025. */
  26026. private _fillAlignment;
  26027. /**
  26028. * Adds an uniform in the buffer.
  26029. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26030. * for the layout to be correct !
  26031. * @param name Name of the uniform, as used in the uniform block in the shader.
  26032. * @param size Data size, or data directly.
  26033. */
  26034. addUniform(name: string, size: number | number[]): void;
  26035. /**
  26036. * Adds a Matrix 4x4 to the uniform buffer.
  26037. * @param name Name of the uniform, as used in the uniform block in the shader.
  26038. * @param mat A 4x4 matrix.
  26039. */
  26040. addMatrix(name: string, mat: Matrix): void;
  26041. /**
  26042. * Adds a vec2 to the uniform buffer.
  26043. * @param name Name of the uniform, as used in the uniform block in the shader.
  26044. * @param x Define the x component value of the vec2
  26045. * @param y Define the y component value of the vec2
  26046. */
  26047. addFloat2(name: string, x: number, y: number): void;
  26048. /**
  26049. * Adds a vec3 to the uniform buffer.
  26050. * @param name Name of the uniform, as used in the uniform block in the shader.
  26051. * @param x Define the x component value of the vec3
  26052. * @param y Define the y component value of the vec3
  26053. * @param z Define the z component value of the vec3
  26054. */
  26055. addFloat3(name: string, x: number, y: number, z: number): void;
  26056. /**
  26057. * Adds a vec3 to the uniform buffer.
  26058. * @param name Name of the uniform, as used in the uniform block in the shader.
  26059. * @param color Define the vec3 from a Color
  26060. */
  26061. addColor3(name: string, color: Color3): void;
  26062. /**
  26063. * Adds a vec4 to the uniform buffer.
  26064. * @param name Name of the uniform, as used in the uniform block in the shader.
  26065. * @param color Define the rgb components from a Color
  26066. * @param alpha Define the a component of the vec4
  26067. */
  26068. addColor4(name: string, color: Color3, alpha: number): void;
  26069. /**
  26070. * Adds a vec3 to the uniform buffer.
  26071. * @param name Name of the uniform, as used in the uniform block in the shader.
  26072. * @param vector Define the vec3 components from a Vector
  26073. */
  26074. addVector3(name: string, vector: Vector3): void;
  26075. /**
  26076. * Adds a Matrix 3x3 to the uniform buffer.
  26077. * @param name Name of the uniform, as used in the uniform block in the shader.
  26078. */
  26079. addMatrix3x3(name: string): void;
  26080. /**
  26081. * Adds a Matrix 2x2 to the uniform buffer.
  26082. * @param name Name of the uniform, as used in the uniform block in the shader.
  26083. */
  26084. addMatrix2x2(name: string): void;
  26085. /**
  26086. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26087. */
  26088. create(): void;
  26089. /** @hidden */
  26090. _rebuild(): void;
  26091. /**
  26092. * Updates the WebGL Uniform Buffer on the GPU.
  26093. * If the `dynamic` flag is set to true, no cache comparison is done.
  26094. * Otherwise, the buffer will be updated only if the cache differs.
  26095. */
  26096. update(): void;
  26097. /**
  26098. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26099. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26100. * @param data Define the flattened data
  26101. * @param size Define the size of the data.
  26102. */
  26103. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26104. private _updateMatrix3x3ForUniform;
  26105. private _updateMatrix3x3ForEffect;
  26106. private _updateMatrix2x2ForEffect;
  26107. private _updateMatrix2x2ForUniform;
  26108. private _updateFloatForEffect;
  26109. private _updateFloatForUniform;
  26110. private _updateFloat2ForEffect;
  26111. private _updateFloat2ForUniform;
  26112. private _updateFloat3ForEffect;
  26113. private _updateFloat3ForUniform;
  26114. private _updateFloat4ForEffect;
  26115. private _updateFloat4ForUniform;
  26116. private _updateMatrixForEffect;
  26117. private _updateMatrixForUniform;
  26118. private _updateVector3ForEffect;
  26119. private _updateVector3ForUniform;
  26120. private _updateVector4ForEffect;
  26121. private _updateVector4ForUniform;
  26122. private _updateColor3ForEffect;
  26123. private _updateColor3ForUniform;
  26124. private _updateColor4ForEffect;
  26125. private _updateColor4ForUniform;
  26126. /**
  26127. * Sets a sampler uniform on the effect.
  26128. * @param name Define the name of the sampler.
  26129. * @param texture Define the texture to set in the sampler
  26130. */
  26131. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26132. /**
  26133. * Directly updates the value of the uniform in the cache AND on the GPU.
  26134. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26135. * @param data Define the flattened data
  26136. */
  26137. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26138. /**
  26139. * Binds this uniform buffer to an effect.
  26140. * @param effect Define the effect to bind the buffer to
  26141. * @param name Name of the uniform block in the shader.
  26142. */
  26143. bindToEffect(effect: Effect, name: string): void;
  26144. /**
  26145. * Disposes the uniform buffer.
  26146. */
  26147. dispose(): void;
  26148. }
  26149. }
  26150. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26151. import { Nullable } from "babylonjs/types";
  26152. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26153. /**
  26154. * This represents the required contract to create a new type of texture loader.
  26155. */
  26156. export interface IInternalTextureLoader {
  26157. /**
  26158. * Defines wether the loader supports cascade loading the different faces.
  26159. */
  26160. supportCascades: boolean;
  26161. /**
  26162. * This returns if the loader support the current file information.
  26163. * @param extension defines the file extension of the file being loaded
  26164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26165. * @param fallback defines the fallback internal texture if any
  26166. * @param isBase64 defines whether the texture is encoded as a base64
  26167. * @param isBuffer defines whether the texture data are stored as a buffer
  26168. * @returns true if the loader can load the specified file
  26169. */
  26170. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26171. /**
  26172. * Transform the url before loading if required.
  26173. * @param rootUrl the url of the texture
  26174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26175. * @returns the transformed texture
  26176. */
  26177. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26178. /**
  26179. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26180. * @param rootUrl the url of the texture
  26181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26182. * @returns the fallback texture
  26183. */
  26184. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26185. /**
  26186. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26187. * @param data contains the texture data
  26188. * @param texture defines the BabylonJS internal texture
  26189. * @param createPolynomials will be true if polynomials have been requested
  26190. * @param onLoad defines the callback to trigger once the texture is ready
  26191. * @param onError defines the callback to trigger in case of error
  26192. */
  26193. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26194. /**
  26195. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26196. * @param data contains the texture data
  26197. * @param texture defines the BabylonJS internal texture
  26198. * @param callback defines the method to call once ready to upload
  26199. */
  26200. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26201. }
  26202. }
  26203. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26204. import { Scene } from "babylonjs/scene";
  26205. import { Engine } from "babylonjs/Engines/engine";
  26206. import { Texture } from "babylonjs/Materials/Textures/texture";
  26207. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26208. /**
  26209. * Creation options of the multi render target texture.
  26210. */
  26211. export interface IMultiRenderTargetOptions {
  26212. /**
  26213. * Define if the texture needs to create mip maps after render.
  26214. */
  26215. generateMipMaps?: boolean;
  26216. /**
  26217. * Define the types of all the draw buffers we want to create
  26218. */
  26219. types?: number[];
  26220. /**
  26221. * Define the sampling modes of all the draw buffers we want to create
  26222. */
  26223. samplingModes?: number[];
  26224. /**
  26225. * Define if a depth buffer is required
  26226. */
  26227. generateDepthBuffer?: boolean;
  26228. /**
  26229. * Define if a stencil buffer is required
  26230. */
  26231. generateStencilBuffer?: boolean;
  26232. /**
  26233. * Define if a depth texture is required instead of a depth buffer
  26234. */
  26235. generateDepthTexture?: boolean;
  26236. /**
  26237. * Define the number of desired draw buffers
  26238. */
  26239. textureCount?: number;
  26240. /**
  26241. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26242. */
  26243. doNotChangeAspectRatio?: boolean;
  26244. /**
  26245. * Define the default type of the buffers we are creating
  26246. */
  26247. defaultType?: number;
  26248. }
  26249. /**
  26250. * A multi render target, like a render target provides the ability to render to a texture.
  26251. * Unlike the render target, it can render to several draw buffers in one draw.
  26252. * This is specially interesting in deferred rendering or for any effects requiring more than
  26253. * just one color from a single pass.
  26254. */
  26255. export class MultiRenderTarget extends RenderTargetTexture {
  26256. private _internalTextures;
  26257. private _textures;
  26258. private _multiRenderTargetOptions;
  26259. /**
  26260. * Get if draw buffers are currently supported by the used hardware and browser.
  26261. */
  26262. readonly isSupported: boolean;
  26263. /**
  26264. * Get the list of textures generated by the multi render target.
  26265. */
  26266. readonly textures: Texture[];
  26267. /**
  26268. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26269. */
  26270. readonly depthTexture: Texture;
  26271. /**
  26272. * Set the wrapping mode on U of all the textures we are rendering to.
  26273. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26274. */
  26275. wrapU: number;
  26276. /**
  26277. * Set the wrapping mode on V of all the textures we are rendering to.
  26278. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26279. */
  26280. wrapV: number;
  26281. /**
  26282. * Instantiate a new multi render target texture.
  26283. * A multi render target, like a render target provides the ability to render to a texture.
  26284. * Unlike the render target, it can render to several draw buffers in one draw.
  26285. * This is specially interesting in deferred rendering or for any effects requiring more than
  26286. * just one color from a single pass.
  26287. * @param name Define the name of the texture
  26288. * @param size Define the size of the buffers to render to
  26289. * @param count Define the number of target we are rendering into
  26290. * @param scene Define the scene the texture belongs to
  26291. * @param options Define the options used to create the multi render target
  26292. */
  26293. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26294. /** @hidden */
  26295. _rebuild(): void;
  26296. private _createInternalTextures;
  26297. private _createTextures;
  26298. /**
  26299. * Define the number of samples used if MSAA is enabled.
  26300. */
  26301. samples: number;
  26302. /**
  26303. * Resize all the textures in the multi render target.
  26304. * Be carrefull as it will recreate all the data in the new texture.
  26305. * @param size Define the new size
  26306. */
  26307. resize(size: any): void;
  26308. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26309. /**
  26310. * Dispose the render targets and their associated resources
  26311. */
  26312. dispose(): void;
  26313. /**
  26314. * Release all the underlying texture used as draw buffers.
  26315. */
  26316. releaseInternalTextures(): void;
  26317. }
  26318. }
  26319. declare module "babylonjs/Audio/analyser" {
  26320. import { Scene } from "babylonjs/scene";
  26321. /**
  26322. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26324. */
  26325. export class Analyser {
  26326. /**
  26327. * Gets or sets the smoothing
  26328. * @ignorenaming
  26329. */
  26330. SMOOTHING: number;
  26331. /**
  26332. * Gets or sets the FFT table size
  26333. * @ignorenaming
  26334. */
  26335. FFT_SIZE: number;
  26336. /**
  26337. * Gets or sets the bar graph amplitude
  26338. * @ignorenaming
  26339. */
  26340. BARGRAPHAMPLITUDE: number;
  26341. /**
  26342. * Gets or sets the position of the debug canvas
  26343. * @ignorenaming
  26344. */
  26345. DEBUGCANVASPOS: {
  26346. x: number;
  26347. y: number;
  26348. };
  26349. /**
  26350. * Gets or sets the debug canvas size
  26351. * @ignorenaming
  26352. */
  26353. DEBUGCANVASSIZE: {
  26354. width: number;
  26355. height: number;
  26356. };
  26357. private _byteFreqs;
  26358. private _byteTime;
  26359. private _floatFreqs;
  26360. private _webAudioAnalyser;
  26361. private _debugCanvas;
  26362. private _debugCanvasContext;
  26363. private _scene;
  26364. private _registerFunc;
  26365. private _audioEngine;
  26366. /**
  26367. * Creates a new analyser
  26368. * @param scene defines hosting scene
  26369. */
  26370. constructor(scene: Scene);
  26371. /**
  26372. * Get the number of data values you will have to play with for the visualization
  26373. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26374. * @returns a number
  26375. */
  26376. getFrequencyBinCount(): number;
  26377. /**
  26378. * Gets the current frequency data as a byte array
  26379. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26380. * @returns a Uint8Array
  26381. */
  26382. getByteFrequencyData(): Uint8Array;
  26383. /**
  26384. * Gets the current waveform as a byte array
  26385. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26386. * @returns a Uint8Array
  26387. */
  26388. getByteTimeDomainData(): Uint8Array;
  26389. /**
  26390. * Gets the current frequency data as a float array
  26391. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26392. * @returns a Float32Array
  26393. */
  26394. getFloatFrequencyData(): Float32Array;
  26395. /**
  26396. * Renders the debug canvas
  26397. */
  26398. drawDebugCanvas(): void;
  26399. /**
  26400. * Stops rendering the debug canvas and removes it
  26401. */
  26402. stopDebugCanvas(): void;
  26403. /**
  26404. * Connects two audio nodes
  26405. * @param inputAudioNode defines first node to connect
  26406. * @param outputAudioNode defines second node to connect
  26407. */
  26408. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26409. /**
  26410. * Releases all associated resources
  26411. */
  26412. dispose(): void;
  26413. }
  26414. }
  26415. declare module "babylonjs/Audio/audioEngine" {
  26416. import { IDisposable } from "babylonjs/scene";
  26417. import { Analyser } from "babylonjs/Audio/analyser";
  26418. import { Nullable } from "babylonjs/types";
  26419. import { Observable } from "babylonjs/Misc/observable";
  26420. /**
  26421. * This represents an audio engine and it is responsible
  26422. * to play, synchronize and analyse sounds throughout the application.
  26423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26424. */
  26425. export interface IAudioEngine extends IDisposable {
  26426. /**
  26427. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26428. */
  26429. readonly canUseWebAudio: boolean;
  26430. /**
  26431. * Gets the current AudioContext if available.
  26432. */
  26433. readonly audioContext: Nullable<AudioContext>;
  26434. /**
  26435. * The master gain node defines the global audio volume of your audio engine.
  26436. */
  26437. readonly masterGain: GainNode;
  26438. /**
  26439. * Gets whether or not mp3 are supported by your browser.
  26440. */
  26441. readonly isMP3supported: boolean;
  26442. /**
  26443. * Gets whether or not ogg are supported by your browser.
  26444. */
  26445. readonly isOGGsupported: boolean;
  26446. /**
  26447. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26448. * @ignoreNaming
  26449. */
  26450. WarnedWebAudioUnsupported: boolean;
  26451. /**
  26452. * Defines if the audio engine relies on a custom unlocked button.
  26453. * In this case, the embedded button will not be displayed.
  26454. */
  26455. useCustomUnlockedButton: boolean;
  26456. /**
  26457. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26458. */
  26459. readonly unlocked: boolean;
  26460. /**
  26461. * Event raised when audio has been unlocked on the browser.
  26462. */
  26463. onAudioUnlockedObservable: Observable<AudioEngine>;
  26464. /**
  26465. * Event raised when audio has been locked on the browser.
  26466. */
  26467. onAudioLockedObservable: Observable<AudioEngine>;
  26468. /**
  26469. * Flags the audio engine in Locked state.
  26470. * This happens due to new browser policies preventing audio to autoplay.
  26471. */
  26472. lock(): void;
  26473. /**
  26474. * Unlocks the audio engine once a user action has been done on the dom.
  26475. * This is helpful to resume play once browser policies have been satisfied.
  26476. */
  26477. unlock(): void;
  26478. }
  26479. /**
  26480. * This represents the default audio engine used in babylon.
  26481. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26483. */
  26484. export class AudioEngine implements IAudioEngine {
  26485. private _audioContext;
  26486. private _audioContextInitialized;
  26487. private _muteButton;
  26488. private _hostElement;
  26489. /**
  26490. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26491. */
  26492. canUseWebAudio: boolean;
  26493. /**
  26494. * The master gain node defines the global audio volume of your audio engine.
  26495. */
  26496. masterGain: GainNode;
  26497. /**
  26498. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26499. * @ignoreNaming
  26500. */
  26501. WarnedWebAudioUnsupported: boolean;
  26502. /**
  26503. * Gets whether or not mp3 are supported by your browser.
  26504. */
  26505. isMP3supported: boolean;
  26506. /**
  26507. * Gets whether or not ogg are supported by your browser.
  26508. */
  26509. isOGGsupported: boolean;
  26510. /**
  26511. * Gets whether audio has been unlocked on the device.
  26512. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26513. * a user interaction has happened.
  26514. */
  26515. unlocked: boolean;
  26516. /**
  26517. * Defines if the audio engine relies on a custom unlocked button.
  26518. * In this case, the embedded button will not be displayed.
  26519. */
  26520. useCustomUnlockedButton: boolean;
  26521. /**
  26522. * Event raised when audio has been unlocked on the browser.
  26523. */
  26524. onAudioUnlockedObservable: Observable<AudioEngine>;
  26525. /**
  26526. * Event raised when audio has been locked on the browser.
  26527. */
  26528. onAudioLockedObservable: Observable<AudioEngine>;
  26529. /**
  26530. * Gets the current AudioContext if available.
  26531. */
  26532. readonly audioContext: Nullable<AudioContext>;
  26533. private _connectedAnalyser;
  26534. /**
  26535. * Instantiates a new audio engine.
  26536. *
  26537. * There should be only one per page as some browsers restrict the number
  26538. * of audio contexts you can create.
  26539. * @param hostElement defines the host element where to display the mute icon if necessary
  26540. */
  26541. constructor(hostElement?: Nullable<HTMLElement>);
  26542. /**
  26543. * Flags the audio engine in Locked state.
  26544. * This happens due to new browser policies preventing audio to autoplay.
  26545. */
  26546. lock(): void;
  26547. /**
  26548. * Unlocks the audio engine once a user action has been done on the dom.
  26549. * This is helpful to resume play once browser policies have been satisfied.
  26550. */
  26551. unlock(): void;
  26552. private _resumeAudioContext;
  26553. private _initializeAudioContext;
  26554. private _tryToRun;
  26555. private _triggerRunningState;
  26556. private _triggerSuspendedState;
  26557. private _displayMuteButton;
  26558. private _moveButtonToTopLeft;
  26559. private _onResize;
  26560. private _hideMuteButton;
  26561. /**
  26562. * Destroy and release the resources associated with the audio ccontext.
  26563. */
  26564. dispose(): void;
  26565. /**
  26566. * Gets the global volume sets on the master gain.
  26567. * @returns the global volume if set or -1 otherwise
  26568. */
  26569. getGlobalVolume(): number;
  26570. /**
  26571. * Sets the global volume of your experience (sets on the master gain).
  26572. * @param newVolume Defines the new global volume of the application
  26573. */
  26574. setGlobalVolume(newVolume: number): void;
  26575. /**
  26576. * Connect the audio engine to an audio analyser allowing some amazing
  26577. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26579. * @param analyser The analyser to connect to the engine
  26580. */
  26581. connectToAnalyser(analyser: Analyser): void;
  26582. }
  26583. }
  26584. declare module "babylonjs/Loading/loadingScreen" {
  26585. /**
  26586. * Interface used to present a loading screen while loading a scene
  26587. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26588. */
  26589. export interface ILoadingScreen {
  26590. /**
  26591. * Function called to display the loading screen
  26592. */
  26593. displayLoadingUI: () => void;
  26594. /**
  26595. * Function called to hide the loading screen
  26596. */
  26597. hideLoadingUI: () => void;
  26598. /**
  26599. * Gets or sets the color to use for the background
  26600. */
  26601. loadingUIBackgroundColor: string;
  26602. /**
  26603. * Gets or sets the text to display while loading
  26604. */
  26605. loadingUIText: string;
  26606. }
  26607. /**
  26608. * Class used for the default loading screen
  26609. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26610. */
  26611. export class DefaultLoadingScreen implements ILoadingScreen {
  26612. private _renderingCanvas;
  26613. private _loadingText;
  26614. private _loadingDivBackgroundColor;
  26615. private _loadingDiv;
  26616. private _loadingTextDiv;
  26617. /**
  26618. * Creates a new default loading screen
  26619. * @param _renderingCanvas defines the canvas used to render the scene
  26620. * @param _loadingText defines the default text to display
  26621. * @param _loadingDivBackgroundColor defines the default background color
  26622. */
  26623. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26624. /**
  26625. * Function called to display the loading screen
  26626. */
  26627. displayLoadingUI(): void;
  26628. /**
  26629. * Function called to hide the loading screen
  26630. */
  26631. hideLoadingUI(): void;
  26632. /**
  26633. * Gets or sets the text to display while loading
  26634. */
  26635. loadingUIText: string;
  26636. /**
  26637. * Gets or sets the color to use for the background
  26638. */
  26639. loadingUIBackgroundColor: string;
  26640. private _resizeLoadingUI;
  26641. }
  26642. }
  26643. declare module "babylonjs/Materials/Textures/videoTexture" {
  26644. import { Observable } from "babylonjs/Misc/observable";
  26645. import { Nullable } from "babylonjs/types";
  26646. import { Scene } from "babylonjs/scene";
  26647. import { Texture } from "babylonjs/Materials/Textures/texture";
  26648. /**
  26649. * Settings for finer control over video usage
  26650. */
  26651. export interface VideoTextureSettings {
  26652. /**
  26653. * Applies `autoplay` to video, if specified
  26654. */
  26655. autoPlay?: boolean;
  26656. /**
  26657. * Applies `loop` to video, if specified
  26658. */
  26659. loop?: boolean;
  26660. /**
  26661. * Automatically updates internal texture from video at every frame in the render loop
  26662. */
  26663. autoUpdateTexture: boolean;
  26664. /**
  26665. * Image src displayed during the video loading or until the user interacts with the video.
  26666. */
  26667. poster?: string;
  26668. }
  26669. /**
  26670. * If you want to display a video in your scene, this is the special texture for that.
  26671. * This special texture works similar to other textures, with the exception of a few parameters.
  26672. * @see https://doc.babylonjs.com/how_to/video_texture
  26673. */
  26674. export class VideoTexture extends Texture {
  26675. /**
  26676. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26677. */
  26678. readonly autoUpdateTexture: boolean;
  26679. /**
  26680. * The video instance used by the texture internally
  26681. */
  26682. readonly video: HTMLVideoElement;
  26683. private _onUserActionRequestedObservable;
  26684. /**
  26685. * Event triggerd when a dom action is required by the user to play the video.
  26686. * This happens due to recent changes in browser policies preventing video to auto start.
  26687. */
  26688. readonly onUserActionRequestedObservable: Observable<Texture>;
  26689. private _generateMipMaps;
  26690. private _engine;
  26691. private _stillImageCaptured;
  26692. private _displayingPosterTexture;
  26693. private _settings;
  26694. private _createInternalTextureOnEvent;
  26695. /**
  26696. * Creates a video texture.
  26697. * If you want to display a video in your scene, this is the special texture for that.
  26698. * This special texture works similar to other textures, with the exception of a few parameters.
  26699. * @see https://doc.babylonjs.com/how_to/video_texture
  26700. * @param name optional name, will detect from video source, if not defined
  26701. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26702. * @param scene is obviously the current scene.
  26703. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26704. * @param invertY is false by default but can be used to invert video on Y axis
  26705. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26706. * @param settings allows finer control over video usage
  26707. */
  26708. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26709. private _getName;
  26710. private _getVideo;
  26711. private _createInternalTexture;
  26712. private reset;
  26713. /**
  26714. * @hidden Internal method to initiate `update`.
  26715. */
  26716. _rebuild(): void;
  26717. /**
  26718. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26719. */
  26720. update(): void;
  26721. /**
  26722. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26723. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26724. */
  26725. updateTexture(isVisible: boolean): void;
  26726. protected _updateInternalTexture: () => void;
  26727. /**
  26728. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26729. * @param url New url.
  26730. */
  26731. updateURL(url: string): void;
  26732. /**
  26733. * Dispose the texture and release its associated resources.
  26734. */
  26735. dispose(): void;
  26736. /**
  26737. * Creates a video texture straight from a stream.
  26738. * @param scene Define the scene the texture should be created in
  26739. * @param stream Define the stream the texture should be created from
  26740. * @returns The created video texture as a promise
  26741. */
  26742. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26743. /**
  26744. * Creates a video texture straight from your WebCam video feed.
  26745. * @param scene Define the scene the texture should be created in
  26746. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26747. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26748. * @returns The created video texture as a promise
  26749. */
  26750. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26751. minWidth: number;
  26752. maxWidth: number;
  26753. minHeight: number;
  26754. maxHeight: number;
  26755. deviceId: string;
  26756. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26757. /**
  26758. * Creates a video texture straight from your WebCam video feed.
  26759. * @param scene Define the scene the texture should be created in
  26760. * @param onReady Define a callback to triggered once the texture will be ready
  26761. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26762. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26763. */
  26764. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26765. minWidth: number;
  26766. maxWidth: number;
  26767. minHeight: number;
  26768. maxHeight: number;
  26769. deviceId: string;
  26770. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26771. }
  26772. }
  26773. declare module "babylonjs/Engines/engine" {
  26774. import { Observable } from "babylonjs/Misc/observable";
  26775. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26776. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26777. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26778. import { Camera } from "babylonjs/Cameras/camera";
  26779. import { Scene } from "babylonjs/scene";
  26780. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26781. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26782. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26783. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26784. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26785. import { Material } from "babylonjs/Materials/material";
  26786. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26787. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26788. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26789. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26790. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26791. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26792. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26793. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26794. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26795. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26796. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26797. /**
  26798. * Interface for attribute information associated with buffer instanciation
  26799. */
  26800. export class InstancingAttributeInfo {
  26801. /**
  26802. * Index/offset of the attribute in the vertex shader
  26803. */
  26804. index: number;
  26805. /**
  26806. * size of the attribute, 1, 2, 3 or 4
  26807. */
  26808. attributeSize: number;
  26809. /**
  26810. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26811. * default is FLOAT
  26812. */
  26813. attribyteType: number;
  26814. /**
  26815. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26816. */
  26817. normalized: boolean;
  26818. /**
  26819. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26820. */
  26821. offset: number;
  26822. /**
  26823. * Name of the GLSL attribute, for debugging purpose only
  26824. */
  26825. attributeName: string;
  26826. }
  26827. /**
  26828. * Define options used to create a depth texture
  26829. */
  26830. export class DepthTextureCreationOptions {
  26831. /** Specifies whether or not a stencil should be allocated in the texture */
  26832. generateStencil?: boolean;
  26833. /** Specifies whether or not bilinear filtering is enable on the texture */
  26834. bilinearFiltering?: boolean;
  26835. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26836. comparisonFunction?: number;
  26837. /** Specifies if the created texture is a cube texture */
  26838. isCube?: boolean;
  26839. }
  26840. /**
  26841. * Class used to describe the capabilities of the engine relatively to the current browser
  26842. */
  26843. export class EngineCapabilities {
  26844. /** Maximum textures units per fragment shader */
  26845. maxTexturesImageUnits: number;
  26846. /** Maximum texture units per vertex shader */
  26847. maxVertexTextureImageUnits: number;
  26848. /** Maximum textures units in the entire pipeline */
  26849. maxCombinedTexturesImageUnits: number;
  26850. /** Maximum texture size */
  26851. maxTextureSize: number;
  26852. /** Maximum cube texture size */
  26853. maxCubemapTextureSize: number;
  26854. /** Maximum render texture size */
  26855. maxRenderTextureSize: number;
  26856. /** Maximum number of vertex attributes */
  26857. maxVertexAttribs: number;
  26858. /** Maximum number of varyings */
  26859. maxVaryingVectors: number;
  26860. /** Maximum number of uniforms per vertex shader */
  26861. maxVertexUniformVectors: number;
  26862. /** Maximum number of uniforms per fragment shader */
  26863. maxFragmentUniformVectors: number;
  26864. /** Defines if standard derivates (dx/dy) are supported */
  26865. standardDerivatives: boolean;
  26866. /** Defines if s3tc texture compression is supported */
  26867. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26868. /** Defines if pvrtc texture compression is supported */
  26869. pvrtc: any;
  26870. /** Defines if etc1 texture compression is supported */
  26871. etc1: any;
  26872. /** Defines if etc2 texture compression is supported */
  26873. etc2: any;
  26874. /** Defines if astc texture compression is supported */
  26875. astc: any;
  26876. /** Defines if float textures are supported */
  26877. textureFloat: boolean;
  26878. /** Defines if vertex array objects are supported */
  26879. vertexArrayObject: boolean;
  26880. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26881. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26882. /** Gets the maximum level of anisotropy supported */
  26883. maxAnisotropy: number;
  26884. /** Defines if instancing is supported */
  26885. instancedArrays: boolean;
  26886. /** Defines if 32 bits indices are supported */
  26887. uintIndices: boolean;
  26888. /** Defines if high precision shaders are supported */
  26889. highPrecisionShaderSupported: boolean;
  26890. /** Defines if depth reading in the fragment shader is supported */
  26891. fragmentDepthSupported: boolean;
  26892. /** Defines if float texture linear filtering is supported*/
  26893. textureFloatLinearFiltering: boolean;
  26894. /** Defines if rendering to float textures is supported */
  26895. textureFloatRender: boolean;
  26896. /** Defines if half float textures are supported*/
  26897. textureHalfFloat: boolean;
  26898. /** Defines if half float texture linear filtering is supported*/
  26899. textureHalfFloatLinearFiltering: boolean;
  26900. /** Defines if rendering to half float textures is supported */
  26901. textureHalfFloatRender: boolean;
  26902. /** Defines if textureLOD shader command is supported */
  26903. textureLOD: boolean;
  26904. /** Defines if draw buffers extension is supported */
  26905. drawBuffersExtension: boolean;
  26906. /** Defines if depth textures are supported */
  26907. depthTextureExtension: boolean;
  26908. /** Defines if float color buffer are supported */
  26909. colorBufferFloat: boolean;
  26910. /** Gets disjoint timer query extension (null if not supported) */
  26911. timerQuery: EXT_disjoint_timer_query;
  26912. /** Defines if timestamp can be used with timer query */
  26913. canUseTimestampForTimerQuery: boolean;
  26914. /** Function used to let the system compiles shaders in background */
  26915. parallelShaderCompile: {
  26916. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26917. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26918. COMPLETION_STATUS_KHR: number;
  26919. };
  26920. }
  26921. /** Interface defining initialization parameters for Engine class */
  26922. export interface EngineOptions extends WebGLContextAttributes {
  26923. /**
  26924. * Defines if the engine should no exceed a specified device ratio
  26925. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26926. */
  26927. limitDeviceRatio?: number;
  26928. /**
  26929. * Defines if webvr should be enabled automatically
  26930. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26931. */
  26932. autoEnableWebVR?: boolean;
  26933. /**
  26934. * Defines if webgl2 should be turned off even if supported
  26935. * @see http://doc.babylonjs.com/features/webgl2
  26936. */
  26937. disableWebGL2Support?: boolean;
  26938. /**
  26939. * Defines if webaudio should be initialized as well
  26940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26941. */
  26942. audioEngine?: boolean;
  26943. /**
  26944. * Defines if animations should run using a deterministic lock step
  26945. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26946. */
  26947. deterministicLockstep?: boolean;
  26948. /** Defines the maximum steps to use with deterministic lock step mode */
  26949. lockstepMaxSteps?: number;
  26950. /**
  26951. * Defines that engine should ignore context lost events
  26952. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26953. */
  26954. doNotHandleContextLost?: boolean;
  26955. /**
  26956. * Defines that engine should ignore modifying touch action attribute and style
  26957. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26958. */
  26959. doNotHandleTouchAction?: boolean;
  26960. }
  26961. /**
  26962. * Defines the interface used by display changed events
  26963. */
  26964. export interface IDisplayChangedEventArgs {
  26965. /** Gets the vrDisplay object (if any) */
  26966. vrDisplay: Nullable<any>;
  26967. /** Gets a boolean indicating if webVR is supported */
  26968. vrSupported: boolean;
  26969. }
  26970. /**
  26971. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26972. */
  26973. export class Engine {
  26974. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26975. static ExceptionList: ({
  26976. key: string;
  26977. capture: string;
  26978. captureConstraint: number;
  26979. targets: string[];
  26980. } | {
  26981. key: string;
  26982. capture: null;
  26983. captureConstraint: null;
  26984. targets: string[];
  26985. })[];
  26986. /** Gets the list of created engines */
  26987. static readonly Instances: Engine[];
  26988. /**
  26989. * Gets the latest created engine
  26990. */
  26991. static readonly LastCreatedEngine: Nullable<Engine>;
  26992. /**
  26993. * Gets the latest created scene
  26994. */
  26995. static readonly LastCreatedScene: Nullable<Scene>;
  26996. /**
  26997. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26998. * @param flag defines which part of the materials must be marked as dirty
  26999. * @param predicate defines a predicate used to filter which materials should be affected
  27000. */
  27001. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27002. /**
  27003. * Hidden
  27004. */
  27005. static _TextureLoaders: IInternalTextureLoader[];
  27006. /** Defines that alpha blending is disabled */
  27007. static readonly ALPHA_DISABLE: number;
  27008. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27009. static readonly ALPHA_ADD: number;
  27010. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27011. static readonly ALPHA_COMBINE: number;
  27012. /** Defines that alpha blending to DEST - SRC * DEST */
  27013. static readonly ALPHA_SUBTRACT: number;
  27014. /** Defines that alpha blending to SRC * DEST */
  27015. static readonly ALPHA_MULTIPLY: number;
  27016. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27017. static readonly ALPHA_MAXIMIZED: number;
  27018. /** Defines that alpha blending to SRC + DEST */
  27019. static readonly ALPHA_ONEONE: number;
  27020. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27021. static readonly ALPHA_PREMULTIPLIED: number;
  27022. /**
  27023. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27024. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27025. */
  27026. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27027. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27028. static readonly ALPHA_INTERPOLATE: number;
  27029. /**
  27030. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27031. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27032. */
  27033. static readonly ALPHA_SCREENMODE: number;
  27034. /** Defines that the ressource is not delayed*/
  27035. static readonly DELAYLOADSTATE_NONE: number;
  27036. /** Defines that the ressource was successfully delay loaded */
  27037. static readonly DELAYLOADSTATE_LOADED: number;
  27038. /** Defines that the ressource is currently delay loading */
  27039. static readonly DELAYLOADSTATE_LOADING: number;
  27040. /** Defines that the ressource is delayed and has not started loading */
  27041. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27042. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27043. static readonly NEVER: number;
  27044. /** 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 */
  27045. static readonly ALWAYS: number;
  27046. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27047. static readonly LESS: number;
  27048. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27049. static readonly EQUAL: number;
  27050. /** 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 */
  27051. static readonly LEQUAL: number;
  27052. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27053. static readonly GREATER: number;
  27054. /** 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 */
  27055. static readonly GEQUAL: number;
  27056. /** 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 */
  27057. static readonly NOTEQUAL: number;
  27058. /** Passed to stencilOperation to specify that stencil value must be kept */
  27059. static readonly KEEP: number;
  27060. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27061. static readonly REPLACE: number;
  27062. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27063. static readonly INCR: number;
  27064. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27065. static readonly DECR: number;
  27066. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27067. static readonly INVERT: number;
  27068. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27069. static readonly INCR_WRAP: number;
  27070. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27071. static readonly DECR_WRAP: number;
  27072. /** Texture is not repeating outside of 0..1 UVs */
  27073. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27074. /** Texture is repeating outside of 0..1 UVs */
  27075. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27076. /** Texture is repeating and mirrored */
  27077. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27078. /** ALPHA */
  27079. static readonly TEXTUREFORMAT_ALPHA: number;
  27080. /** LUMINANCE */
  27081. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27082. /** LUMINANCE_ALPHA */
  27083. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27084. /** RGB */
  27085. static readonly TEXTUREFORMAT_RGB: number;
  27086. /** RGBA */
  27087. static readonly TEXTUREFORMAT_RGBA: number;
  27088. /** RED */
  27089. static readonly TEXTUREFORMAT_RED: number;
  27090. /** RED (2nd reference) */
  27091. static readonly TEXTUREFORMAT_R: number;
  27092. /** RG */
  27093. static readonly TEXTUREFORMAT_RG: number;
  27094. /** RED_INTEGER */
  27095. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27096. /** RED_INTEGER (2nd reference) */
  27097. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27098. /** RG_INTEGER */
  27099. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27100. /** RGB_INTEGER */
  27101. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27102. /** RGBA_INTEGER */
  27103. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27104. /** UNSIGNED_BYTE */
  27105. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27106. /** UNSIGNED_BYTE (2nd reference) */
  27107. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27108. /** FLOAT */
  27109. static readonly TEXTURETYPE_FLOAT: number;
  27110. /** HALF_FLOAT */
  27111. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27112. /** BYTE */
  27113. static readonly TEXTURETYPE_BYTE: number;
  27114. /** SHORT */
  27115. static readonly TEXTURETYPE_SHORT: number;
  27116. /** UNSIGNED_SHORT */
  27117. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27118. /** INT */
  27119. static readonly TEXTURETYPE_INT: number;
  27120. /** UNSIGNED_INT */
  27121. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27122. /** UNSIGNED_SHORT_4_4_4_4 */
  27123. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27124. /** UNSIGNED_SHORT_5_5_5_1 */
  27125. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27126. /** UNSIGNED_SHORT_5_6_5 */
  27127. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27128. /** UNSIGNED_INT_2_10_10_10_REV */
  27129. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27130. /** UNSIGNED_INT_24_8 */
  27131. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27132. /** UNSIGNED_INT_10F_11F_11F_REV */
  27133. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27134. /** UNSIGNED_INT_5_9_9_9_REV */
  27135. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27136. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27137. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27138. /** nearest is mag = nearest and min = nearest and mip = linear */
  27139. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27140. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27141. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27142. /** Trilinear is mag = linear and min = linear and mip = linear */
  27143. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27144. /** nearest is mag = nearest and min = nearest and mip = linear */
  27145. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27146. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27147. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27148. /** Trilinear is mag = linear and min = linear and mip = linear */
  27149. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27150. /** mag = nearest and min = nearest and mip = nearest */
  27151. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27152. /** mag = nearest and min = linear and mip = nearest */
  27153. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27154. /** mag = nearest and min = linear and mip = linear */
  27155. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27156. /** mag = nearest and min = linear and mip = none */
  27157. static readonly TEXTURE_NEAREST_LINEAR: number;
  27158. /** mag = nearest and min = nearest and mip = none */
  27159. static readonly TEXTURE_NEAREST_NEAREST: number;
  27160. /** mag = linear and min = nearest and mip = nearest */
  27161. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27162. /** mag = linear and min = nearest and mip = linear */
  27163. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27164. /** mag = linear and min = linear and mip = none */
  27165. static readonly TEXTURE_LINEAR_LINEAR: number;
  27166. /** mag = linear and min = nearest and mip = none */
  27167. static readonly TEXTURE_LINEAR_NEAREST: number;
  27168. /** Explicit coordinates mode */
  27169. static readonly TEXTURE_EXPLICIT_MODE: number;
  27170. /** Spherical coordinates mode */
  27171. static readonly TEXTURE_SPHERICAL_MODE: number;
  27172. /** Planar coordinates mode */
  27173. static readonly TEXTURE_PLANAR_MODE: number;
  27174. /** Cubic coordinates mode */
  27175. static readonly TEXTURE_CUBIC_MODE: number;
  27176. /** Projection coordinates mode */
  27177. static readonly TEXTURE_PROJECTION_MODE: number;
  27178. /** Skybox coordinates mode */
  27179. static readonly TEXTURE_SKYBOX_MODE: number;
  27180. /** Inverse Cubic coordinates mode */
  27181. static readonly TEXTURE_INVCUBIC_MODE: number;
  27182. /** Equirectangular coordinates mode */
  27183. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27184. /** Equirectangular Fixed coordinates mode */
  27185. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27186. /** Equirectangular Fixed Mirrored coordinates mode */
  27187. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27188. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27189. static readonly SCALEMODE_FLOOR: number;
  27190. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27191. static readonly SCALEMODE_NEAREST: number;
  27192. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27193. static readonly SCALEMODE_CEILING: number;
  27194. /**
  27195. * Returns the current version of the framework
  27196. */
  27197. static readonly Version: string;
  27198. /**
  27199. * Returns a string describing the current engine
  27200. */
  27201. readonly description: string;
  27202. /**
  27203. * Gets or sets the epsilon value used by collision engine
  27204. */
  27205. static CollisionsEpsilon: number;
  27206. /**
  27207. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27208. */
  27209. static ShadersRepository: string;
  27210. /**
  27211. * Method called to create the default loading screen.
  27212. * This can be overriden in your own app.
  27213. * @param canvas The rendering canvas element
  27214. * @returns The loading screen
  27215. */
  27216. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27217. /**
  27218. * Method called to create the default rescale post process on each engine.
  27219. */
  27220. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27221. /**
  27222. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27223. */
  27224. forcePOTTextures: boolean;
  27225. /**
  27226. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27227. */
  27228. isFullscreen: boolean;
  27229. /**
  27230. * Gets a boolean indicating if the pointer is currently locked
  27231. */
  27232. isPointerLock: boolean;
  27233. /**
  27234. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27235. */
  27236. cullBackFaces: boolean;
  27237. /**
  27238. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27239. */
  27240. renderEvenInBackground: boolean;
  27241. /**
  27242. * Gets or sets a boolean indicating that cache can be kept between frames
  27243. */
  27244. preventCacheWipeBetweenFrames: boolean;
  27245. /**
  27246. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27247. **/
  27248. enableOfflineSupport: boolean;
  27249. /**
  27250. * 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)
  27251. **/
  27252. disableManifestCheck: boolean;
  27253. /**
  27254. * Gets the list of created scenes
  27255. */
  27256. scenes: Scene[];
  27257. /**
  27258. * Event raised when a new scene is created
  27259. */
  27260. onNewSceneAddedObservable: Observable<Scene>;
  27261. /**
  27262. * Gets the list of created postprocesses
  27263. */
  27264. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27265. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27266. validateShaderPrograms: boolean;
  27267. /**
  27268. * Observable event triggered each time the rendering canvas is resized
  27269. */
  27270. onResizeObservable: Observable<Engine>;
  27271. /**
  27272. * Observable event triggered each time the canvas loses focus
  27273. */
  27274. onCanvasBlurObservable: Observable<Engine>;
  27275. /**
  27276. * Observable event triggered each time the canvas gains focus
  27277. */
  27278. onCanvasFocusObservable: Observable<Engine>;
  27279. /**
  27280. * Observable event triggered each time the canvas receives pointerout event
  27281. */
  27282. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27283. /**
  27284. * Observable event triggered before each texture is initialized
  27285. */
  27286. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27287. private _vrDisplay;
  27288. private _vrSupported;
  27289. private _oldSize;
  27290. private _oldHardwareScaleFactor;
  27291. private _vrExclusivePointerMode;
  27292. private _webVRInitPromise;
  27293. /**
  27294. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27295. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27296. */
  27297. readonly isInVRExclusivePointerMode: boolean;
  27298. /**
  27299. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27300. */
  27301. disableUniformBuffers: boolean;
  27302. /** @hidden */
  27303. _uniformBuffers: UniformBuffer[];
  27304. /**
  27305. * Gets a boolean indicating that the engine supports uniform buffers
  27306. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27307. */
  27308. readonly supportsUniformBuffers: boolean;
  27309. /**
  27310. * Observable raised when the engine begins a new frame
  27311. */
  27312. onBeginFrameObservable: Observable<Engine>;
  27313. /**
  27314. * If set, will be used to request the next animation frame for the render loop
  27315. */
  27316. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27317. /**
  27318. * Observable raised when the engine ends the current frame
  27319. */
  27320. onEndFrameObservable: Observable<Engine>;
  27321. /**
  27322. * Observable raised when the engine is about to compile a shader
  27323. */
  27324. onBeforeShaderCompilationObservable: Observable<Engine>;
  27325. /**
  27326. * Observable raised when the engine has jsut compiled a shader
  27327. */
  27328. onAfterShaderCompilationObservable: Observable<Engine>;
  27329. /** @hidden */
  27330. _gl: WebGLRenderingContext;
  27331. private _renderingCanvas;
  27332. private _windowIsBackground;
  27333. private _webGLVersion;
  27334. /**
  27335. * Gets a boolean indicating that only power of 2 textures are supported
  27336. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27337. */
  27338. readonly needPOTTextures: boolean;
  27339. /** @hidden */
  27340. _badOS: boolean;
  27341. /** @hidden */
  27342. _badDesktopOS: boolean;
  27343. /**
  27344. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27345. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27346. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27347. */
  27348. disableTextureBindingOptimization: boolean;
  27349. /**
  27350. * Gets the audio engine
  27351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27352. * @ignorenaming
  27353. */
  27354. static audioEngine: IAudioEngine;
  27355. /**
  27356. * Default AudioEngine factory responsible of creating the Audio Engine.
  27357. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27358. */
  27359. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27360. /**
  27361. * Default offline support factory responsible of creating a tool used to store data locally.
  27362. * By default, this will create a Database object if the workload has been embedded.
  27363. */
  27364. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27365. private _onFocus;
  27366. private _onBlur;
  27367. private _onCanvasPointerOut;
  27368. private _onCanvasBlur;
  27369. private _onCanvasFocus;
  27370. private _onFullscreenChange;
  27371. private _onPointerLockChange;
  27372. private _onVRDisplayPointerRestricted;
  27373. private _onVRDisplayPointerUnrestricted;
  27374. private _onVrDisplayConnect;
  27375. private _onVrDisplayDisconnect;
  27376. private _onVrDisplayPresentChange;
  27377. /**
  27378. * Observable signaled when VR display mode changes
  27379. */
  27380. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27381. /**
  27382. * Observable signaled when VR request present is complete
  27383. */
  27384. onVRRequestPresentComplete: Observable<boolean>;
  27385. /**
  27386. * Observable signaled when VR request present starts
  27387. */
  27388. onVRRequestPresentStart: Observable<Engine>;
  27389. private _hardwareScalingLevel;
  27390. /** @hidden */
  27391. protected _caps: EngineCapabilities;
  27392. private _pointerLockRequested;
  27393. private _isStencilEnable;
  27394. private _colorWrite;
  27395. private _loadingScreen;
  27396. /** @hidden */
  27397. _drawCalls: PerfCounter;
  27398. /** @hidden */
  27399. _textureCollisions: PerfCounter;
  27400. private _glVersion;
  27401. private _glRenderer;
  27402. private _glVendor;
  27403. private _videoTextureSupported;
  27404. private _renderingQueueLaunched;
  27405. private _activeRenderLoops;
  27406. private _deterministicLockstep;
  27407. private _lockstepMaxSteps;
  27408. /**
  27409. * Observable signaled when a context lost event is raised
  27410. */
  27411. onContextLostObservable: Observable<Engine>;
  27412. /**
  27413. * Observable signaled when a context restored event is raised
  27414. */
  27415. onContextRestoredObservable: Observable<Engine>;
  27416. private _onContextLost;
  27417. private _onContextRestored;
  27418. private _contextWasLost;
  27419. private _doNotHandleContextLost;
  27420. /**
  27421. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27422. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27423. */
  27424. doNotHandleContextLost: boolean;
  27425. private _performanceMonitor;
  27426. private _fps;
  27427. private _deltaTime;
  27428. /**
  27429. * Turn this value on if you want to pause FPS computation when in background
  27430. */
  27431. disablePerformanceMonitorInBackground: boolean;
  27432. /**
  27433. * Gets the performance monitor attached to this engine
  27434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27435. */
  27436. readonly performanceMonitor: PerformanceMonitor;
  27437. /** @hidden */
  27438. protected _depthCullingState: _DepthCullingState;
  27439. /** @hidden */
  27440. protected _stencilState: _StencilState;
  27441. /** @hidden */
  27442. protected _alphaState: _AlphaState;
  27443. /** @hidden */
  27444. protected _alphaMode: number;
  27445. protected _internalTexturesCache: InternalTexture[];
  27446. /** @hidden */
  27447. protected _activeChannel: number;
  27448. private _currentTextureChannel;
  27449. /** @hidden */
  27450. protected _boundTexturesCache: {
  27451. [key: string]: Nullable<InternalTexture>;
  27452. };
  27453. /** @hidden */
  27454. protected _currentEffect: Nullable<Effect>;
  27455. /** @hidden */
  27456. protected _currentProgram: Nullable<WebGLProgram>;
  27457. private _compiledEffects;
  27458. private _vertexAttribArraysEnabled;
  27459. /** @hidden */
  27460. protected _cachedViewport: Nullable<Viewport>;
  27461. private _cachedVertexArrayObject;
  27462. /** @hidden */
  27463. protected _cachedVertexBuffers: any;
  27464. /** @hidden */
  27465. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27466. /** @hidden */
  27467. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27468. /** @hidden */
  27469. protected _currentRenderTarget: Nullable<InternalTexture>;
  27470. private _uintIndicesCurrentlySet;
  27471. private _currentBoundBuffer;
  27472. /** @hidden */
  27473. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27474. private _currentBufferPointers;
  27475. private _currentInstanceLocations;
  27476. private _currentInstanceBuffers;
  27477. private _textureUnits;
  27478. private _firstBoundInternalTextureTracker;
  27479. private _lastBoundInternalTextureTracker;
  27480. private _workingCanvas;
  27481. private _workingContext;
  27482. private _rescalePostProcess;
  27483. private _dummyFramebuffer;
  27484. private _externalData;
  27485. private _bindedRenderFunction;
  27486. private _vaoRecordInProgress;
  27487. private _mustWipeVertexAttributes;
  27488. private _emptyTexture;
  27489. private _emptyCubeTexture;
  27490. private _emptyTexture3D;
  27491. /** @hidden */
  27492. _frameHandler: number;
  27493. private _nextFreeTextureSlots;
  27494. private _maxSimultaneousTextures;
  27495. private _activeRequests;
  27496. private _texturesSupported;
  27497. private _textureFormatInUse;
  27498. /**
  27499. * Gets the list of texture formats supported
  27500. */
  27501. readonly texturesSupported: Array<string>;
  27502. /**
  27503. * Gets the list of texture formats in use
  27504. */
  27505. readonly textureFormatInUse: Nullable<string>;
  27506. /**
  27507. * Gets the current viewport
  27508. */
  27509. readonly currentViewport: Nullable<Viewport>;
  27510. /**
  27511. * Gets the default empty texture
  27512. */
  27513. readonly emptyTexture: InternalTexture;
  27514. /**
  27515. * Gets the default empty 3D texture
  27516. */
  27517. readonly emptyTexture3D: InternalTexture;
  27518. /**
  27519. * Gets the default empty cube texture
  27520. */
  27521. readonly emptyCubeTexture: InternalTexture;
  27522. /**
  27523. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27524. */
  27525. readonly premultipliedAlpha: boolean;
  27526. /**
  27527. * Creates a new engine
  27528. * @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
  27529. * @param antialias defines enable antialiasing (default: false)
  27530. * @param options defines further options to be sent to the getContext() function
  27531. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27532. */
  27533. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27534. private _disableTouchAction;
  27535. private _rebuildInternalTextures;
  27536. private _rebuildEffects;
  27537. /**
  27538. * Gets a boolean indicating if all created effects are ready
  27539. * @returns true if all effects are ready
  27540. */
  27541. areAllEffectsReady(): boolean;
  27542. private _rebuildBuffers;
  27543. private _initGLContext;
  27544. /**
  27545. * Gets version of the current webGL context
  27546. */
  27547. readonly webGLVersion: number;
  27548. /**
  27549. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27550. */
  27551. readonly isStencilEnable: boolean;
  27552. private _prepareWorkingCanvas;
  27553. /**
  27554. * Reset the texture cache to empty state
  27555. */
  27556. resetTextureCache(): void;
  27557. /**
  27558. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27559. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27560. * @returns true if engine is in deterministic lock step mode
  27561. */
  27562. isDeterministicLockStep(): boolean;
  27563. /**
  27564. * Gets the max steps when engine is running in deterministic lock step
  27565. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27566. * @returns the max steps
  27567. */
  27568. getLockstepMaxSteps(): number;
  27569. /**
  27570. * Gets an object containing information about the current webGL context
  27571. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27572. */
  27573. getGlInfo(): {
  27574. vendor: string;
  27575. renderer: string;
  27576. version: string;
  27577. };
  27578. /**
  27579. * Gets current aspect ratio
  27580. * @param camera defines the camera to use to get the aspect ratio
  27581. * @param useScreen defines if screen size must be used (or the current render target if any)
  27582. * @returns a number defining the aspect ratio
  27583. */
  27584. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27585. /**
  27586. * Gets current screen aspect ratio
  27587. * @returns a number defining the aspect ratio
  27588. */
  27589. getScreenAspectRatio(): number;
  27590. /**
  27591. * Gets the current render width
  27592. * @param useScreen defines if screen size must be used (or the current render target if any)
  27593. * @returns a number defining the current render width
  27594. */
  27595. getRenderWidth(useScreen?: boolean): number;
  27596. /**
  27597. * Gets the current render height
  27598. * @param useScreen defines if screen size must be used (or the current render target if any)
  27599. * @returns a number defining the current render height
  27600. */
  27601. getRenderHeight(useScreen?: boolean): number;
  27602. /**
  27603. * Gets the HTML canvas attached with the current webGL context
  27604. * @returns a HTML canvas
  27605. */
  27606. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27607. /**
  27608. * Gets the client rect of the HTML canvas attached with the current webGL context
  27609. * @returns a client rectanglee
  27610. */
  27611. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27612. /**
  27613. * Defines the hardware scaling level.
  27614. * By default the hardware scaling level is computed from the window device ratio.
  27615. * 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.
  27616. * @param level defines the level to use
  27617. */
  27618. setHardwareScalingLevel(level: number): void;
  27619. /**
  27620. * Gets the current hardware scaling level.
  27621. * By default the hardware scaling level is computed from the window device ratio.
  27622. * 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.
  27623. * @returns a number indicating the current hardware scaling level
  27624. */
  27625. getHardwareScalingLevel(): number;
  27626. /**
  27627. * Gets the list of loaded textures
  27628. * @returns an array containing all loaded textures
  27629. */
  27630. getLoadedTexturesCache(): InternalTexture[];
  27631. /**
  27632. * Gets the object containing all engine capabilities
  27633. * @returns the EngineCapabilities object
  27634. */
  27635. getCaps(): EngineCapabilities;
  27636. /**
  27637. * Gets the current depth function
  27638. * @returns a number defining the depth function
  27639. */
  27640. getDepthFunction(): Nullable<number>;
  27641. /**
  27642. * Sets the current depth function
  27643. * @param depthFunc defines the function to use
  27644. */
  27645. setDepthFunction(depthFunc: number): void;
  27646. /**
  27647. * Sets the current depth function to GREATER
  27648. */
  27649. setDepthFunctionToGreater(): void;
  27650. /**
  27651. * Sets the current depth function to GEQUAL
  27652. */
  27653. setDepthFunctionToGreaterOrEqual(): void;
  27654. /**
  27655. * Sets the current depth function to LESS
  27656. */
  27657. setDepthFunctionToLess(): void;
  27658. /**
  27659. * Sets the current depth function to LEQUAL
  27660. */
  27661. setDepthFunctionToLessOrEqual(): void;
  27662. /**
  27663. * Gets a boolean indicating if stencil buffer is enabled
  27664. * @returns the current stencil buffer state
  27665. */
  27666. getStencilBuffer(): boolean;
  27667. /**
  27668. * Enable or disable the stencil buffer
  27669. * @param enable defines if the stencil buffer must be enabled or disabled
  27670. */
  27671. setStencilBuffer(enable: boolean): void;
  27672. /**
  27673. * Gets the current stencil mask
  27674. * @returns a number defining the new stencil mask to use
  27675. */
  27676. getStencilMask(): number;
  27677. /**
  27678. * Sets the current stencil mask
  27679. * @param mask defines the new stencil mask to use
  27680. */
  27681. setStencilMask(mask: number): void;
  27682. /**
  27683. * Gets the current stencil function
  27684. * @returns a number defining the stencil function to use
  27685. */
  27686. getStencilFunction(): number;
  27687. /**
  27688. * Gets the current stencil reference value
  27689. * @returns a number defining the stencil reference value to use
  27690. */
  27691. getStencilFunctionReference(): number;
  27692. /**
  27693. * Gets the current stencil mask
  27694. * @returns a number defining the stencil mask to use
  27695. */
  27696. getStencilFunctionMask(): number;
  27697. /**
  27698. * Sets the current stencil function
  27699. * @param stencilFunc defines the new stencil function to use
  27700. */
  27701. setStencilFunction(stencilFunc: number): void;
  27702. /**
  27703. * Sets the current stencil reference
  27704. * @param reference defines the new stencil reference to use
  27705. */
  27706. setStencilFunctionReference(reference: number): void;
  27707. /**
  27708. * Sets the current stencil mask
  27709. * @param mask defines the new stencil mask to use
  27710. */
  27711. setStencilFunctionMask(mask: number): void;
  27712. /**
  27713. * Gets the current stencil operation when stencil fails
  27714. * @returns a number defining stencil operation to use when stencil fails
  27715. */
  27716. getStencilOperationFail(): number;
  27717. /**
  27718. * Gets the current stencil operation when depth fails
  27719. * @returns a number defining stencil operation to use when depth fails
  27720. */
  27721. getStencilOperationDepthFail(): number;
  27722. /**
  27723. * Gets the current stencil operation when stencil passes
  27724. * @returns a number defining stencil operation to use when stencil passes
  27725. */
  27726. getStencilOperationPass(): number;
  27727. /**
  27728. * Sets the stencil operation to use when stencil fails
  27729. * @param operation defines the stencil operation to use when stencil fails
  27730. */
  27731. setStencilOperationFail(operation: number): void;
  27732. /**
  27733. * Sets the stencil operation to use when depth fails
  27734. * @param operation defines the stencil operation to use when depth fails
  27735. */
  27736. setStencilOperationDepthFail(operation: number): void;
  27737. /**
  27738. * Sets the stencil operation to use when stencil passes
  27739. * @param operation defines the stencil operation to use when stencil passes
  27740. */
  27741. setStencilOperationPass(operation: number): void;
  27742. /**
  27743. * Sets a boolean indicating if the dithering state is enabled or disabled
  27744. * @param value defines the dithering state
  27745. */
  27746. setDitheringState(value: boolean): void;
  27747. /**
  27748. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27749. * @param value defines the rasterizer state
  27750. */
  27751. setRasterizerState(value: boolean): void;
  27752. /**
  27753. * stop executing a render loop function and remove it from the execution array
  27754. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27755. */
  27756. stopRenderLoop(renderFunction?: () => void): void;
  27757. /** @hidden */
  27758. _renderLoop(): void;
  27759. /**
  27760. * Register and execute a render loop. The engine can have more than one render function
  27761. * @param renderFunction defines the function to continuously execute
  27762. */
  27763. runRenderLoop(renderFunction: () => void): void;
  27764. /**
  27765. * Toggle full screen mode
  27766. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27767. */
  27768. switchFullscreen(requestPointerLock: boolean): void;
  27769. /**
  27770. * Enters full screen mode
  27771. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27772. */
  27773. enterFullscreen(requestPointerLock: boolean): void;
  27774. /**
  27775. * Exits full screen mode
  27776. */
  27777. exitFullscreen(): void;
  27778. /**
  27779. * Clear the current render buffer or the current render target (if any is set up)
  27780. * @param color defines the color to use
  27781. * @param backBuffer defines if the back buffer must be cleared
  27782. * @param depth defines if the depth buffer must be cleared
  27783. * @param stencil defines if the stencil buffer must be cleared
  27784. */
  27785. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27786. /**
  27787. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27788. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27789. * @param y defines the y-coordinate of the corner of the clear rectangle
  27790. * @param width defines the width of the clear rectangle
  27791. * @param height defines the height of the clear rectangle
  27792. * @param clearColor defines the clear color
  27793. */
  27794. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27795. /**
  27796. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27797. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27798. * @param y defines the y-coordinate of the corner of the clear rectangle
  27799. * @param width defines the width of the clear rectangle
  27800. * @param height defines the height of the clear rectangle
  27801. */
  27802. enableScissor(x: number, y: number, width: number, height: number): void;
  27803. /**
  27804. * Disable previously set scissor test rectangle
  27805. */
  27806. disableScissor(): void;
  27807. private _viewportCached;
  27808. /** @hidden */
  27809. _viewport(x: number, y: number, width: number, height: number): void;
  27810. /**
  27811. * Set the WebGL's viewport
  27812. * @param viewport defines the viewport element to be used
  27813. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27814. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27815. */
  27816. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27817. /**
  27818. * Directly set the WebGL Viewport
  27819. * @param x defines the x coordinate of the viewport (in screen space)
  27820. * @param y defines the y coordinate of the viewport (in screen space)
  27821. * @param width defines the width of the viewport (in screen space)
  27822. * @param height defines the height of the viewport (in screen space)
  27823. * @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
  27824. */
  27825. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27826. /**
  27827. * Begin a new frame
  27828. */
  27829. beginFrame(): void;
  27830. /**
  27831. * Enf the current frame
  27832. */
  27833. endFrame(): void;
  27834. /**
  27835. * Resize the view according to the canvas' size
  27836. */
  27837. resize(): void;
  27838. /**
  27839. * Force a specific size of the canvas
  27840. * @param width defines the new canvas' width
  27841. * @param height defines the new canvas' height
  27842. */
  27843. setSize(width: number, height: number): void;
  27844. /**
  27845. * Gets a boolean indicating if a webVR device was detected
  27846. * @returns true if a webVR device was detected
  27847. */
  27848. isVRDevicePresent(): boolean;
  27849. /**
  27850. * Gets the current webVR device
  27851. * @returns the current webVR device (or null)
  27852. */
  27853. getVRDevice(): any;
  27854. /**
  27855. * Initializes a webVR display and starts listening to display change events
  27856. * The onVRDisplayChangedObservable will be notified upon these changes
  27857. * @returns The onVRDisplayChangedObservable
  27858. */
  27859. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27860. /**
  27861. * Initializes a webVR display and starts listening to display change events
  27862. * The onVRDisplayChangedObservable will be notified upon these changes
  27863. * @returns A promise containing a VRDisplay and if vr is supported
  27864. */
  27865. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27866. /**
  27867. * Call this function to switch to webVR mode
  27868. * Will do nothing if webVR is not supported or if there is no webVR device
  27869. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27870. */
  27871. enableVR(): void;
  27872. /**
  27873. * Call this function to leave webVR mode
  27874. * Will do nothing if webVR is not supported or if there is no webVR device
  27875. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27876. */
  27877. disableVR(): void;
  27878. private _onVRFullScreenTriggered;
  27879. private _getVRDisplaysAsync;
  27880. /**
  27881. * Binds the frame buffer to the specified texture.
  27882. * @param texture The texture to render to or null for the default canvas
  27883. * @param faceIndex The face of the texture to render to in case of cube texture
  27884. * @param requiredWidth The width of the target to render to
  27885. * @param requiredHeight The height of the target to render to
  27886. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27887. * @param depthStencilTexture The depth stencil texture to use to render
  27888. * @param lodLevel defines le lod level to bind to the frame buffer
  27889. */
  27890. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27891. private bindUnboundFramebuffer;
  27892. /**
  27893. * Unbind the current render target texture from the webGL context
  27894. * @param texture defines the render target texture to unbind
  27895. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27896. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27897. */
  27898. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27899. /**
  27900. * Unbind a list of render target textures from the webGL context
  27901. * This is used only when drawBuffer extension or webGL2 are active
  27902. * @param textures defines the render target textures to unbind
  27903. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27904. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27905. */
  27906. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27907. /**
  27908. * Force the mipmap generation for the given render target texture
  27909. * @param texture defines the render target texture to use
  27910. */
  27911. generateMipMapsForCubemap(texture: InternalTexture): void;
  27912. /**
  27913. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27914. */
  27915. flushFramebuffer(): void;
  27916. /**
  27917. * Unbind the current render target and bind the default framebuffer
  27918. */
  27919. restoreDefaultFramebuffer(): void;
  27920. /**
  27921. * Create an uniform buffer
  27922. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27923. * @param elements defines the content of the uniform buffer
  27924. * @returns the webGL uniform buffer
  27925. */
  27926. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27927. /**
  27928. * Create a dynamic uniform buffer
  27929. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27930. * @param elements defines the content of the uniform buffer
  27931. * @returns the webGL uniform buffer
  27932. */
  27933. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27934. /**
  27935. * Update an existing uniform buffer
  27936. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27937. * @param uniformBuffer defines the target uniform buffer
  27938. * @param elements defines the content to update
  27939. * @param offset defines the offset in the uniform buffer where update should start
  27940. * @param count defines the size of the data to update
  27941. */
  27942. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27943. private _resetVertexBufferBinding;
  27944. /**
  27945. * Creates a vertex buffer
  27946. * @param data the data for the vertex buffer
  27947. * @returns the new WebGL static buffer
  27948. */
  27949. createVertexBuffer(data: DataArray): WebGLBuffer;
  27950. /**
  27951. * Creates a dynamic vertex buffer
  27952. * @param data the data for the dynamic vertex buffer
  27953. * @returns the new WebGL dynamic buffer
  27954. */
  27955. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27956. /**
  27957. * Update a dynamic index buffer
  27958. * @param indexBuffer defines the target index buffer
  27959. * @param indices defines the data to update
  27960. * @param offset defines the offset in the target index buffer where update should start
  27961. */
  27962. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27963. /**
  27964. * Updates a dynamic vertex buffer.
  27965. * @param vertexBuffer the vertex buffer to update
  27966. * @param data the data used to update the vertex buffer
  27967. * @param byteOffset the byte offset of the data
  27968. * @param byteLength the byte length of the data
  27969. */
  27970. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27971. private _resetIndexBufferBinding;
  27972. /**
  27973. * Creates a new index buffer
  27974. * @param indices defines the content of the index buffer
  27975. * @param updatable defines if the index buffer must be updatable
  27976. * @returns a new webGL buffer
  27977. */
  27978. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27979. /**
  27980. * Bind a webGL buffer to the webGL context
  27981. * @param buffer defines the buffer to bind
  27982. */
  27983. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27984. /**
  27985. * Bind an uniform buffer to the current webGL context
  27986. * @param buffer defines the buffer to bind
  27987. */
  27988. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27989. /**
  27990. * Bind a buffer to the current webGL context at a given location
  27991. * @param buffer defines the buffer to bind
  27992. * @param location defines the index where to bind the buffer
  27993. */
  27994. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27995. /**
  27996. * Bind a specific block at a given index in a specific shader program
  27997. * @param shaderProgram defines the shader program
  27998. * @param blockName defines the block name
  27999. * @param index defines the index where to bind the block
  28000. */
  28001. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28002. private bindIndexBuffer;
  28003. private bindBuffer;
  28004. /**
  28005. * update the bound buffer with the given data
  28006. * @param data defines the data to update
  28007. */
  28008. updateArrayBuffer(data: Float32Array): void;
  28009. private _vertexAttribPointer;
  28010. private _bindIndexBufferWithCache;
  28011. private _bindVertexBuffersAttributes;
  28012. /**
  28013. * Records a vertex array object
  28014. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28015. * @param vertexBuffers defines the list of vertex buffers to store
  28016. * @param indexBuffer defines the index buffer to store
  28017. * @param effect defines the effect to store
  28018. * @returns the new vertex array object
  28019. */
  28020. recordVertexArrayObject(vertexBuffers: {
  28021. [key: string]: VertexBuffer;
  28022. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28023. /**
  28024. * Bind a specific vertex array object
  28025. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28026. * @param vertexArrayObject defines the vertex array object to bind
  28027. * @param indexBuffer defines the index buffer to bind
  28028. */
  28029. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28030. /**
  28031. * Bind webGl buffers directly to the webGL context
  28032. * @param vertexBuffer defines the vertex buffer to bind
  28033. * @param indexBuffer defines the index buffer to bind
  28034. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28035. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28036. * @param effect defines the effect associated with the vertex buffer
  28037. */
  28038. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28039. private _unbindVertexArrayObject;
  28040. /**
  28041. * Bind a list of vertex buffers to the webGL context
  28042. * @param vertexBuffers defines the list of vertex buffers to bind
  28043. * @param indexBuffer defines the index buffer to bind
  28044. * @param effect defines the effect associated with the vertex buffers
  28045. */
  28046. bindBuffers(vertexBuffers: {
  28047. [key: string]: Nullable<VertexBuffer>;
  28048. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28049. /**
  28050. * Unbind all instance attributes
  28051. */
  28052. unbindInstanceAttributes(): void;
  28053. /**
  28054. * Release and free the memory of a vertex array object
  28055. * @param vao defines the vertex array object to delete
  28056. */
  28057. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28058. /** @hidden */
  28059. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28060. /**
  28061. * Creates a webGL buffer to use with instanciation
  28062. * @param capacity defines the size of the buffer
  28063. * @returns the webGL buffer
  28064. */
  28065. createInstancesBuffer(capacity: number): WebGLBuffer;
  28066. /**
  28067. * Delete a webGL buffer used with instanciation
  28068. * @param buffer defines the webGL buffer to delete
  28069. */
  28070. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28071. /**
  28072. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28073. * @param instancesBuffer defines the webGL buffer to update and bind
  28074. * @param data defines the data to store in the buffer
  28075. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28076. */
  28077. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28078. /**
  28079. * Apply all cached states (depth, culling, stencil and alpha)
  28080. */
  28081. applyStates(): void;
  28082. /**
  28083. * Send a draw order
  28084. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28085. * @param indexStart defines the starting index
  28086. * @param indexCount defines the number of index to draw
  28087. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28088. */
  28089. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28090. /**
  28091. * Draw a list of points
  28092. * @param verticesStart defines the index of first vertex to draw
  28093. * @param verticesCount defines the count of vertices to draw
  28094. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28095. */
  28096. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28097. /**
  28098. * Draw a list of unindexed primitives
  28099. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28100. * @param verticesStart defines the index of first vertex to draw
  28101. * @param verticesCount defines the count of vertices to draw
  28102. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28103. */
  28104. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28105. /**
  28106. * Draw a list of indexed primitives
  28107. * @param fillMode defines the primitive to use
  28108. * @param indexStart defines the starting index
  28109. * @param indexCount defines the number of index to draw
  28110. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28111. */
  28112. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28113. /**
  28114. * Draw a list of unindexed primitives
  28115. * @param fillMode defines the primitive to use
  28116. * @param verticesStart defines the index of first vertex to draw
  28117. * @param verticesCount defines the count of vertices to draw
  28118. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28119. */
  28120. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28121. private _drawMode;
  28122. /** @hidden */
  28123. _releaseEffect(effect: Effect): void;
  28124. /** @hidden */
  28125. _deleteProgram(program: WebGLProgram): void;
  28126. /**
  28127. * Create a new effect (used to store vertex/fragment shaders)
  28128. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28129. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28130. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28131. * @param samplers defines an array of string used to represent textures
  28132. * @param defines defines the string containing the defines to use to compile the shaders
  28133. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28134. * @param onCompiled defines a function to call when the effect creation is successful
  28135. * @param onError defines a function to call when the effect creation has failed
  28136. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28137. * @returns the new Effect
  28138. */
  28139. 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;
  28140. private _compileShader;
  28141. private _compileRawShader;
  28142. /**
  28143. * Directly creates a webGL program
  28144. * @param vertexCode defines the vertex shader code to use
  28145. * @param fragmentCode defines the fragment shader code to use
  28146. * @param context defines the webGL context to use (if not set, the current one will be used)
  28147. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28148. * @returns the new webGL program
  28149. */
  28150. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28151. /**
  28152. * Creates a webGL program
  28153. * @param vertexCode defines the vertex shader code to use
  28154. * @param fragmentCode defines the fragment shader code to use
  28155. * @param defines defines the string containing the defines to use to compile the shaders
  28156. * @param context defines the webGL context to use (if not set, the current one will be used)
  28157. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28158. * @returns the new webGL program
  28159. */
  28160. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28161. private _createShaderProgram;
  28162. private _finalizeProgram;
  28163. /** @hidden */
  28164. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28165. /** @hidden */
  28166. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28167. /**
  28168. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28169. * @param shaderProgram defines the webGL program to use
  28170. * @param uniformsNames defines the list of uniform names
  28171. * @returns an array of webGL uniform locations
  28172. */
  28173. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28174. /**
  28175. * Gets the lsit of active attributes for a given webGL program
  28176. * @param shaderProgram defines the webGL program to use
  28177. * @param attributesNames defines the list of attribute names to get
  28178. * @returns an array of indices indicating the offset of each attribute
  28179. */
  28180. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28181. /**
  28182. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28183. * @param effect defines the effect to activate
  28184. */
  28185. enableEffect(effect: Nullable<Effect>): void;
  28186. /**
  28187. * Set the value of an uniform to an array of int32
  28188. * @param uniform defines the webGL uniform location where to store the value
  28189. * @param array defines the array of int32 to store
  28190. */
  28191. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28192. /**
  28193. * Set the value of an uniform to an array of int32 (stored as vec2)
  28194. * @param uniform defines the webGL uniform location where to store the value
  28195. * @param array defines the array of int32 to store
  28196. */
  28197. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28198. /**
  28199. * Set the value of an uniform to an array of int32 (stored as vec3)
  28200. * @param uniform defines the webGL uniform location where to store the value
  28201. * @param array defines the array of int32 to store
  28202. */
  28203. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28204. /**
  28205. * Set the value of an uniform to an array of int32 (stored as vec4)
  28206. * @param uniform defines the webGL uniform location where to store the value
  28207. * @param array defines the array of int32 to store
  28208. */
  28209. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28210. /**
  28211. * Set the value of an uniform to an array of float32
  28212. * @param uniform defines the webGL uniform location where to store the value
  28213. * @param array defines the array of float32 to store
  28214. */
  28215. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28216. /**
  28217. * Set the value of an uniform to an array of float32 (stored as vec2)
  28218. * @param uniform defines the webGL uniform location where to store the value
  28219. * @param array defines the array of float32 to store
  28220. */
  28221. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28222. /**
  28223. * Set the value of an uniform to an array of float32 (stored as vec3)
  28224. * @param uniform defines the webGL uniform location where to store the value
  28225. * @param array defines the array of float32 to store
  28226. */
  28227. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28228. /**
  28229. * Set the value of an uniform to an array of float32 (stored as vec4)
  28230. * @param uniform defines the webGL uniform location where to store the value
  28231. * @param array defines the array of float32 to store
  28232. */
  28233. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28234. /**
  28235. * Set the value of an uniform to an array of number
  28236. * @param uniform defines the webGL uniform location where to store the value
  28237. * @param array defines the array of number to store
  28238. */
  28239. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28240. /**
  28241. * Set the value of an uniform to an array of number (stored as vec2)
  28242. * @param uniform defines the webGL uniform location where to store the value
  28243. * @param array defines the array of number to store
  28244. */
  28245. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28246. /**
  28247. * Set the value of an uniform to an array of number (stored as vec3)
  28248. * @param uniform defines the webGL uniform location where to store the value
  28249. * @param array defines the array of number to store
  28250. */
  28251. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28252. /**
  28253. * Set the value of an uniform to an array of number (stored as vec4)
  28254. * @param uniform defines the webGL uniform location where to store the value
  28255. * @param array defines the array of number to store
  28256. */
  28257. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28258. /**
  28259. * Set the value of an uniform to an array of float32 (stored as matrices)
  28260. * @param uniform defines the webGL uniform location where to store the value
  28261. * @param matrices defines the array of float32 to store
  28262. */
  28263. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28264. /**
  28265. * Set the value of an uniform to a matrix
  28266. * @param uniform defines the webGL uniform location where to store the value
  28267. * @param matrix defines the matrix to store
  28268. */
  28269. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28270. /**
  28271. * Set the value of an uniform to a matrix (3x3)
  28272. * @param uniform defines the webGL uniform location where to store the value
  28273. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28274. */
  28275. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28276. /**
  28277. * Set the value of an uniform to a matrix (2x2)
  28278. * @param uniform defines the webGL uniform location where to store the value
  28279. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28280. */
  28281. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28282. /**
  28283. * Set the value of an uniform to a number (int)
  28284. * @param uniform defines the webGL uniform location where to store the value
  28285. * @param value defines the int number to store
  28286. */
  28287. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28288. /**
  28289. * Set the value of an uniform to a number (float)
  28290. * @param uniform defines the webGL uniform location where to store the value
  28291. * @param value defines the float number to store
  28292. */
  28293. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28294. /**
  28295. * Set the value of an uniform to a vec2
  28296. * @param uniform defines the webGL uniform location where to store the value
  28297. * @param x defines the 1st component of the value
  28298. * @param y defines the 2nd component of the value
  28299. */
  28300. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28301. /**
  28302. * Set the value of an uniform to a vec3
  28303. * @param uniform defines the webGL uniform location where to store the value
  28304. * @param x defines the 1st component of the value
  28305. * @param y defines the 2nd component of the value
  28306. * @param z defines the 3rd component of the value
  28307. */
  28308. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28309. /**
  28310. * Set the value of an uniform to a boolean
  28311. * @param uniform defines the webGL uniform location where to store the value
  28312. * @param bool defines the boolean to store
  28313. */
  28314. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28315. /**
  28316. * Set the value of an uniform to a vec4
  28317. * @param uniform defines the webGL uniform location where to store the value
  28318. * @param x defines the 1st component of the value
  28319. * @param y defines the 2nd component of the value
  28320. * @param z defines the 3rd component of the value
  28321. * @param w defines the 4th component of the value
  28322. */
  28323. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28324. /**
  28325. * Set the value of an uniform to a Color3
  28326. * @param uniform defines the webGL uniform location where to store the value
  28327. * @param color3 defines the color to store
  28328. */
  28329. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28330. /**
  28331. * Set the value of an uniform to a Color3 and an alpha value
  28332. * @param uniform defines the webGL uniform location where to store the value
  28333. * @param color3 defines the color to store
  28334. * @param alpha defines the alpha component to store
  28335. */
  28336. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28337. /**
  28338. * Sets a Color4 on a uniform variable
  28339. * @param uniform defines the uniform location
  28340. * @param color4 defines the value to be set
  28341. */
  28342. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28343. /**
  28344. * Set various states to the webGL context
  28345. * @param culling defines backface culling state
  28346. * @param zOffset defines the value to apply to zOffset (0 by default)
  28347. * @param force defines if states must be applied even if cache is up to date
  28348. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28349. */
  28350. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28351. /**
  28352. * Set the z offset to apply to current rendering
  28353. * @param value defines the offset to apply
  28354. */
  28355. setZOffset(value: number): void;
  28356. /**
  28357. * Gets the current value of the zOffset
  28358. * @returns the current zOffset state
  28359. */
  28360. getZOffset(): number;
  28361. /**
  28362. * Enable or disable depth buffering
  28363. * @param enable defines the state to set
  28364. */
  28365. setDepthBuffer(enable: boolean): void;
  28366. /**
  28367. * Gets a boolean indicating if depth writing is enabled
  28368. * @returns the current depth writing state
  28369. */
  28370. getDepthWrite(): boolean;
  28371. /**
  28372. * Enable or disable depth writing
  28373. * @param enable defines the state to set
  28374. */
  28375. setDepthWrite(enable: boolean): void;
  28376. /**
  28377. * Enable or disable color writing
  28378. * @param enable defines the state to set
  28379. */
  28380. setColorWrite(enable: boolean): void;
  28381. /**
  28382. * Gets a boolean indicating if color writing is enabled
  28383. * @returns the current color writing state
  28384. */
  28385. getColorWrite(): boolean;
  28386. /**
  28387. * Sets alpha constants used by some alpha blending modes
  28388. * @param r defines the red component
  28389. * @param g defines the green component
  28390. * @param b defines the blue component
  28391. * @param a defines the alpha component
  28392. */
  28393. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28394. /**
  28395. * Sets the current alpha mode
  28396. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28397. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28398. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28399. */
  28400. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28401. /**
  28402. * Gets the current alpha mode
  28403. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28404. * @returns the current alpha mode
  28405. */
  28406. getAlphaMode(): number;
  28407. /**
  28408. * Clears the list of texture accessible through engine.
  28409. * This can help preventing texture load conflict due to name collision.
  28410. */
  28411. clearInternalTexturesCache(): void;
  28412. /**
  28413. * Force the entire cache to be cleared
  28414. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28415. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28416. */
  28417. wipeCaches(bruteForce?: boolean): void;
  28418. /**
  28419. * Set the compressed texture format to use, based on the formats you have, and the formats
  28420. * supported by the hardware / browser.
  28421. *
  28422. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28423. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28424. * to API arguments needed to compressed textures. This puts the burden on the container
  28425. * generator to house the arcane code for determining these for current & future formats.
  28426. *
  28427. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28428. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28429. *
  28430. * Note: The result of this call is not taken into account when a texture is base64.
  28431. *
  28432. * @param formatsAvailable defines the list of those format families you have created
  28433. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28434. *
  28435. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28436. * @returns The extension selected.
  28437. */
  28438. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28439. private _getSamplingParameters;
  28440. private _partialLoadImg;
  28441. private _cascadeLoadImgs;
  28442. /** @hidden */
  28443. _createTexture(): WebGLTexture;
  28444. /**
  28445. * Usually called from Texture.ts.
  28446. * Passed information to create a WebGLTexture
  28447. * @param urlArg defines a value which contains one of the following:
  28448. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28449. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28450. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28451. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28452. * @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)
  28453. * @param scene needed for loading to the correct scene
  28454. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28455. * @param onLoad optional callback to be called upon successful completion
  28456. * @param onError optional callback to be called upon failure
  28457. * @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
  28458. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28459. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28460. * @param forcedExtension defines the extension to use to pick the right loader
  28461. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28462. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28463. */
  28464. 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;
  28465. private _rescaleTexture;
  28466. /**
  28467. * Update a raw texture
  28468. * @param texture defines the texture to update
  28469. * @param data defines the data to store in the texture
  28470. * @param format defines the format of the data
  28471. * @param invertY defines if data must be stored with Y axis inverted
  28472. * @param compression defines the compression used (null by default)
  28473. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28474. */
  28475. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28476. /**
  28477. * Creates a raw texture
  28478. * @param data defines the data to store in the texture
  28479. * @param width defines the width of the texture
  28480. * @param height defines the height of the texture
  28481. * @param format defines the format of the data
  28482. * @param generateMipMaps defines if the engine should generate the mip levels
  28483. * @param invertY defines if data must be stored with Y axis inverted
  28484. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28485. * @param compression defines the compression used (null by default)
  28486. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28487. * @returns the raw texture inside an InternalTexture
  28488. */
  28489. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28490. private _unpackFlipYCached;
  28491. /**
  28492. * In case you are sharing the context with other applications, it might
  28493. * be interested to not cache the unpack flip y state to ensure a consistent
  28494. * value would be set.
  28495. */
  28496. enableUnpackFlipYCached: boolean;
  28497. /** @hidden */
  28498. _unpackFlipY(value: boolean): void;
  28499. /** @hidden */
  28500. _getUnpackAlignement(): number;
  28501. /**
  28502. * Creates a dynamic texture
  28503. * @param width defines the width of the texture
  28504. * @param height defines the height of the texture
  28505. * @param generateMipMaps defines if the engine should generate the mip levels
  28506. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28507. * @returns the dynamic texture inside an InternalTexture
  28508. */
  28509. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28510. /**
  28511. * Update the sampling mode of a given texture
  28512. * @param samplingMode defines the required sampling mode
  28513. * @param texture defines the texture to update
  28514. */
  28515. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28516. /**
  28517. * Update the content of a dynamic texture
  28518. * @param texture defines the texture to update
  28519. * @param canvas defines the canvas containing the source
  28520. * @param invertY defines if data must be stored with Y axis inverted
  28521. * @param premulAlpha defines if alpha is stored as premultiplied
  28522. * @param format defines the format of the data
  28523. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28524. */
  28525. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28526. /**
  28527. * Update a video texture
  28528. * @param texture defines the texture to update
  28529. * @param video defines the video element to use
  28530. * @param invertY defines if data must be stored with Y axis inverted
  28531. */
  28532. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28533. /**
  28534. * Updates a depth texture Comparison Mode and Function.
  28535. * If the comparison Function is equal to 0, the mode will be set to none.
  28536. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28537. * @param texture The texture to set the comparison function for
  28538. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28539. */
  28540. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28541. private _setupDepthStencilTexture;
  28542. /**
  28543. * Creates a depth stencil texture.
  28544. * This is only available in WebGL 2 or with the depth texture extension available.
  28545. * @param size The size of face edge in the texture.
  28546. * @param options The options defining the texture.
  28547. * @returns The texture
  28548. */
  28549. createDepthStencilTexture(size: number | {
  28550. width: number;
  28551. height: number;
  28552. }, options: DepthTextureCreationOptions): InternalTexture;
  28553. /**
  28554. * Creates a depth stencil texture.
  28555. * This is only available in WebGL 2 or with the depth texture extension available.
  28556. * @param size The size of face edge in the texture.
  28557. * @param options The options defining the texture.
  28558. * @returns The texture
  28559. */
  28560. private _createDepthStencilTexture;
  28561. /**
  28562. * Creates a depth stencil cube texture.
  28563. * This is only available in WebGL 2.
  28564. * @param size The size of face edge in the cube texture.
  28565. * @param options The options defining the cube texture.
  28566. * @returns The cube texture
  28567. */
  28568. private _createDepthStencilCubeTexture;
  28569. /**
  28570. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28571. * @param renderTarget The render target to set the frame buffer for
  28572. */
  28573. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28574. /**
  28575. * Creates a new render target texture
  28576. * @param size defines the size of the texture
  28577. * @param options defines the options used to create the texture
  28578. * @returns a new render target texture stored in an InternalTexture
  28579. */
  28580. createRenderTargetTexture(size: number | {
  28581. width: number;
  28582. height: number;
  28583. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28584. /**
  28585. * Create a multi render target texture
  28586. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28587. * @param size defines the size of the texture
  28588. * @param options defines the creation options
  28589. * @returns the cube texture as an InternalTexture
  28590. */
  28591. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28592. private _setupFramebufferDepthAttachments;
  28593. /**
  28594. * Updates the sample count of a render target texture
  28595. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28596. * @param texture defines the texture to update
  28597. * @param samples defines the sample count to set
  28598. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28599. */
  28600. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28601. /**
  28602. * Update the sample count for a given multiple render target texture
  28603. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28604. * @param textures defines the textures to update
  28605. * @param samples defines the sample count to set
  28606. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28607. */
  28608. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28609. /** @hidden */
  28610. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28611. /** @hidden */
  28612. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28613. /** @hidden */
  28614. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28615. /** @hidden */
  28616. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28617. /**
  28618. * Creates a new render target cube texture
  28619. * @param size defines the size of the texture
  28620. * @param options defines the options used to create the texture
  28621. * @returns a new render target cube texture stored in an InternalTexture
  28622. */
  28623. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28624. /**
  28625. * Creates a cube texture
  28626. * @param rootUrl defines the url where the files to load is located
  28627. * @param scene defines the current scene
  28628. * @param files defines the list of files to load (1 per face)
  28629. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28630. * @param onLoad defines an optional callback raised when the texture is loaded
  28631. * @param onError defines an optional callback raised if there is an issue to load the texture
  28632. * @param format defines the format of the data
  28633. * @param forcedExtension defines the extension to use to pick the right loader
  28634. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28635. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28636. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28637. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28638. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28639. * @returns the cube texture as an InternalTexture
  28640. */
  28641. 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;
  28642. /**
  28643. * @hidden
  28644. */
  28645. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28646. /**
  28647. * Update a raw cube texture
  28648. * @param texture defines the texture to udpdate
  28649. * @param data defines the data to store
  28650. * @param format defines the data format
  28651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28652. * @param invertY defines if data must be stored with Y axis inverted
  28653. * @param compression defines the compression used (null by default)
  28654. * @param level defines which level of the texture to update
  28655. */
  28656. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28657. /**
  28658. * Creates a new raw cube texture
  28659. * @param data defines the array of data to use to create each face
  28660. * @param size defines the size of the textures
  28661. * @param format defines the format of the data
  28662. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28663. * @param generateMipMaps defines if the engine should generate the mip levels
  28664. * @param invertY defines if data must be stored with Y axis inverted
  28665. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28666. * @param compression defines the compression used (null by default)
  28667. * @returns the cube texture as an InternalTexture
  28668. */
  28669. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28670. /**
  28671. * Creates a new raw cube texture from a specified url
  28672. * @param url defines the url where the data is located
  28673. * @param scene defines the current scene
  28674. * @param size defines the size of the textures
  28675. * @param format defines the format of the data
  28676. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28677. * @param noMipmap defines if the engine should avoid generating the mip levels
  28678. * @param callback defines a callback used to extract texture data from loaded data
  28679. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28680. * @param onLoad defines a callback called when texture is loaded
  28681. * @param onError defines a callback called if there is an error
  28682. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28683. * @param invertY defines if data must be stored with Y axis inverted
  28684. * @returns the cube texture as an InternalTexture
  28685. */
  28686. 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;
  28687. /**
  28688. * Update a raw 3D texture
  28689. * @param texture defines the texture to update
  28690. * @param data defines the data to store
  28691. * @param format defines the data format
  28692. * @param invertY defines if data must be stored with Y axis inverted
  28693. * @param compression defines the used compression (can be null)
  28694. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28695. */
  28696. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28697. /**
  28698. * Creates a new raw 3D texture
  28699. * @param data defines the data used to create the texture
  28700. * @param width defines the width of the texture
  28701. * @param height defines the height of the texture
  28702. * @param depth defines the depth of the texture
  28703. * @param format defines the format of the texture
  28704. * @param generateMipMaps defines if the engine must generate mip levels
  28705. * @param invertY defines if data must be stored with Y axis inverted
  28706. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28707. * @param compression defines the compressed used (can be null)
  28708. * @param textureType defines the compressed used (can be null)
  28709. * @returns a new raw 3D texture (stored in an InternalTexture)
  28710. */
  28711. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28712. private _prepareWebGLTextureContinuation;
  28713. private _prepareWebGLTexture;
  28714. private _convertRGBtoRGBATextureData;
  28715. /** @hidden */
  28716. _releaseFramebufferObjects(texture: InternalTexture): void;
  28717. /** @hidden */
  28718. _releaseTexture(texture: InternalTexture): void;
  28719. private setProgram;
  28720. private _boundUniforms;
  28721. /**
  28722. * Binds an effect to the webGL context
  28723. * @param effect defines the effect to bind
  28724. */
  28725. bindSamplers(effect: Effect): void;
  28726. private _moveBoundTextureOnTop;
  28727. private _getCorrectTextureChannel;
  28728. private _linkTrackers;
  28729. private _removeDesignatedSlot;
  28730. private _activateCurrentTexture;
  28731. /** @hidden */
  28732. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28733. /** @hidden */
  28734. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28735. /**
  28736. * Sets a texture to the webGL context from a postprocess
  28737. * @param channel defines the channel to use
  28738. * @param postProcess defines the source postprocess
  28739. */
  28740. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28741. /**
  28742. * Binds the output of the passed in post process to the texture channel specified
  28743. * @param channel The channel the texture should be bound to
  28744. * @param postProcess The post process which's output should be bound
  28745. */
  28746. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28747. /**
  28748. * Unbind all textures from the webGL context
  28749. */
  28750. unbindAllTextures(): void;
  28751. /**
  28752. * Sets a texture to the according uniform.
  28753. * @param channel The texture channel
  28754. * @param uniform The uniform to set
  28755. * @param texture The texture to apply
  28756. */
  28757. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28758. /**
  28759. * Sets a depth stencil texture from a render target to the according uniform.
  28760. * @param channel The texture channel
  28761. * @param uniform The uniform to set
  28762. * @param texture The render target texture containing the depth stencil texture to apply
  28763. */
  28764. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28765. private _bindSamplerUniformToChannel;
  28766. private _getTextureWrapMode;
  28767. private _setTexture;
  28768. /**
  28769. * Sets an array of texture to the webGL context
  28770. * @param channel defines the channel where the texture array must be set
  28771. * @param uniform defines the associated uniform location
  28772. * @param textures defines the array of textures to bind
  28773. */
  28774. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28775. /** @hidden */
  28776. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28777. private _setTextureParameterFloat;
  28778. private _setTextureParameterInteger;
  28779. /**
  28780. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28781. * @param x defines the x coordinate of the rectangle where pixels must be read
  28782. * @param y defines the y coordinate of the rectangle where pixels must be read
  28783. * @param width defines the width of the rectangle where pixels must be read
  28784. * @param height defines the height of the rectangle where pixels must be read
  28785. * @returns a Uint8Array containing RGBA colors
  28786. */
  28787. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28788. /**
  28789. * Add an externaly attached data from its key.
  28790. * This method call will fail and return false, if such key already exists.
  28791. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28792. * @param key the unique key that identifies the data
  28793. * @param data the data object to associate to the key for this Engine instance
  28794. * @return true if no such key were already present and the data was added successfully, false otherwise
  28795. */
  28796. addExternalData<T>(key: string, data: T): boolean;
  28797. /**
  28798. * Get an externaly attached data from its key
  28799. * @param key the unique key that identifies the data
  28800. * @return the associated data, if present (can be null), or undefined if not present
  28801. */
  28802. getExternalData<T>(key: string): T;
  28803. /**
  28804. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28805. * @param key the unique key that identifies the data
  28806. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28807. * @return the associated data, can be null if the factory returned null.
  28808. */
  28809. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28810. /**
  28811. * Remove an externaly attached data from the Engine instance
  28812. * @param key the unique key that identifies the data
  28813. * @return true if the data was successfully removed, false if it doesn't exist
  28814. */
  28815. removeExternalData(key: string): boolean;
  28816. /**
  28817. * Unbind all vertex attributes from the webGL context
  28818. */
  28819. unbindAllAttributes(): void;
  28820. /**
  28821. * 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
  28822. */
  28823. releaseEffects(): void;
  28824. /**
  28825. * Dispose and release all associated resources
  28826. */
  28827. dispose(): void;
  28828. /**
  28829. * Display the loading screen
  28830. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28831. */
  28832. displayLoadingUI(): void;
  28833. /**
  28834. * Hide the loading screen
  28835. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28836. */
  28837. hideLoadingUI(): void;
  28838. /**
  28839. * Gets the current loading screen object
  28840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28841. */
  28842. /**
  28843. * Sets the current loading screen object
  28844. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28845. */
  28846. loadingScreen: ILoadingScreen;
  28847. /**
  28848. * Sets the current loading screen text
  28849. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28850. */
  28851. loadingUIText: string;
  28852. /**
  28853. * Sets the current loading screen background color
  28854. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28855. */
  28856. loadingUIBackgroundColor: string;
  28857. /**
  28858. * Attach a new callback raised when context lost event is fired
  28859. * @param callback defines the callback to call
  28860. */
  28861. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28862. /**
  28863. * Attach a new callback raised when context restored event is fired
  28864. * @param callback defines the callback to call
  28865. */
  28866. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28867. /**
  28868. * Gets the source code of the vertex shader associated with a specific webGL program
  28869. * @param program defines the program to use
  28870. * @returns a string containing the source code of the vertex shader associated with the program
  28871. */
  28872. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28873. /**
  28874. * Gets the source code of the fragment shader associated with a specific webGL program
  28875. * @param program defines the program to use
  28876. * @returns a string containing the source code of the fragment shader associated with the program
  28877. */
  28878. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28879. /**
  28880. * Get the current error code of the webGL context
  28881. * @returns the error code
  28882. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28883. */
  28884. getError(): number;
  28885. /**
  28886. * Gets the current framerate
  28887. * @returns a number representing the framerate
  28888. */
  28889. getFps(): number;
  28890. /**
  28891. * Gets the time spent between current and previous frame
  28892. * @returns a number representing the delta time in ms
  28893. */
  28894. getDeltaTime(): number;
  28895. private _measureFps;
  28896. /** @hidden */
  28897. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28898. private _canRenderToFloatFramebuffer;
  28899. private _canRenderToHalfFloatFramebuffer;
  28900. private _canRenderToFramebuffer;
  28901. /** @hidden */
  28902. _getWebGLTextureType(type: number): number;
  28903. private _getInternalFormat;
  28904. /** @hidden */
  28905. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28906. /** @hidden */
  28907. _getRGBAMultiSampleBufferFormat(type: number): number;
  28908. /** @hidden */
  28909. _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;
  28910. /** @hidden */
  28911. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28912. private _partialLoadFile;
  28913. private _cascadeLoadFiles;
  28914. /**
  28915. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28916. * @returns true if the engine can be created
  28917. * @ignorenaming
  28918. */
  28919. static isSupported(): boolean;
  28920. }
  28921. }
  28922. declare module "babylonjs/Materials/effect" {
  28923. import { Observable } from "babylonjs/Misc/observable";
  28924. import { Nullable } from "babylonjs/types";
  28925. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28926. import { Engine } from "babylonjs/Engines/engine";
  28927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28930. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28932. /**
  28933. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28934. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28935. */
  28936. export class EffectFallbacks {
  28937. private _defines;
  28938. private _currentRank;
  28939. private _maxRank;
  28940. private _mesh;
  28941. /**
  28942. * Removes the fallback from the bound mesh.
  28943. */
  28944. unBindMesh(): void;
  28945. /**
  28946. * Adds a fallback on the specified property.
  28947. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28948. * @param define The name of the define in the shader
  28949. */
  28950. addFallback(rank: number, define: string): void;
  28951. /**
  28952. * Sets the mesh to use CPU skinning when needing to fallback.
  28953. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28954. * @param mesh The mesh to use the fallbacks.
  28955. */
  28956. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28957. /**
  28958. * Checks to see if more fallbacks are still availible.
  28959. */
  28960. readonly isMoreFallbacks: boolean;
  28961. /**
  28962. * Removes the defines that shoould be removed when falling back.
  28963. * @param currentDefines defines the current define statements for the shader.
  28964. * @param effect defines the current effect we try to compile
  28965. * @returns The resulting defines with defines of the current rank removed.
  28966. */
  28967. reduce(currentDefines: string, effect: Effect): string;
  28968. }
  28969. /**
  28970. * Options to be used when creating an effect.
  28971. */
  28972. export class EffectCreationOptions {
  28973. /**
  28974. * Atrributes that will be used in the shader.
  28975. */
  28976. attributes: string[];
  28977. /**
  28978. * Uniform varible names that will be set in the shader.
  28979. */
  28980. uniformsNames: string[];
  28981. /**
  28982. * Uniform buffer varible names that will be set in the shader.
  28983. */
  28984. uniformBuffersNames: string[];
  28985. /**
  28986. * Sampler texture variable names that will be set in the shader.
  28987. */
  28988. samplers: string[];
  28989. /**
  28990. * Define statements that will be set in the shader.
  28991. */
  28992. defines: any;
  28993. /**
  28994. * Possible fallbacks for this effect to improve performance when needed.
  28995. */
  28996. fallbacks: Nullable<EffectFallbacks>;
  28997. /**
  28998. * Callback that will be called when the shader is compiled.
  28999. */
  29000. onCompiled: Nullable<(effect: Effect) => void>;
  29001. /**
  29002. * Callback that will be called if an error occurs during shader compilation.
  29003. */
  29004. onError: Nullable<(effect: Effect, errors: string) => void>;
  29005. /**
  29006. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29007. */
  29008. indexParameters: any;
  29009. /**
  29010. * Max number of lights that can be used in the shader.
  29011. */
  29012. maxSimultaneousLights: number;
  29013. /**
  29014. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29015. */
  29016. transformFeedbackVaryings: Nullable<string[]>;
  29017. }
  29018. /**
  29019. * Effect containing vertex and fragment shader that can be executed on an object.
  29020. */
  29021. export class Effect {
  29022. /**
  29023. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29024. */
  29025. static ShadersRepository: string;
  29026. /**
  29027. * Name of the effect.
  29028. */
  29029. name: any;
  29030. /**
  29031. * String container all the define statements that should be set on the shader.
  29032. */
  29033. defines: string;
  29034. /**
  29035. * Callback that will be called when the shader is compiled.
  29036. */
  29037. onCompiled: Nullable<(effect: Effect) => void>;
  29038. /**
  29039. * Callback that will be called if an error occurs during shader compilation.
  29040. */
  29041. onError: Nullable<(effect: Effect, errors: string) => void>;
  29042. /**
  29043. * Callback that will be called when effect is bound.
  29044. */
  29045. onBind: Nullable<(effect: Effect) => void>;
  29046. /**
  29047. * Unique ID of the effect.
  29048. */
  29049. uniqueId: number;
  29050. /**
  29051. * Observable that will be called when the shader is compiled.
  29052. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29053. */
  29054. onCompileObservable: Observable<Effect>;
  29055. /**
  29056. * Observable that will be called if an error occurs during shader compilation.
  29057. */
  29058. onErrorObservable: Observable<Effect>;
  29059. /** @hidden */
  29060. _onBindObservable: Nullable<Observable<Effect>>;
  29061. /**
  29062. * Observable that will be called when effect is bound.
  29063. */
  29064. readonly onBindObservable: Observable<Effect>;
  29065. /** @hidden */
  29066. _bonesComputationForcedToCPU: boolean;
  29067. private static _uniqueIdSeed;
  29068. private _engine;
  29069. private _uniformBuffersNames;
  29070. private _uniformsNames;
  29071. private _samplers;
  29072. private _isReady;
  29073. private _compilationError;
  29074. private _attributesNames;
  29075. private _attributes;
  29076. private _uniforms;
  29077. /**
  29078. * Key for the effect.
  29079. * @hidden
  29080. */
  29081. _key: string;
  29082. private _indexParameters;
  29083. private _fallbacks;
  29084. private _vertexSourceCode;
  29085. private _fragmentSourceCode;
  29086. private _vertexSourceCodeOverride;
  29087. private _fragmentSourceCodeOverride;
  29088. private _transformFeedbackVaryings;
  29089. /**
  29090. * Compiled shader to webGL program.
  29091. * @hidden
  29092. */
  29093. _program: WebGLProgram;
  29094. private _valueCache;
  29095. private static _baseCache;
  29096. /**
  29097. * Instantiates an effect.
  29098. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29099. * @param baseName Name of the effect.
  29100. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29101. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29102. * @param samplers List of sampler variables that will be passed to the shader.
  29103. * @param engine Engine to be used to render the effect
  29104. * @param defines Define statements to be added to the shader.
  29105. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29106. * @param onCompiled Callback that will be called when the shader is compiled.
  29107. * @param onError Callback that will be called if an error occurs during shader compilation.
  29108. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29109. */
  29110. 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);
  29111. /**
  29112. * Unique key for this effect
  29113. */
  29114. readonly key: string;
  29115. /**
  29116. * If the effect has been compiled and prepared.
  29117. * @returns if the effect is compiled and prepared.
  29118. */
  29119. isReady(): boolean;
  29120. /**
  29121. * The engine the effect was initialized with.
  29122. * @returns the engine.
  29123. */
  29124. getEngine(): Engine;
  29125. /**
  29126. * The compiled webGL program for the effect
  29127. * @returns the webGL program.
  29128. */
  29129. getProgram(): WebGLProgram;
  29130. /**
  29131. * The set of names of attribute variables for the shader.
  29132. * @returns An array of attribute names.
  29133. */
  29134. getAttributesNames(): string[];
  29135. /**
  29136. * Returns the attribute at the given index.
  29137. * @param index The index of the attribute.
  29138. * @returns The location of the attribute.
  29139. */
  29140. getAttributeLocation(index: number): number;
  29141. /**
  29142. * Returns the attribute based on the name of the variable.
  29143. * @param name of the attribute to look up.
  29144. * @returns the attribute location.
  29145. */
  29146. getAttributeLocationByName(name: string): number;
  29147. /**
  29148. * The number of attributes.
  29149. * @returns the numnber of attributes.
  29150. */
  29151. getAttributesCount(): number;
  29152. /**
  29153. * Gets the index of a uniform variable.
  29154. * @param uniformName of the uniform to look up.
  29155. * @returns the index.
  29156. */
  29157. getUniformIndex(uniformName: string): number;
  29158. /**
  29159. * Returns the attribute based on the name of the variable.
  29160. * @param uniformName of the uniform to look up.
  29161. * @returns the location of the uniform.
  29162. */
  29163. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29164. /**
  29165. * Returns an array of sampler variable names
  29166. * @returns The array of sampler variable neames.
  29167. */
  29168. getSamplers(): string[];
  29169. /**
  29170. * The error from the last compilation.
  29171. * @returns the error string.
  29172. */
  29173. getCompilationError(): string;
  29174. /**
  29175. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29176. * @param func The callback to be used.
  29177. */
  29178. executeWhenCompiled(func: (effect: Effect) => void): void;
  29179. private _checkIsReady;
  29180. /** @hidden */
  29181. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29182. /** @hidden */
  29183. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29184. /** @hidden */
  29185. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29186. private _processShaderConversion;
  29187. private _processIncludes;
  29188. private _processPrecision;
  29189. /**
  29190. * Recompiles the webGL program
  29191. * @param vertexSourceCode The source code for the vertex shader.
  29192. * @param fragmentSourceCode The source code for the fragment shader.
  29193. * @param onCompiled Callback called when completed.
  29194. * @param onError Callback called on error.
  29195. * @hidden
  29196. */
  29197. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29198. /**
  29199. * Gets the uniform locations of the the specified variable names
  29200. * @param names THe names of the variables to lookup.
  29201. * @returns Array of locations in the same order as variable names.
  29202. */
  29203. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29204. /**
  29205. * Prepares the effect
  29206. * @hidden
  29207. */
  29208. _prepareEffect(): void;
  29209. /**
  29210. * Checks if the effect is supported. (Must be called after compilation)
  29211. */
  29212. readonly isSupported: boolean;
  29213. /**
  29214. * Binds a texture to the engine to be used as output of the shader.
  29215. * @param channel Name of the output variable.
  29216. * @param texture Texture to bind.
  29217. * @hidden
  29218. */
  29219. _bindTexture(channel: string, texture: InternalTexture): void;
  29220. /**
  29221. * Sets a texture on the engine to be used in the shader.
  29222. * @param channel Name of the sampler variable.
  29223. * @param texture Texture to set.
  29224. */
  29225. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29226. /**
  29227. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29228. * @param channel Name of the sampler variable.
  29229. * @param texture Texture to set.
  29230. */
  29231. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29232. /**
  29233. * Sets an array of textures on the engine to be used in the shader.
  29234. * @param channel Name of the variable.
  29235. * @param textures Textures to set.
  29236. */
  29237. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29238. /**
  29239. * 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)
  29240. * @param channel Name of the sampler variable.
  29241. * @param postProcess Post process to get the input texture from.
  29242. */
  29243. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29244. /**
  29245. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29246. * 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)
  29247. * @param channel Name of the sampler variable.
  29248. * @param postProcess Post process to get the output texture from.
  29249. */
  29250. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29251. /** @hidden */
  29252. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29253. /** @hidden */
  29254. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29255. /** @hidden */
  29256. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29257. /** @hidden */
  29258. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29259. /**
  29260. * Binds a buffer to a uniform.
  29261. * @param buffer Buffer to bind.
  29262. * @param name Name of the uniform variable to bind to.
  29263. */
  29264. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29265. /**
  29266. * Binds block to a uniform.
  29267. * @param blockName Name of the block to bind.
  29268. * @param index Index to bind.
  29269. */
  29270. bindUniformBlock(blockName: string, index: number): void;
  29271. /**
  29272. * Sets an interger value on a uniform variable.
  29273. * @param uniformName Name of the variable.
  29274. * @param value Value to be set.
  29275. * @returns this effect.
  29276. */
  29277. setInt(uniformName: string, value: number): Effect;
  29278. /**
  29279. * Sets an int array on a uniform variable.
  29280. * @param uniformName Name of the variable.
  29281. * @param array array to be set.
  29282. * @returns this effect.
  29283. */
  29284. setIntArray(uniformName: string, array: Int32Array): Effect;
  29285. /**
  29286. * 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)
  29287. * @param uniformName Name of the variable.
  29288. * @param array array to be set.
  29289. * @returns this effect.
  29290. */
  29291. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29292. /**
  29293. * 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)
  29294. * @param uniformName Name of the variable.
  29295. * @param array array to be set.
  29296. * @returns this effect.
  29297. */
  29298. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29299. /**
  29300. * 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)
  29301. * @param uniformName Name of the variable.
  29302. * @param array array to be set.
  29303. * @returns this effect.
  29304. */
  29305. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29306. /**
  29307. * Sets an float array on a uniform variable.
  29308. * @param uniformName Name of the variable.
  29309. * @param array array to be set.
  29310. * @returns this effect.
  29311. */
  29312. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29313. /**
  29314. * 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)
  29315. * @param uniformName Name of the variable.
  29316. * @param array array to be set.
  29317. * @returns this effect.
  29318. */
  29319. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29320. /**
  29321. * 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)
  29322. * @param uniformName Name of the variable.
  29323. * @param array array to be set.
  29324. * @returns this effect.
  29325. */
  29326. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29327. /**
  29328. * 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)
  29329. * @param uniformName Name of the variable.
  29330. * @param array array to be set.
  29331. * @returns this effect.
  29332. */
  29333. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29334. /**
  29335. * Sets an array on a uniform variable.
  29336. * @param uniformName Name of the variable.
  29337. * @param array array to be set.
  29338. * @returns this effect.
  29339. */
  29340. setArray(uniformName: string, array: number[]): Effect;
  29341. /**
  29342. * 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)
  29343. * @param uniformName Name of the variable.
  29344. * @param array array to be set.
  29345. * @returns this effect.
  29346. */
  29347. setArray2(uniformName: string, array: number[]): Effect;
  29348. /**
  29349. * 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)
  29350. * @param uniformName Name of the variable.
  29351. * @param array array to be set.
  29352. * @returns this effect.
  29353. */
  29354. setArray3(uniformName: string, array: number[]): Effect;
  29355. /**
  29356. * 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)
  29357. * @param uniformName Name of the variable.
  29358. * @param array array to be set.
  29359. * @returns this effect.
  29360. */
  29361. setArray4(uniformName: string, array: number[]): Effect;
  29362. /**
  29363. * Sets matrices on a uniform variable.
  29364. * @param uniformName Name of the variable.
  29365. * @param matrices matrices to be set.
  29366. * @returns this effect.
  29367. */
  29368. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29369. /**
  29370. * Sets matrix on a uniform variable.
  29371. * @param uniformName Name of the variable.
  29372. * @param matrix matrix to be set.
  29373. * @returns this effect.
  29374. */
  29375. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29376. /**
  29377. * 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)
  29378. * @param uniformName Name of the variable.
  29379. * @param matrix matrix to be set.
  29380. * @returns this effect.
  29381. */
  29382. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29383. /**
  29384. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29385. * @param uniformName Name of the variable.
  29386. * @param matrix matrix to be set.
  29387. * @returns this effect.
  29388. */
  29389. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29390. /**
  29391. * Sets a float on a uniform variable.
  29392. * @param uniformName Name of the variable.
  29393. * @param value value to be set.
  29394. * @returns this effect.
  29395. */
  29396. setFloat(uniformName: string, value: number): Effect;
  29397. /**
  29398. * Sets a boolean on a uniform variable.
  29399. * @param uniformName Name of the variable.
  29400. * @param bool value to be set.
  29401. * @returns this effect.
  29402. */
  29403. setBool(uniformName: string, bool: boolean): Effect;
  29404. /**
  29405. * Sets a Vector2 on a uniform variable.
  29406. * @param uniformName Name of the variable.
  29407. * @param vector2 vector2 to be set.
  29408. * @returns this effect.
  29409. */
  29410. setVector2(uniformName: string, vector2: Vector2): Effect;
  29411. /**
  29412. * Sets a float2 on a uniform variable.
  29413. * @param uniformName Name of the variable.
  29414. * @param x First float in float2.
  29415. * @param y Second float in float2.
  29416. * @returns this effect.
  29417. */
  29418. setFloat2(uniformName: string, x: number, y: number): Effect;
  29419. /**
  29420. * Sets a Vector3 on a uniform variable.
  29421. * @param uniformName Name of the variable.
  29422. * @param vector3 Value to be set.
  29423. * @returns this effect.
  29424. */
  29425. setVector3(uniformName: string, vector3: Vector3): Effect;
  29426. /**
  29427. * Sets a float3 on a uniform variable.
  29428. * @param uniformName Name of the variable.
  29429. * @param x First float in float3.
  29430. * @param y Second float in float3.
  29431. * @param z Third float in float3.
  29432. * @returns this effect.
  29433. */
  29434. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29435. /**
  29436. * Sets a Vector4 on a uniform variable.
  29437. * @param uniformName Name of the variable.
  29438. * @param vector4 Value to be set.
  29439. * @returns this effect.
  29440. */
  29441. setVector4(uniformName: string, vector4: Vector4): Effect;
  29442. /**
  29443. * Sets a float4 on a uniform variable.
  29444. * @param uniformName Name of the variable.
  29445. * @param x First float in float4.
  29446. * @param y Second float in float4.
  29447. * @param z Third float in float4.
  29448. * @param w Fourth float in float4.
  29449. * @returns this effect.
  29450. */
  29451. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29452. /**
  29453. * Sets a Color3 on a uniform variable.
  29454. * @param uniformName Name of the variable.
  29455. * @param color3 Value to be set.
  29456. * @returns this effect.
  29457. */
  29458. setColor3(uniformName: string, color3: Color3): Effect;
  29459. /**
  29460. * Sets a Color4 on a uniform variable.
  29461. * @param uniformName Name of the variable.
  29462. * @param color3 Value to be set.
  29463. * @param alpha Alpha value to be set.
  29464. * @returns this effect.
  29465. */
  29466. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29467. /**
  29468. * Sets a Color4 on a uniform variable
  29469. * @param uniformName defines the name of the variable
  29470. * @param color4 defines the value to be set
  29471. * @returns this effect.
  29472. */
  29473. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29474. /**
  29475. * This function will add a new shader to the shader store
  29476. * @param name the name of the shader
  29477. * @param pixelShader optional pixel shader content
  29478. * @param vertexShader optional vertex shader content
  29479. */
  29480. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29481. /**
  29482. * Store of each shader (The can be looked up using effect.key)
  29483. */
  29484. static ShadersStore: {
  29485. [key: string]: string;
  29486. };
  29487. /**
  29488. * Store of each included file for a shader (The can be looked up using effect.key)
  29489. */
  29490. static IncludesShadersStore: {
  29491. [key: string]: string;
  29492. };
  29493. /**
  29494. * Resets the cache of effects.
  29495. */
  29496. static ResetCache(): void;
  29497. }
  29498. }
  29499. declare module "babylonjs/Materials/colorCurves" {
  29500. import { Effect } from "babylonjs/Materials/effect";
  29501. /**
  29502. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29503. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29504. * 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;
  29505. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29506. */
  29507. export class ColorCurves {
  29508. private _dirty;
  29509. private _tempColor;
  29510. private _globalCurve;
  29511. private _highlightsCurve;
  29512. private _midtonesCurve;
  29513. private _shadowsCurve;
  29514. private _positiveCurve;
  29515. private _negativeCurve;
  29516. private _globalHue;
  29517. private _globalDensity;
  29518. private _globalSaturation;
  29519. private _globalExposure;
  29520. /**
  29521. * Gets the global Hue value.
  29522. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29523. */
  29524. /**
  29525. * Sets the global Hue value.
  29526. * 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).
  29527. */
  29528. globalHue: number;
  29529. /**
  29530. * Gets the global Density value.
  29531. * 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.
  29532. * Values less than zero provide a filter of opposite hue.
  29533. */
  29534. /**
  29535. * Sets the global Density value.
  29536. * 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.
  29537. * Values less than zero provide a filter of opposite hue.
  29538. */
  29539. globalDensity: number;
  29540. /**
  29541. * Gets the global Saturation value.
  29542. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29543. */
  29544. /**
  29545. * Sets the global Saturation value.
  29546. * 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.
  29547. */
  29548. globalSaturation: number;
  29549. /**
  29550. * Gets the global Exposure value.
  29551. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29552. */
  29553. /**
  29554. * Sets the global Exposure value.
  29555. * 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.
  29556. */
  29557. globalExposure: number;
  29558. private _highlightsHue;
  29559. private _highlightsDensity;
  29560. private _highlightsSaturation;
  29561. private _highlightsExposure;
  29562. /**
  29563. * Gets the highlights Hue value.
  29564. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29565. */
  29566. /**
  29567. * Sets the highlights Hue value.
  29568. * 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).
  29569. */
  29570. highlightsHue: number;
  29571. /**
  29572. * Gets the highlights Density value.
  29573. * 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.
  29574. * Values less than zero provide a filter of opposite hue.
  29575. */
  29576. /**
  29577. * Sets the highlights Density value.
  29578. * 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.
  29579. * Values less than zero provide a filter of opposite hue.
  29580. */
  29581. highlightsDensity: number;
  29582. /**
  29583. * Gets the highlights Saturation value.
  29584. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29585. */
  29586. /**
  29587. * Sets the highlights Saturation value.
  29588. * 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.
  29589. */
  29590. highlightsSaturation: number;
  29591. /**
  29592. * Gets the highlights Exposure value.
  29593. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29594. */
  29595. /**
  29596. * Sets the highlights Exposure value.
  29597. * 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.
  29598. */
  29599. highlightsExposure: number;
  29600. private _midtonesHue;
  29601. private _midtonesDensity;
  29602. private _midtonesSaturation;
  29603. private _midtonesExposure;
  29604. /**
  29605. * Gets the midtones Hue value.
  29606. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29607. */
  29608. /**
  29609. * Sets the midtones Hue value.
  29610. * 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).
  29611. */
  29612. midtonesHue: number;
  29613. /**
  29614. * Gets the midtones Density value.
  29615. * 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.
  29616. * Values less than zero provide a filter of opposite hue.
  29617. */
  29618. /**
  29619. * Sets the midtones Density value.
  29620. * 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.
  29621. * Values less than zero provide a filter of opposite hue.
  29622. */
  29623. midtonesDensity: number;
  29624. /**
  29625. * Gets the midtones Saturation value.
  29626. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29627. */
  29628. /**
  29629. * Sets the midtones Saturation value.
  29630. * 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.
  29631. */
  29632. midtonesSaturation: number;
  29633. /**
  29634. * Gets the midtones Exposure value.
  29635. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29636. */
  29637. /**
  29638. * Sets the midtones Exposure value.
  29639. * 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.
  29640. */
  29641. midtonesExposure: number;
  29642. private _shadowsHue;
  29643. private _shadowsDensity;
  29644. private _shadowsSaturation;
  29645. private _shadowsExposure;
  29646. /**
  29647. * Gets the shadows Hue value.
  29648. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  29649. */
  29650. /**
  29651. * Sets the shadows Hue value.
  29652. * 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).
  29653. */
  29654. shadowsHue: number;
  29655. /**
  29656. * Gets the shadows Density value.
  29657. * 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.
  29658. * Values less than zero provide a filter of opposite hue.
  29659. */
  29660. /**
  29661. * Sets the shadows Density value.
  29662. * 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.
  29663. * Values less than zero provide a filter of opposite hue.
  29664. */
  29665. shadowsDensity: number;
  29666. /**
  29667. * Gets the shadows Saturation value.
  29668. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  29669. */
  29670. /**
  29671. * Sets the shadows Saturation value.
  29672. * 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.
  29673. */
  29674. shadowsSaturation: number;
  29675. /**
  29676. * Gets the shadows Exposure value.
  29677. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29678. */
  29679. /**
  29680. * Sets the shadows Exposure value.
  29681. * 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.
  29682. */
  29683. shadowsExposure: number;
  29684. /**
  29685. * Returns the class name
  29686. * @returns The class name
  29687. */
  29688. getClassName(): string;
  29689. /**
  29690. * Binds the color curves to the shader.
  29691. * @param colorCurves The color curve to bind
  29692. * @param effect The effect to bind to
  29693. * @param positiveUniform The positive uniform shader parameter
  29694. * @param neutralUniform The neutral uniform shader parameter
  29695. * @param negativeUniform The negative uniform shader parameter
  29696. */
  29697. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29698. /**
  29699. * Prepare the list of uniforms associated with the ColorCurves effects.
  29700. * @param uniformsList The list of uniforms used in the effect
  29701. */
  29702. static PrepareUniforms(uniformsList: string[]): void;
  29703. /**
  29704. * Returns color grading data based on a hue, density, saturation and exposure value.
  29705. * @param filterHue The hue of the color filter.
  29706. * @param filterDensity The density of the color filter.
  29707. * @param saturation The saturation.
  29708. * @param exposure The exposure.
  29709. * @param result The result data container.
  29710. */
  29711. private getColorGradingDataToRef;
  29712. /**
  29713. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29714. * @param value The input slider value in range [-100,100].
  29715. * @returns Adjusted value.
  29716. */
  29717. private static applyColorGradingSliderNonlinear;
  29718. /**
  29719. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29720. * @param hue The hue (H) input.
  29721. * @param saturation The saturation (S) input.
  29722. * @param brightness The brightness (B) input.
  29723. * @result An RGBA color represented as Vector4.
  29724. */
  29725. private static fromHSBToRef;
  29726. /**
  29727. * Returns a value clamped between min and max
  29728. * @param value The value to clamp
  29729. * @param min The minimum of value
  29730. * @param max The maximum of value
  29731. * @returns The clamped value.
  29732. */
  29733. private static clamp;
  29734. /**
  29735. * Clones the current color curve instance.
  29736. * @return The cloned curves
  29737. */
  29738. clone(): ColorCurves;
  29739. /**
  29740. * Serializes the current color curve instance to a json representation.
  29741. * @return a JSON representation
  29742. */
  29743. serialize(): any;
  29744. /**
  29745. * Parses the color curve from a json representation.
  29746. * @param source the JSON source to parse
  29747. * @return The parsed curves
  29748. */
  29749. static Parse(source: any): ColorCurves;
  29750. }
  29751. }
  29752. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29753. import { Observable } from "babylonjs/Misc/observable";
  29754. import { Nullable } from "babylonjs/types";
  29755. import { Color4 } from "babylonjs/Maths/math";
  29756. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29757. import { Effect } from "babylonjs/Materials/effect";
  29758. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29759. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29760. /**
  29761. * Interface to follow in your material defines to integrate easily the
  29762. * Image proccessing functions.
  29763. * @hidden
  29764. */
  29765. export interface IImageProcessingConfigurationDefines {
  29766. IMAGEPROCESSING: boolean;
  29767. VIGNETTE: boolean;
  29768. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29769. VIGNETTEBLENDMODEOPAQUE: boolean;
  29770. TONEMAPPING: boolean;
  29771. TONEMAPPING_ACES: boolean;
  29772. CONTRAST: boolean;
  29773. EXPOSURE: boolean;
  29774. COLORCURVES: boolean;
  29775. COLORGRADING: boolean;
  29776. COLORGRADING3D: boolean;
  29777. SAMPLER3DGREENDEPTH: boolean;
  29778. SAMPLER3DBGRMAP: boolean;
  29779. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29780. }
  29781. /**
  29782. * @hidden
  29783. */
  29784. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29785. IMAGEPROCESSING: boolean;
  29786. VIGNETTE: boolean;
  29787. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29788. VIGNETTEBLENDMODEOPAQUE: boolean;
  29789. TONEMAPPING: boolean;
  29790. TONEMAPPING_ACES: boolean;
  29791. CONTRAST: boolean;
  29792. COLORCURVES: boolean;
  29793. COLORGRADING: boolean;
  29794. COLORGRADING3D: boolean;
  29795. SAMPLER3DGREENDEPTH: boolean;
  29796. SAMPLER3DBGRMAP: boolean;
  29797. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29798. EXPOSURE: boolean;
  29799. constructor();
  29800. }
  29801. /**
  29802. * This groups together the common properties used for image processing either in direct forward pass
  29803. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29804. * or not.
  29805. */
  29806. export class ImageProcessingConfiguration {
  29807. /**
  29808. * Default tone mapping applied in BabylonJS.
  29809. */
  29810. static readonly TONEMAPPING_STANDARD: number;
  29811. /**
  29812. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29813. * to other engines rendering to increase portability.
  29814. */
  29815. static readonly TONEMAPPING_ACES: number;
  29816. /**
  29817. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29818. */
  29819. colorCurves: Nullable<ColorCurves>;
  29820. private _colorCurvesEnabled;
  29821. /**
  29822. * Gets wether the color curves effect is enabled.
  29823. */
  29824. /**
  29825. * Sets wether the color curves effect is enabled.
  29826. */
  29827. colorCurvesEnabled: boolean;
  29828. private _colorGradingTexture;
  29829. /**
  29830. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29831. */
  29832. /**
  29833. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29834. */
  29835. colorGradingTexture: Nullable<BaseTexture>;
  29836. private _colorGradingEnabled;
  29837. /**
  29838. * Gets wether the color grading effect is enabled.
  29839. */
  29840. /**
  29841. * Sets wether the color grading effect is enabled.
  29842. */
  29843. colorGradingEnabled: boolean;
  29844. private _colorGradingWithGreenDepth;
  29845. /**
  29846. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29847. */
  29848. /**
  29849. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29850. */
  29851. colorGradingWithGreenDepth: boolean;
  29852. private _colorGradingBGR;
  29853. /**
  29854. * Gets wether the color grading texture contains BGR values.
  29855. */
  29856. /**
  29857. * Sets wether the color grading texture contains BGR values.
  29858. */
  29859. colorGradingBGR: boolean;
  29860. /** @hidden */
  29861. _exposure: number;
  29862. /**
  29863. * Gets the Exposure used in the effect.
  29864. */
  29865. /**
  29866. * Sets the Exposure used in the effect.
  29867. */
  29868. exposure: number;
  29869. private _toneMappingEnabled;
  29870. /**
  29871. * Gets wether the tone mapping effect is enabled.
  29872. */
  29873. /**
  29874. * Sets wether the tone mapping effect is enabled.
  29875. */
  29876. toneMappingEnabled: boolean;
  29877. private _toneMappingType;
  29878. /**
  29879. * Gets the type of tone mapping effect.
  29880. */
  29881. /**
  29882. * Sets the type of tone mapping effect used in BabylonJS.
  29883. */
  29884. toneMappingType: number;
  29885. protected _contrast: number;
  29886. /**
  29887. * Gets the contrast used in the effect.
  29888. */
  29889. /**
  29890. * Sets the contrast used in the effect.
  29891. */
  29892. contrast: number;
  29893. /**
  29894. * Vignette stretch size.
  29895. */
  29896. vignetteStretch: number;
  29897. /**
  29898. * Vignette centre X Offset.
  29899. */
  29900. vignetteCentreX: number;
  29901. /**
  29902. * Vignette centre Y Offset.
  29903. */
  29904. vignetteCentreY: number;
  29905. /**
  29906. * Vignette weight or intensity of the vignette effect.
  29907. */
  29908. vignetteWeight: number;
  29909. /**
  29910. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29911. * if vignetteEnabled is set to true.
  29912. */
  29913. vignetteColor: Color4;
  29914. /**
  29915. * Camera field of view used by the Vignette effect.
  29916. */
  29917. vignetteCameraFov: number;
  29918. private _vignetteBlendMode;
  29919. /**
  29920. * Gets the vignette blend mode allowing different kind of effect.
  29921. */
  29922. /**
  29923. * Sets the vignette blend mode allowing different kind of effect.
  29924. */
  29925. vignetteBlendMode: number;
  29926. private _vignetteEnabled;
  29927. /**
  29928. * Gets wether the vignette effect is enabled.
  29929. */
  29930. /**
  29931. * Sets wether the vignette effect is enabled.
  29932. */
  29933. vignetteEnabled: boolean;
  29934. private _applyByPostProcess;
  29935. /**
  29936. * Gets wether the image processing is applied through a post process or not.
  29937. */
  29938. /**
  29939. * Sets wether the image processing is applied through a post process or not.
  29940. */
  29941. applyByPostProcess: boolean;
  29942. private _isEnabled;
  29943. /**
  29944. * Gets wether the image processing is enabled or not.
  29945. */
  29946. /**
  29947. * Sets wether the image processing is enabled or not.
  29948. */
  29949. isEnabled: boolean;
  29950. /**
  29951. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29952. */
  29953. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29954. /**
  29955. * Method called each time the image processing information changes requires to recompile the effect.
  29956. */
  29957. protected _updateParameters(): void;
  29958. /**
  29959. * Gets the current class name.
  29960. * @return "ImageProcessingConfiguration"
  29961. */
  29962. getClassName(): string;
  29963. /**
  29964. * Prepare the list of uniforms associated with the Image Processing effects.
  29965. * @param uniforms The list of uniforms used in the effect
  29966. * @param defines the list of defines currently in use
  29967. */
  29968. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29969. /**
  29970. * Prepare the list of samplers associated with the Image Processing effects.
  29971. * @param samplersList The list of uniforms used in the effect
  29972. * @param defines the list of defines currently in use
  29973. */
  29974. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29975. /**
  29976. * Prepare the list of defines associated to the shader.
  29977. * @param defines the list of defines to complete
  29978. * @param forPostProcess Define if we are currently in post process mode or not
  29979. */
  29980. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29981. /**
  29982. * Returns true if all the image processing information are ready.
  29983. * @returns True if ready, otherwise, false
  29984. */
  29985. isReady(): boolean;
  29986. /**
  29987. * Binds the image processing to the shader.
  29988. * @param effect The effect to bind to
  29989. * @param aspectRatio Define the current aspect ratio of the effect
  29990. */
  29991. bind(effect: Effect, aspectRatio?: number): void;
  29992. /**
  29993. * Clones the current image processing instance.
  29994. * @return The cloned image processing
  29995. */
  29996. clone(): ImageProcessingConfiguration;
  29997. /**
  29998. * Serializes the current image processing instance to a json representation.
  29999. * @return a JSON representation
  30000. */
  30001. serialize(): any;
  30002. /**
  30003. * Parses the image processing from a json representation.
  30004. * @param source the JSON source to parse
  30005. * @return The parsed image processing
  30006. */
  30007. static Parse(source: any): ImageProcessingConfiguration;
  30008. private static _VIGNETTEMODE_MULTIPLY;
  30009. private static _VIGNETTEMODE_OPAQUE;
  30010. /**
  30011. * Used to apply the vignette as a mix with the pixel color.
  30012. */
  30013. static readonly VIGNETTEMODE_MULTIPLY: number;
  30014. /**
  30015. * Used to apply the vignette as a replacement of the pixel color.
  30016. */
  30017. static readonly VIGNETTEMODE_OPAQUE: number;
  30018. }
  30019. }
  30020. declare module "babylonjs/Materials/fresnelParameters" {
  30021. import { Color3 } from "babylonjs/Maths/math";
  30022. /**
  30023. * This represents all the required information to add a fresnel effect on a material:
  30024. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30025. */
  30026. export class FresnelParameters {
  30027. private _isEnabled;
  30028. /**
  30029. * Define if the fresnel effect is enable or not.
  30030. */
  30031. isEnabled: boolean;
  30032. /**
  30033. * Define the color used on edges (grazing angle)
  30034. */
  30035. leftColor: Color3;
  30036. /**
  30037. * Define the color used on center
  30038. */
  30039. rightColor: Color3;
  30040. /**
  30041. * Define bias applied to computed fresnel term
  30042. */
  30043. bias: number;
  30044. /**
  30045. * Defined the power exponent applied to fresnel term
  30046. */
  30047. power: number;
  30048. /**
  30049. * Clones the current fresnel and its valuues
  30050. * @returns a clone fresnel configuration
  30051. */
  30052. clone(): FresnelParameters;
  30053. /**
  30054. * Serializes the current fresnel parameters to a JSON representation.
  30055. * @return the JSON serialization
  30056. */
  30057. serialize(): any;
  30058. /**
  30059. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30060. * @param parsedFresnelParameters Define the JSON representation
  30061. * @returns the parsed parameters
  30062. */
  30063. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30064. }
  30065. }
  30066. declare module "babylonjs/Misc/decorators" {
  30067. import { Nullable } from "babylonjs/types";
  30068. import { Scene } from "babylonjs/scene";
  30069. import { IAnimatable } from "babylonjs/Misc/tools";
  30070. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30071. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30072. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30073. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30074. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30075. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30076. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30077. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30078. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30079. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30080. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30081. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30082. /**
  30083. * Decorator used to define property that can be serialized as reference to a camera
  30084. * @param sourceName defines the name of the property to decorate
  30085. */
  30086. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30087. /**
  30088. * Class used to help serialization objects
  30089. */
  30090. export class SerializationHelper {
  30091. /** hidden */
  30092. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30093. /** hidden */
  30094. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30095. /** hidden */
  30096. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30097. /** hidden */
  30098. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30099. /**
  30100. * Appends the serialized animations from the source animations
  30101. * @param source Source containing the animations
  30102. * @param destination Target to store the animations
  30103. */
  30104. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30105. /**
  30106. * Static function used to serialized a specific entity
  30107. * @param entity defines the entity to serialize
  30108. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30109. * @returns a JSON compatible object representing the serialization of the entity
  30110. */
  30111. static Serialize<T>(entity: T, serializationObject?: any): any;
  30112. /**
  30113. * Creates a new entity from a serialization data object
  30114. * @param creationFunction defines a function used to instanciated the new entity
  30115. * @param source defines the source serialization data
  30116. * @param scene defines the hosting scene
  30117. * @param rootUrl defines the root url for resources
  30118. * @returns a new entity
  30119. */
  30120. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30121. /**
  30122. * Clones an object
  30123. * @param creationFunction defines the function used to instanciate the new object
  30124. * @param source defines the source object
  30125. * @returns the cloned object
  30126. */
  30127. static Clone<T>(creationFunction: () => T, source: T): T;
  30128. /**
  30129. * Instanciates a new object based on a source one (some data will be shared between both object)
  30130. * @param creationFunction defines the function used to instanciate the new object
  30131. * @param source defines the source object
  30132. * @returns the new object
  30133. */
  30134. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30135. }
  30136. }
  30137. declare module "babylonjs/Cameras/camera" {
  30138. import { SmartArray } from "babylonjs/Misc/smartArray";
  30139. import { Observable } from "babylonjs/Misc/observable";
  30140. import { Nullable } from "babylonjs/types";
  30141. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30142. import { Scene } from "babylonjs/scene";
  30143. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30144. import { Node } from "babylonjs/node";
  30145. import { Mesh } from "babylonjs/Meshes/mesh";
  30146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30147. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30148. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30149. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30150. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30151. import { Ray } from "babylonjs/Culling/ray";
  30152. /**
  30153. * This is the base class of all the camera used in the application.
  30154. * @see http://doc.babylonjs.com/features/cameras
  30155. */
  30156. export class Camera extends Node {
  30157. /** @hidden */
  30158. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30159. /**
  30160. * This is the default projection mode used by the cameras.
  30161. * It helps recreating a feeling of perspective and better appreciate depth.
  30162. * This is the best way to simulate real life cameras.
  30163. */
  30164. static readonly PERSPECTIVE_CAMERA: number;
  30165. /**
  30166. * This helps creating camera with an orthographic mode.
  30167. * 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.
  30168. */
  30169. static readonly ORTHOGRAPHIC_CAMERA: number;
  30170. /**
  30171. * This is the default FOV mode for perspective cameras.
  30172. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30173. */
  30174. static readonly FOVMODE_VERTICAL_FIXED: number;
  30175. /**
  30176. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30177. */
  30178. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30179. /**
  30180. * This specifies ther is no need for a camera rig.
  30181. * Basically only one eye is rendered corresponding to the camera.
  30182. */
  30183. static readonly RIG_MODE_NONE: number;
  30184. /**
  30185. * Simulates a camera Rig with one blue eye and one red eye.
  30186. * This can be use with 3d blue and red glasses.
  30187. */
  30188. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30189. /**
  30190. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30191. */
  30192. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30193. /**
  30194. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30195. */
  30196. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30197. /**
  30198. * Defines that both eyes of the camera will be rendered over under each other.
  30199. */
  30200. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30201. /**
  30202. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30203. */
  30204. static readonly RIG_MODE_VR: number;
  30205. /**
  30206. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30207. */
  30208. static readonly RIG_MODE_WEBVR: number;
  30209. /**
  30210. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30211. */
  30212. static readonly RIG_MODE_CUSTOM: number;
  30213. /**
  30214. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30215. */
  30216. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30217. /**
  30218. * @hidden
  30219. * Might be removed once multiview will be a thing
  30220. */
  30221. static UseAlternateWebVRRendering: boolean;
  30222. /**
  30223. * Define the input manager associated with the camera.
  30224. */
  30225. inputs: CameraInputsManager<Camera>;
  30226. /** @hidden */
  30227. _position: Vector3;
  30228. /**
  30229. * Define the current local position of the camera in the scene
  30230. */
  30231. position: Vector3;
  30232. /**
  30233. * The vector the camera should consider as up.
  30234. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30235. */
  30236. upVector: Vector3;
  30237. /**
  30238. * Define the current limit on the left side for an orthographic camera
  30239. * In scene unit
  30240. */
  30241. orthoLeft: Nullable<number>;
  30242. /**
  30243. * Define the current limit on the right side for an orthographic camera
  30244. * In scene unit
  30245. */
  30246. orthoRight: Nullable<number>;
  30247. /**
  30248. * Define the current limit on the bottom side for an orthographic camera
  30249. * In scene unit
  30250. */
  30251. orthoBottom: Nullable<number>;
  30252. /**
  30253. * Define the current limit on the top side for an orthographic camera
  30254. * In scene unit
  30255. */
  30256. orthoTop: Nullable<number>;
  30257. /**
  30258. * Field Of View is set in Radians. (default is 0.8)
  30259. */
  30260. fov: number;
  30261. /**
  30262. * Define the minimum distance the camera can see from.
  30263. * This is important to note that the depth buffer are not infinite and the closer it starts
  30264. * the more your scene might encounter depth fighting issue.
  30265. */
  30266. minZ: number;
  30267. /**
  30268. * Define the maximum distance the camera can see to.
  30269. * This is important to note that the depth buffer are not infinite and the further it end
  30270. * the more your scene might encounter depth fighting issue.
  30271. */
  30272. maxZ: number;
  30273. /**
  30274. * Define the default inertia of the camera.
  30275. * This helps giving a smooth feeling to the camera movement.
  30276. */
  30277. inertia: number;
  30278. /**
  30279. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30280. */
  30281. mode: number;
  30282. /**
  30283. * Define wether the camera is intermediate.
  30284. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30285. */
  30286. isIntermediate: boolean;
  30287. /**
  30288. * Define the viewport of the camera.
  30289. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30290. */
  30291. viewport: Viewport;
  30292. /**
  30293. * Restricts the camera to viewing objects with the same layerMask.
  30294. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30295. */
  30296. layerMask: number;
  30297. /**
  30298. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30299. */
  30300. fovMode: number;
  30301. /**
  30302. * Rig mode of the camera.
  30303. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30304. * This is normally controlled byt the camera themselves as internal use.
  30305. */
  30306. cameraRigMode: number;
  30307. /**
  30308. * Defines the distance between both "eyes" in case of a RIG
  30309. */
  30310. interaxialDistance: number;
  30311. /**
  30312. * Defines if stereoscopic rendering is done side by side or over under.
  30313. */
  30314. isStereoscopicSideBySide: boolean;
  30315. /**
  30316. * 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
  30317. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30318. * else in the scene.
  30319. */
  30320. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30321. /**
  30322. * When set, the camera will render to this render target instead of the default canvas
  30323. */
  30324. outputRenderTarget: Nullable<RenderTargetTexture>;
  30325. /**
  30326. * Observable triggered when the camera view matrix has changed.
  30327. */
  30328. onViewMatrixChangedObservable: Observable<Camera>;
  30329. /**
  30330. * Observable triggered when the camera Projection matrix has changed.
  30331. */
  30332. onProjectionMatrixChangedObservable: Observable<Camera>;
  30333. /**
  30334. * Observable triggered when the inputs have been processed.
  30335. */
  30336. onAfterCheckInputsObservable: Observable<Camera>;
  30337. /**
  30338. * Observable triggered when reset has been called and applied to the camera.
  30339. */
  30340. onRestoreStateObservable: Observable<Camera>;
  30341. /** @hidden */
  30342. _cameraRigParams: any;
  30343. /** @hidden */
  30344. _rigCameras: Camera[];
  30345. /** @hidden */
  30346. _rigPostProcess: Nullable<PostProcess>;
  30347. protected _webvrViewMatrix: Matrix;
  30348. /** @hidden */
  30349. _skipRendering: boolean;
  30350. /** @hidden */
  30351. _alternateCamera: Camera;
  30352. /** @hidden */
  30353. _projectionMatrix: Matrix;
  30354. /** @hidden */
  30355. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30356. /** @hidden */
  30357. _activeMeshes: SmartArray<AbstractMesh>;
  30358. protected _globalPosition: Vector3;
  30359. /** hidden */
  30360. _computedViewMatrix: Matrix;
  30361. private _doNotComputeProjectionMatrix;
  30362. private _transformMatrix;
  30363. private _frustumPlanes;
  30364. private _refreshFrustumPlanes;
  30365. private _storedFov;
  30366. private _stateStored;
  30367. /**
  30368. * Instantiates a new camera object.
  30369. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30370. * @see http://doc.babylonjs.com/features/cameras
  30371. * @param name Defines the name of the camera in the scene
  30372. * @param position Defines the position of the camera
  30373. * @param scene Defines the scene the camera belongs too
  30374. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30375. */
  30376. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30377. /**
  30378. * Store current camera state (fov, position, etc..)
  30379. * @returns the camera
  30380. */
  30381. storeState(): Camera;
  30382. /**
  30383. * Restores the camera state values if it has been stored. You must call storeState() first
  30384. */
  30385. protected _restoreStateValues(): boolean;
  30386. /**
  30387. * Restored camera state. You must call storeState() first.
  30388. * @returns true if restored and false otherwise
  30389. */
  30390. restoreState(): boolean;
  30391. /**
  30392. * Gets the class name of the camera.
  30393. * @returns the class name
  30394. */
  30395. getClassName(): string;
  30396. /** @hidden */
  30397. readonly _isCamera: boolean;
  30398. /**
  30399. * Gets a string representation of the camera useful for debug purpose.
  30400. * @param fullDetails Defines that a more verboe level of logging is required
  30401. * @returns the string representation
  30402. */
  30403. toString(fullDetails?: boolean): string;
  30404. /**
  30405. * Gets the current world space position of the camera.
  30406. */
  30407. readonly globalPosition: Vector3;
  30408. /**
  30409. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30410. * @returns the active meshe list
  30411. */
  30412. getActiveMeshes(): SmartArray<AbstractMesh>;
  30413. /**
  30414. * Check wether a mesh is part of the current active mesh list of the camera
  30415. * @param mesh Defines the mesh to check
  30416. * @returns true if active, false otherwise
  30417. */
  30418. isActiveMesh(mesh: Mesh): boolean;
  30419. /**
  30420. * Is this camera ready to be used/rendered
  30421. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30422. * @return true if the camera is ready
  30423. */
  30424. isReady(completeCheck?: boolean): boolean;
  30425. /** @hidden */
  30426. _initCache(): void;
  30427. /** @hidden */
  30428. _updateCache(ignoreParentClass?: boolean): void;
  30429. /** @hidden */
  30430. _isSynchronized(): boolean;
  30431. /** @hidden */
  30432. _isSynchronizedViewMatrix(): boolean;
  30433. /** @hidden */
  30434. _isSynchronizedProjectionMatrix(): boolean;
  30435. /**
  30436. * Attach the input controls to a specific dom element to get the input from.
  30437. * @param element Defines the element the controls should be listened from
  30438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30439. */
  30440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30441. /**
  30442. * Detach the current controls from the specified dom element.
  30443. * @param element Defines the element to stop listening the inputs from
  30444. */
  30445. detachControl(element: HTMLElement): void;
  30446. /**
  30447. * Update the camera state according to the different inputs gathered during the frame.
  30448. */
  30449. update(): void;
  30450. /** @hidden */
  30451. _checkInputs(): void;
  30452. /** @hidden */
  30453. readonly rigCameras: Camera[];
  30454. /**
  30455. * Gets the post process used by the rig cameras
  30456. */
  30457. readonly rigPostProcess: Nullable<PostProcess>;
  30458. /**
  30459. * Internal, gets the first post proces.
  30460. * @returns the first post process to be run on this camera.
  30461. */
  30462. _getFirstPostProcess(): Nullable<PostProcess>;
  30463. private _cascadePostProcessesToRigCams;
  30464. /**
  30465. * Attach a post process to the camera.
  30466. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30467. * @param postProcess The post process to attach to the camera
  30468. * @param insertAt The position of the post process in case several of them are in use in the scene
  30469. * @returns the position the post process has been inserted at
  30470. */
  30471. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30472. /**
  30473. * Detach a post process to the camera.
  30474. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30475. * @param postProcess The post process to detach from the camera
  30476. */
  30477. detachPostProcess(postProcess: PostProcess): void;
  30478. /**
  30479. * Gets the current world matrix of the camera
  30480. */
  30481. getWorldMatrix(): Matrix;
  30482. /** @hidden */
  30483. _getViewMatrix(): Matrix;
  30484. /**
  30485. * Gets the current view matrix of the camera.
  30486. * @param force forces the camera to recompute the matrix without looking at the cached state
  30487. * @returns the view matrix
  30488. */
  30489. getViewMatrix(force?: boolean): Matrix;
  30490. /**
  30491. * Freeze the projection matrix.
  30492. * It will prevent the cache check of the camera projection compute and can speed up perf
  30493. * if no parameter of the camera are meant to change
  30494. * @param projection Defines manually a projection if necessary
  30495. */
  30496. freezeProjectionMatrix(projection?: Matrix): void;
  30497. /**
  30498. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30499. */
  30500. unfreezeProjectionMatrix(): void;
  30501. /**
  30502. * Gets the current projection matrix of the camera.
  30503. * @param force forces the camera to recompute the matrix without looking at the cached state
  30504. * @returns the projection matrix
  30505. */
  30506. getProjectionMatrix(force?: boolean): Matrix;
  30507. /**
  30508. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30509. * @returns a Matrix
  30510. */
  30511. getTransformationMatrix(): Matrix;
  30512. private _updateFrustumPlanes;
  30513. /**
  30514. * Checks if a cullable object (mesh...) is in the camera frustum
  30515. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30516. * @param target The object to check
  30517. * @returns true if the object is in frustum otherwise false
  30518. */
  30519. isInFrustum(target: ICullable): boolean;
  30520. /**
  30521. * Checks if a cullable object (mesh...) is in the camera frustum
  30522. * Unlike isInFrustum this cheks the full bounding box
  30523. * @param target The object to check
  30524. * @returns true if the object is in frustum otherwise false
  30525. */
  30526. isCompletelyInFrustum(target: ICullable): boolean;
  30527. /**
  30528. * Gets a ray in the forward direction from the camera.
  30529. * @param length Defines the length of the ray to create
  30530. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30531. * @param origin Defines the start point of the ray which defaults to the camera position
  30532. * @returns the forward ray
  30533. */
  30534. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30535. /**
  30536. * Releases resources associated with this node.
  30537. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30538. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30539. */
  30540. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30541. /** @hidden */
  30542. _isLeftCamera: boolean;
  30543. /**
  30544. * Gets the left camera of a rig setup in case of Rigged Camera
  30545. */
  30546. readonly isLeftCamera: boolean;
  30547. /** @hidden */
  30548. _isRightCamera: boolean;
  30549. /**
  30550. * Gets the right camera of a rig setup in case of Rigged Camera
  30551. */
  30552. readonly isRightCamera: boolean;
  30553. /**
  30554. * Gets the left camera of a rig setup in case of Rigged Camera
  30555. */
  30556. readonly leftCamera: Nullable<FreeCamera>;
  30557. /**
  30558. * Gets the right camera of a rig setup in case of Rigged Camera
  30559. */
  30560. readonly rightCamera: Nullable<FreeCamera>;
  30561. /**
  30562. * Gets the left camera target of a rig setup in case of Rigged Camera
  30563. * @returns the target position
  30564. */
  30565. getLeftTarget(): Nullable<Vector3>;
  30566. /**
  30567. * Gets the right camera target of a rig setup in case of Rigged Camera
  30568. * @returns the target position
  30569. */
  30570. getRightTarget(): Nullable<Vector3>;
  30571. /**
  30572. * @hidden
  30573. */
  30574. setCameraRigMode(mode: number, rigParams: any): void;
  30575. /** @hidden */
  30576. static _setStereoscopicRigMode(camera: Camera): void;
  30577. /** @hidden */
  30578. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30579. /** @hidden */
  30580. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30581. /** @hidden */
  30582. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30583. /** @hidden */
  30584. _getVRProjectionMatrix(): Matrix;
  30585. protected _updateCameraRotationMatrix(): void;
  30586. protected _updateWebVRCameraRotationMatrix(): void;
  30587. /**
  30588. * This function MUST be overwritten by the different WebVR cameras available.
  30589. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30590. * @hidden
  30591. */
  30592. _getWebVRProjectionMatrix(): Matrix;
  30593. /**
  30594. * This function MUST be overwritten by the different WebVR cameras available.
  30595. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30596. * @hidden
  30597. */
  30598. _getWebVRViewMatrix(): Matrix;
  30599. /** @hidden */
  30600. setCameraRigParameter(name: string, value: any): void;
  30601. /**
  30602. * needs to be overridden by children so sub has required properties to be copied
  30603. * @hidden
  30604. */
  30605. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30606. /**
  30607. * May need to be overridden by children
  30608. * @hidden
  30609. */
  30610. _updateRigCameras(): void;
  30611. /** @hidden */
  30612. _setupInputs(): void;
  30613. /**
  30614. * Serialiaze the camera setup to a json represention
  30615. * @returns the JSON representation
  30616. */
  30617. serialize(): any;
  30618. /**
  30619. * Clones the current camera.
  30620. * @param name The cloned camera name
  30621. * @returns the cloned camera
  30622. */
  30623. clone(name: string): Camera;
  30624. /**
  30625. * Gets the direction of the camera relative to a given local axis.
  30626. * @param localAxis Defines the reference axis to provide a relative direction.
  30627. * @return the direction
  30628. */
  30629. getDirection(localAxis: Vector3): Vector3;
  30630. /**
  30631. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30632. * @param localAxis Defines the reference axis to provide a relative direction.
  30633. * @param result Defines the vector to store the result in
  30634. */
  30635. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30636. /**
  30637. * Gets a camera constructor for a given camera type
  30638. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30639. * @param name The name of the camera the result will be able to instantiate
  30640. * @param scene The scene the result will construct the camera in
  30641. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30642. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30643. * @returns a factory method to construc the camera
  30644. */
  30645. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30646. /**
  30647. * Compute the world matrix of the camera.
  30648. * @returns the camera workd matrix
  30649. */
  30650. computeWorldMatrix(): Matrix;
  30651. /**
  30652. * Parse a JSON and creates the camera from the parsed information
  30653. * @param parsedCamera The JSON to parse
  30654. * @param scene The scene to instantiate the camera in
  30655. * @returns the newly constructed camera
  30656. */
  30657. static Parse(parsedCamera: any, scene: Scene): Camera;
  30658. }
  30659. }
  30660. declare module "babylonjs/Misc/tools" {
  30661. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30662. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30663. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30664. import { Observable } from "babylonjs/Misc/observable";
  30665. import { DomManagement } from "babylonjs/Misc/domManagement";
  30666. import { Camera } from "babylonjs/Cameras/camera";
  30667. import { Engine } from "babylonjs/Engines/engine";
  30668. import { Animation } from "babylonjs/Animations/animation";
  30669. /**
  30670. * Interface for any object that can request an animation frame
  30671. */
  30672. export interface ICustomAnimationFrameRequester {
  30673. /**
  30674. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30675. */
  30676. renderFunction?: Function;
  30677. /**
  30678. * Called to request the next frame to render to
  30679. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30680. */
  30681. requestAnimationFrame: Function;
  30682. /**
  30683. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30684. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30685. */
  30686. requestID?: number;
  30687. }
  30688. /**
  30689. * Interface containing an array of animations
  30690. */
  30691. export interface IAnimatable {
  30692. /**
  30693. * Array of animations
  30694. */
  30695. animations: Array<Animation>;
  30696. }
  30697. /** Interface used by value gradients (color, factor, ...) */
  30698. export interface IValueGradient {
  30699. /**
  30700. * Gets or sets the gradient value (between 0 and 1)
  30701. */
  30702. gradient: number;
  30703. }
  30704. /** Class used to store color4 gradient */
  30705. export class ColorGradient implements IValueGradient {
  30706. /**
  30707. * Gets or sets the gradient value (between 0 and 1)
  30708. */
  30709. gradient: number;
  30710. /**
  30711. * Gets or sets first associated color
  30712. */
  30713. color1: Color4;
  30714. /**
  30715. * Gets or sets second associated color
  30716. */
  30717. color2?: Color4;
  30718. /**
  30719. * Will get a color picked randomly between color1 and color2.
  30720. * If color2 is undefined then color1 will be used
  30721. * @param result defines the target Color4 to store the result in
  30722. */
  30723. getColorToRef(result: Color4): void;
  30724. }
  30725. /** Class used to store color 3 gradient */
  30726. export class Color3Gradient implements IValueGradient {
  30727. /**
  30728. * Gets or sets the gradient value (between 0 and 1)
  30729. */
  30730. gradient: number;
  30731. /**
  30732. * Gets or sets the associated color
  30733. */
  30734. color: Color3;
  30735. }
  30736. /** Class used to store factor gradient */
  30737. export class FactorGradient implements IValueGradient {
  30738. /**
  30739. * Gets or sets the gradient value (between 0 and 1)
  30740. */
  30741. gradient: number;
  30742. /**
  30743. * Gets or sets first associated factor
  30744. */
  30745. factor1: number;
  30746. /**
  30747. * Gets or sets second associated factor
  30748. */
  30749. factor2?: number;
  30750. /**
  30751. * Will get a number picked randomly between factor1 and factor2.
  30752. * If factor2 is undefined then factor1 will be used
  30753. * @returns the picked number
  30754. */
  30755. getFactor(): number;
  30756. }
  30757. /**
  30758. * @ignore
  30759. * Application error to support additional information when loading a file
  30760. */
  30761. export class LoadFileError extends Error {
  30762. /** defines the optional XHR request */
  30763. request?: XMLHttpRequest | undefined;
  30764. private static _setPrototypeOf;
  30765. /**
  30766. * Creates a new LoadFileError
  30767. * @param message defines the message of the error
  30768. * @param request defines the optional XHR request
  30769. */
  30770. constructor(message: string,
  30771. /** defines the optional XHR request */
  30772. request?: XMLHttpRequest | undefined);
  30773. }
  30774. /**
  30775. * Class used to define a retry strategy when error happens while loading assets
  30776. */
  30777. export class RetryStrategy {
  30778. /**
  30779. * Function used to defines an exponential back off strategy
  30780. * @param maxRetries defines the maximum number of retries (3 by default)
  30781. * @param baseInterval defines the interval between retries
  30782. * @returns the strategy function to use
  30783. */
  30784. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30785. }
  30786. /**
  30787. * File request interface
  30788. */
  30789. export interface IFileRequest {
  30790. /**
  30791. * Raised when the request is complete (success or error).
  30792. */
  30793. onCompleteObservable: Observable<IFileRequest>;
  30794. /**
  30795. * Aborts the request for a file.
  30796. */
  30797. abort: () => void;
  30798. }
  30799. /**
  30800. * Class containing a set of static utilities functions
  30801. */
  30802. export class Tools {
  30803. /**
  30804. * Gets or sets the base URL to use to load assets
  30805. */
  30806. static BaseUrl: string;
  30807. /**
  30808. * Enable/Disable Custom HTTP Request Headers globally.
  30809. * default = false
  30810. * @see CustomRequestHeaders
  30811. */
  30812. static UseCustomRequestHeaders: boolean;
  30813. /**
  30814. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30815. * i.e. when loading files, where the server/service expects an Authorization header.
  30816. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30817. */
  30818. static CustomRequestHeaders: {
  30819. [key: string]: string;
  30820. };
  30821. /**
  30822. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30823. */
  30824. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30825. /**
  30826. * Default behaviour for cors in the application.
  30827. * It can be a string if the expected behavior is identical in the entire app.
  30828. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30829. */
  30830. static CorsBehavior: string | ((url: string | string[]) => string);
  30831. /**
  30832. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30833. * @ignorenaming
  30834. */
  30835. static UseFallbackTexture: boolean;
  30836. /**
  30837. * Use this object to register external classes like custom textures or material
  30838. * to allow the laoders to instantiate them
  30839. */
  30840. static RegisteredExternalClasses: {
  30841. [key: string]: Object;
  30842. };
  30843. /**
  30844. * Texture content used if a texture cannot loaded
  30845. * @ignorenaming
  30846. */
  30847. static fallbackTexture: string;
  30848. /**
  30849. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30850. * @param u defines the coordinate on X axis
  30851. * @param v defines the coordinate on Y axis
  30852. * @param width defines the width of the source data
  30853. * @param height defines the height of the source data
  30854. * @param pixels defines the source byte array
  30855. * @param color defines the output color
  30856. */
  30857. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30858. /**
  30859. * Interpolates between a and b via alpha
  30860. * @param a The lower value (returned when alpha = 0)
  30861. * @param b The upper value (returned when alpha = 1)
  30862. * @param alpha The interpolation-factor
  30863. * @return The mixed value
  30864. */
  30865. static Mix(a: number, b: number, alpha: number): number;
  30866. /**
  30867. * Tries to instantiate a new object from a given class name
  30868. * @param className defines the class name to instantiate
  30869. * @returns the new object or null if the system was not able to do the instantiation
  30870. */
  30871. static Instantiate(className: string): any;
  30872. /**
  30873. * Provides a slice function that will work even on IE
  30874. * @param data defines the array to slice
  30875. * @param start defines the start of the data (optional)
  30876. * @param end defines the end of the data (optional)
  30877. * @returns the new sliced array
  30878. */
  30879. static Slice<T>(data: T, start?: number, end?: number): T;
  30880. /**
  30881. * Polyfill for setImmediate
  30882. * @param action defines the action to execute after the current execution block
  30883. */
  30884. static SetImmediate(action: () => void): void;
  30885. /**
  30886. * Function indicating if a number is an exponent of 2
  30887. * @param value defines the value to test
  30888. * @returns true if the value is an exponent of 2
  30889. */
  30890. static IsExponentOfTwo(value: number): boolean;
  30891. private static _tmpFloatArray;
  30892. /**
  30893. * Returns the nearest 32-bit single precision float representation of a Number
  30894. * @param value A Number. If the parameter is of a different type, it will get converted
  30895. * to a number or to NaN if it cannot be converted
  30896. * @returns number
  30897. */
  30898. static FloatRound(value: number): number;
  30899. /**
  30900. * Find the next highest power of two.
  30901. * @param x Number to start search from.
  30902. * @return Next highest power of two.
  30903. */
  30904. static CeilingPOT(x: number): number;
  30905. /**
  30906. * Find the next lowest power of two.
  30907. * @param x Number to start search from.
  30908. * @return Next lowest power of two.
  30909. */
  30910. static FloorPOT(x: number): number;
  30911. /**
  30912. * Find the nearest power of two.
  30913. * @param x Number to start search from.
  30914. * @return Next nearest power of two.
  30915. */
  30916. static NearestPOT(x: number): number;
  30917. /**
  30918. * Get the closest exponent of two
  30919. * @param value defines the value to approximate
  30920. * @param max defines the maximum value to return
  30921. * @param mode defines how to define the closest value
  30922. * @returns closest exponent of two of the given value
  30923. */
  30924. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30925. /**
  30926. * Extracts the filename from a path
  30927. * @param path defines the path to use
  30928. * @returns the filename
  30929. */
  30930. static GetFilename(path: string): string;
  30931. /**
  30932. * Extracts the "folder" part of a path (everything before the filename).
  30933. * @param uri The URI to extract the info from
  30934. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30935. * @returns The "folder" part of the path
  30936. */
  30937. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30938. /**
  30939. * Extracts text content from a DOM element hierarchy
  30940. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30941. */
  30942. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30943. /**
  30944. * Convert an angle in radians to degrees
  30945. * @param angle defines the angle to convert
  30946. * @returns the angle in degrees
  30947. */
  30948. static ToDegrees(angle: number): number;
  30949. /**
  30950. * Convert an angle in degrees to radians
  30951. * @param angle defines the angle to convert
  30952. * @returns the angle in radians
  30953. */
  30954. static ToRadians(angle: number): number;
  30955. /**
  30956. * Encode a buffer to a base64 string
  30957. * @param buffer defines the buffer to encode
  30958. * @returns the encoded string
  30959. */
  30960. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30961. /**
  30962. * Extracts minimum and maximum values from a list of indexed positions
  30963. * @param positions defines the positions to use
  30964. * @param indices defines the indices to the positions
  30965. * @param indexStart defines the start index
  30966. * @param indexCount defines the end index
  30967. * @param bias defines bias value to add to the result
  30968. * @return minimum and maximum values
  30969. */
  30970. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30971. minimum: Vector3;
  30972. maximum: Vector3;
  30973. };
  30974. /**
  30975. * Extracts minimum and maximum values from a list of positions
  30976. * @param positions defines the positions to use
  30977. * @param start defines the start index in the positions array
  30978. * @param count defines the number of positions to handle
  30979. * @param bias defines bias value to add to the result
  30980. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30981. * @return minimum and maximum values
  30982. */
  30983. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30984. minimum: Vector3;
  30985. maximum: Vector3;
  30986. };
  30987. /**
  30988. * Returns an array if obj is not an array
  30989. * @param obj defines the object to evaluate as an array
  30990. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30991. * @returns either obj directly if obj is an array or a new array containing obj
  30992. */
  30993. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30994. /**
  30995. * Gets the pointer prefix to use
  30996. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30997. */
  30998. static GetPointerPrefix(): string;
  30999. /**
  31000. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31001. * @param func - the function to be called
  31002. * @param requester - the object that will request the next frame. Falls back to window.
  31003. * @returns frame number
  31004. */
  31005. static QueueNewFrame(func: () => void, requester?: any): number;
  31006. /**
  31007. * Ask the browser to promote the current element to fullscreen rendering mode
  31008. * @param element defines the DOM element to promote
  31009. */
  31010. static RequestFullscreen(element: HTMLElement): void;
  31011. /**
  31012. * Asks the browser to exit fullscreen mode
  31013. */
  31014. static ExitFullscreen(): void;
  31015. /**
  31016. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31017. * @param url define the url we are trying
  31018. * @param element define the dom element where to configure the cors policy
  31019. */
  31020. static SetCorsBehavior(url: string | string[], element: {
  31021. crossOrigin: string | null;
  31022. }): void;
  31023. /**
  31024. * Removes unwanted characters from an url
  31025. * @param url defines the url to clean
  31026. * @returns the cleaned url
  31027. */
  31028. static CleanUrl(url: string): string;
  31029. /**
  31030. * Gets or sets a function used to pre-process url before using them to load assets
  31031. */
  31032. static PreprocessUrl: (url: string) => string;
  31033. /**
  31034. * Loads an image as an HTMLImageElement.
  31035. * @param input url string, ArrayBuffer, or Blob to load
  31036. * @param onLoad callback called when the image successfully loads
  31037. * @param onError callback called when the image fails to load
  31038. * @param offlineProvider offline provider for caching
  31039. * @returns the HTMLImageElement of the loaded image
  31040. */
  31041. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31042. /**
  31043. * Loads a file
  31044. * @param url url string, ArrayBuffer, or Blob to load
  31045. * @param onSuccess callback called when the file successfully loads
  31046. * @param onProgress callback called while file is loading (if the server supports this mode)
  31047. * @param offlineProvider defines the offline provider for caching
  31048. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31049. * @param onError callback called when the file fails to load
  31050. * @returns a file request object
  31051. */
  31052. 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;
  31053. /**
  31054. * Load a script (identified by an url). When the url returns, the
  31055. * content of this file is added into a new script element, attached to the DOM (body element)
  31056. * @param scriptUrl defines the url of the script to laod
  31057. * @param onSuccess defines the callback called when the script is loaded
  31058. * @param onError defines the callback to call if an error occurs
  31059. */
  31060. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31061. /**
  31062. * Loads a file from a blob
  31063. * @param fileToLoad defines the blob to use
  31064. * @param callback defines the callback to call when data is loaded
  31065. * @param progressCallback defines the callback to call during loading process
  31066. * @returns a file request object
  31067. */
  31068. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31069. /**
  31070. * Loads a file
  31071. * @param fileToLoad defines the file to load
  31072. * @param callback defines the callback to call when data is loaded
  31073. * @param progressCallBack defines the callback to call during loading process
  31074. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31075. * @returns a file request object
  31076. */
  31077. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31078. /**
  31079. * Creates a data url from a given string content
  31080. * @param content defines the content to convert
  31081. * @returns the new data url link
  31082. */
  31083. static FileAsURL(content: string): string;
  31084. /**
  31085. * Format the given number to a specific decimal format
  31086. * @param value defines the number to format
  31087. * @param decimals defines the number of decimals to use
  31088. * @returns the formatted string
  31089. */
  31090. static Format(value: number, decimals?: number): string;
  31091. /**
  31092. * Checks if a given vector is inside a specific range
  31093. * @param v defines the vector to test
  31094. * @param min defines the minimum range
  31095. * @param max defines the maximum range
  31096. */
  31097. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31098. /**
  31099. * Tries to copy an object by duplicating every property
  31100. * @param source defines the source object
  31101. * @param destination defines the target object
  31102. * @param doNotCopyList defines a list of properties to avoid
  31103. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31104. */
  31105. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31106. /**
  31107. * Gets a boolean indicating if the given object has no own property
  31108. * @param obj defines the object to test
  31109. * @returns true if object has no own property
  31110. */
  31111. static IsEmpty(obj: any): boolean;
  31112. /**
  31113. * Function used to register events at window level
  31114. * @param events defines the events to register
  31115. */
  31116. static RegisterTopRootEvents(events: {
  31117. name: string;
  31118. handler: Nullable<(e: FocusEvent) => any>;
  31119. }[]): void;
  31120. /**
  31121. * Function used to unregister events from window level
  31122. * @param events defines the events to unregister
  31123. */
  31124. static UnregisterTopRootEvents(events: {
  31125. name: string;
  31126. handler: Nullable<(e: FocusEvent) => any>;
  31127. }[]): void;
  31128. /**
  31129. * @ignore
  31130. */
  31131. static _ScreenshotCanvas: HTMLCanvasElement;
  31132. /**
  31133. * Dumps the current bound framebuffer
  31134. * @param width defines the rendering width
  31135. * @param height defines the rendering height
  31136. * @param engine defines the hosting engine
  31137. * @param successCallback defines the callback triggered once the data are available
  31138. * @param mimeType defines the mime type of the result
  31139. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31140. */
  31141. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31142. /**
  31143. * Converts the canvas data to blob.
  31144. * This acts as a polyfill for browsers not supporting the to blob function.
  31145. * @param canvas Defines the canvas to extract the data from
  31146. * @param successCallback Defines the callback triggered once the data are available
  31147. * @param mimeType Defines the mime type of the result
  31148. */
  31149. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31150. /**
  31151. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31152. * @param successCallback defines the callback triggered once the data are available
  31153. * @param mimeType defines the mime type of the result
  31154. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31155. */
  31156. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31157. /**
  31158. * Downloads a blob in the browser
  31159. * @param blob defines the blob to download
  31160. * @param fileName defines the name of the downloaded file
  31161. */
  31162. static Download(blob: Blob, fileName: string): void;
  31163. /**
  31164. * Captures a screenshot of the current rendering
  31165. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31166. * @param engine defines the rendering engine
  31167. * @param camera defines the source camera
  31168. * @param size This parameter can be set to a single number or to an object with the
  31169. * following (optional) properties: precision, width, height. If a single number is passed,
  31170. * it will be used for both width and height. If an object is passed, the screenshot size
  31171. * will be derived from the parameters. The precision property is a multiplier allowing
  31172. * rendering at a higher or lower resolution
  31173. * @param successCallback defines the callback receives a single parameter which contains the
  31174. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31175. * src parameter of an <img> to display it
  31176. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31177. * Check your browser for supported MIME types
  31178. */
  31179. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31180. /**
  31181. * Generates an image screenshot from the specified camera.
  31182. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31183. * @param engine The engine to use for rendering
  31184. * @param camera The camera to use for rendering
  31185. * @param size This parameter can be set to a single number or to an object with the
  31186. * following (optional) properties: precision, width, height. If a single number is passed,
  31187. * it will be used for both width and height. If an object is passed, the screenshot size
  31188. * will be derived from the parameters. The precision property is a multiplier allowing
  31189. * rendering at a higher or lower resolution
  31190. * @param successCallback The callback receives a single parameter which contains the
  31191. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31192. * src parameter of an <img> to display it
  31193. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31194. * Check your browser for supported MIME types
  31195. * @param samples Texture samples (default: 1)
  31196. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31197. * @param fileName A name for for the downloaded file.
  31198. */
  31199. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31200. /**
  31201. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31202. * Be aware Math.random() could cause collisions, but:
  31203. * "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"
  31204. * @returns a pseudo random id
  31205. */
  31206. static RandomId(): string;
  31207. /**
  31208. * Test if the given uri is a base64 string
  31209. * @param uri The uri to test
  31210. * @return True if the uri is a base64 string or false otherwise
  31211. */
  31212. static IsBase64(uri: string): boolean;
  31213. /**
  31214. * Decode the given base64 uri.
  31215. * @param uri The uri to decode
  31216. * @return The decoded base64 data.
  31217. */
  31218. static DecodeBase64(uri: string): ArrayBuffer;
  31219. /**
  31220. * No log
  31221. */
  31222. static readonly NoneLogLevel: number;
  31223. /**
  31224. * Only message logs
  31225. */
  31226. static readonly MessageLogLevel: number;
  31227. /**
  31228. * Only warning logs
  31229. */
  31230. static readonly WarningLogLevel: number;
  31231. /**
  31232. * Only error logs
  31233. */
  31234. static readonly ErrorLogLevel: number;
  31235. /**
  31236. * All logs
  31237. */
  31238. static readonly AllLogLevel: number;
  31239. /**
  31240. * Gets a value indicating the number of loading errors
  31241. * @ignorenaming
  31242. */
  31243. static readonly errorsCount: number;
  31244. /**
  31245. * Callback called when a new log is added
  31246. */
  31247. static OnNewCacheEntry: (entry: string) => void;
  31248. /**
  31249. * Log a message to the console
  31250. * @param message defines the message to log
  31251. */
  31252. static Log(message: string): void;
  31253. /**
  31254. * Write a warning message to the console
  31255. * @param message defines the message to log
  31256. */
  31257. static Warn(message: string): void;
  31258. /**
  31259. * Write an error message to the console
  31260. * @param message defines the message to log
  31261. */
  31262. static Error(message: string): void;
  31263. /**
  31264. * Gets current log cache (list of logs)
  31265. */
  31266. static readonly LogCache: string;
  31267. /**
  31268. * Clears the log cache
  31269. */
  31270. static ClearLogCache(): void;
  31271. /**
  31272. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31273. */
  31274. static LogLevels: number;
  31275. /**
  31276. * Checks if the loaded document was accessed via `file:`-Protocol.
  31277. * @returns boolean
  31278. */
  31279. static IsFileURL(): boolean;
  31280. /**
  31281. * Checks if the window object exists
  31282. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31283. */
  31284. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31285. /**
  31286. * No performance log
  31287. */
  31288. static readonly PerformanceNoneLogLevel: number;
  31289. /**
  31290. * Use user marks to log performance
  31291. */
  31292. static readonly PerformanceUserMarkLogLevel: number;
  31293. /**
  31294. * Log performance to the console
  31295. */
  31296. static readonly PerformanceConsoleLogLevel: number;
  31297. private static _performance;
  31298. /**
  31299. * Sets the current performance log level
  31300. */
  31301. static PerformanceLogLevel: number;
  31302. private static _StartPerformanceCounterDisabled;
  31303. private static _EndPerformanceCounterDisabled;
  31304. private static _StartUserMark;
  31305. private static _EndUserMark;
  31306. private static _StartPerformanceConsole;
  31307. private static _EndPerformanceConsole;
  31308. /**
  31309. * Injects the @see CustomRequestHeaders into the given request
  31310. * @param request the request that should be used for injection
  31311. */
  31312. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31313. /**
  31314. * Starts a performance counter
  31315. */
  31316. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31317. /**
  31318. * Ends a specific performance coutner
  31319. */
  31320. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31321. /**
  31322. * Gets either window.performance.now() if supported or Date.now() else
  31323. */
  31324. static readonly Now: number;
  31325. /**
  31326. * This method will return the name of the class used to create the instance of the given object.
  31327. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31328. * @param object the object to get the class name from
  31329. * @param isType defines if the object is actually a type
  31330. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31331. */
  31332. static GetClassName(object: any, isType?: boolean): string;
  31333. /**
  31334. * Gets the first element of an array satisfying a given predicate
  31335. * @param array defines the array to browse
  31336. * @param predicate defines the predicate to use
  31337. * @returns null if not found or the element
  31338. */
  31339. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31340. /**
  31341. * This method will return the name of the full name of the class, including its owning module (if any).
  31342. * 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).
  31343. * @param object the object to get the class name from
  31344. * @param isType defines if the object is actually a type
  31345. * @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.
  31346. * @ignorenaming
  31347. */
  31348. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31349. /**
  31350. * Returns a promise that resolves after the given amount of time.
  31351. * @param delay Number of milliseconds to delay
  31352. * @returns Promise that resolves after the given amount of time
  31353. */
  31354. static DelayAsync(delay: number): Promise<void>;
  31355. /**
  31356. * Gets the current gradient from an array of IValueGradient
  31357. * @param ratio defines the current ratio to get
  31358. * @param gradients defines the array of IValueGradient
  31359. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31360. */
  31361. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31362. }
  31363. /**
  31364. * This class is used to track a performance counter which is number based.
  31365. * The user has access to many properties which give statistics of different nature.
  31366. *
  31367. * The implementer can track two kinds of Performance Counter: time and count.
  31368. * 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.
  31369. * 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.
  31370. */
  31371. export class PerfCounter {
  31372. /**
  31373. * Gets or sets a global boolean to turn on and off all the counters
  31374. */
  31375. static Enabled: boolean;
  31376. /**
  31377. * Returns the smallest value ever
  31378. */
  31379. readonly min: number;
  31380. /**
  31381. * Returns the biggest value ever
  31382. */
  31383. readonly max: number;
  31384. /**
  31385. * Returns the average value since the performance counter is running
  31386. */
  31387. readonly average: number;
  31388. /**
  31389. * Returns the average value of the last second the counter was monitored
  31390. */
  31391. readonly lastSecAverage: number;
  31392. /**
  31393. * Returns the current value
  31394. */
  31395. readonly current: number;
  31396. /**
  31397. * Gets the accumulated total
  31398. */
  31399. readonly total: number;
  31400. /**
  31401. * Gets the total value count
  31402. */
  31403. readonly count: number;
  31404. /**
  31405. * Creates a new counter
  31406. */
  31407. constructor();
  31408. /**
  31409. * Call this method to start monitoring a new frame.
  31410. * 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.
  31411. */
  31412. fetchNewFrame(): void;
  31413. /**
  31414. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31415. * @param newCount the count value to add to the monitored count
  31416. * @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.
  31417. */
  31418. addCount(newCount: number, fetchResult: boolean): void;
  31419. /**
  31420. * Start monitoring this performance counter
  31421. */
  31422. beginMonitoring(): void;
  31423. /**
  31424. * Compute the time lapsed since the previous beginMonitoring() call.
  31425. * @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
  31426. */
  31427. endMonitoring(newFrame?: boolean): void;
  31428. private _fetchResult;
  31429. private _startMonitoringTime;
  31430. private _min;
  31431. private _max;
  31432. private _average;
  31433. private _current;
  31434. private _totalValueCount;
  31435. private _totalAccumulated;
  31436. private _lastSecAverage;
  31437. private _lastSecAccumulated;
  31438. private _lastSecTime;
  31439. private _lastSecValueCount;
  31440. }
  31441. /**
  31442. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31443. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31444. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31445. * @param name The name of the class, case should be preserved
  31446. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31447. */
  31448. export function className(name: string, module?: string): (target: Object) => void;
  31449. /**
  31450. * An implementation of a loop for asynchronous functions.
  31451. */
  31452. export class AsyncLoop {
  31453. /**
  31454. * Defines the number of iterations for the loop
  31455. */
  31456. iterations: number;
  31457. /**
  31458. * Defines the current index of the loop.
  31459. */
  31460. index: number;
  31461. private _done;
  31462. private _fn;
  31463. private _successCallback;
  31464. /**
  31465. * Constructor.
  31466. * @param iterations the number of iterations.
  31467. * @param func the function to run each iteration
  31468. * @param successCallback the callback that will be called upon succesful execution
  31469. * @param offset starting offset.
  31470. */
  31471. constructor(
  31472. /**
  31473. * Defines the number of iterations for the loop
  31474. */
  31475. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31476. /**
  31477. * Execute the next iteration. Must be called after the last iteration was finished.
  31478. */
  31479. executeNext(): void;
  31480. /**
  31481. * Break the loop and run the success callback.
  31482. */
  31483. breakLoop(): void;
  31484. /**
  31485. * Create and run an async loop.
  31486. * @param iterations the number of iterations.
  31487. * @param fn the function to run each iteration
  31488. * @param successCallback the callback that will be called upon succesful execution
  31489. * @param offset starting offset.
  31490. * @returns the created async loop object
  31491. */
  31492. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31493. /**
  31494. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31495. * @param iterations total number of iterations
  31496. * @param syncedIterations number of synchronous iterations in each async iteration.
  31497. * @param fn the function to call each iteration.
  31498. * @param callback a success call back that will be called when iterating stops.
  31499. * @param breakFunction a break condition (optional)
  31500. * @param timeout timeout settings for the setTimeout function. default - 0.
  31501. * @returns the created async loop object
  31502. */
  31503. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31504. }
  31505. }
  31506. declare module "babylonjs/Collisions/collisionCoordinator" {
  31507. import { Nullable } from "babylonjs/types";
  31508. import { Scene } from "babylonjs/scene";
  31509. import { Vector3 } from "babylonjs/Maths/math";
  31510. import { Collider } from "babylonjs/Collisions/collider";
  31511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31512. /** @hidden */
  31513. export interface ICollisionCoordinator {
  31514. createCollider(): Collider;
  31515. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31516. init(scene: Scene): void;
  31517. }
  31518. /** @hidden */
  31519. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31520. private _scene;
  31521. private _scaledPosition;
  31522. private _scaledVelocity;
  31523. private _finalPosition;
  31524. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31525. createCollider(): Collider;
  31526. init(scene: Scene): void;
  31527. private _collideWithWorld;
  31528. }
  31529. }
  31530. declare module "babylonjs/Animations/animationGroup" {
  31531. import { Animatable } from "babylonjs/Animations/animatable";
  31532. import { Animation } from "babylonjs/Animations/animation";
  31533. import { Scene, IDisposable } from "babylonjs/scene";
  31534. import { Observable } from "babylonjs/Misc/observable";
  31535. import { Nullable } from "babylonjs/types";
  31536. /**
  31537. * This class defines the direct association between an animation and a target
  31538. */
  31539. export class TargetedAnimation {
  31540. /**
  31541. * Animation to perform
  31542. */
  31543. animation: Animation;
  31544. /**
  31545. * Target to animate
  31546. */
  31547. target: any;
  31548. }
  31549. /**
  31550. * Use this class to create coordinated animations on multiple targets
  31551. */
  31552. export class AnimationGroup implements IDisposable {
  31553. /** The name of the animation group */
  31554. name: string;
  31555. private _scene;
  31556. private _targetedAnimations;
  31557. private _animatables;
  31558. private _from;
  31559. private _to;
  31560. private _isStarted;
  31561. private _isPaused;
  31562. private _speedRatio;
  31563. /**
  31564. * Gets or sets the unique id of the node
  31565. */
  31566. uniqueId: number;
  31567. /**
  31568. * This observable will notify when one animation have ended
  31569. */
  31570. onAnimationEndObservable: Observable<TargetedAnimation>;
  31571. /**
  31572. * Observer raised when one animation loops
  31573. */
  31574. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31575. /**
  31576. * This observable will notify when all animations have ended.
  31577. */
  31578. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31579. /**
  31580. * This observable will notify when all animations have paused.
  31581. */
  31582. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31583. /**
  31584. * This observable will notify when all animations are playing.
  31585. */
  31586. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31587. /**
  31588. * Gets the first frame
  31589. */
  31590. readonly from: number;
  31591. /**
  31592. * Gets the last frame
  31593. */
  31594. readonly to: number;
  31595. /**
  31596. * Define if the animations are started
  31597. */
  31598. readonly isStarted: boolean;
  31599. /**
  31600. * Gets a value indicating that the current group is playing
  31601. */
  31602. readonly isPlaying: boolean;
  31603. /**
  31604. * Gets or sets the speed ratio to use for all animations
  31605. */
  31606. /**
  31607. * Gets or sets the speed ratio to use for all animations
  31608. */
  31609. speedRatio: number;
  31610. /**
  31611. * Gets the targeted animations for this animation group
  31612. */
  31613. readonly targetedAnimations: Array<TargetedAnimation>;
  31614. /**
  31615. * returning the list of animatables controlled by this animation group.
  31616. */
  31617. readonly animatables: Array<Animatable>;
  31618. /**
  31619. * Instantiates a new Animation Group.
  31620. * This helps managing several animations at once.
  31621. * @see http://doc.babylonjs.com/how_to/group
  31622. * @param name Defines the name of the group
  31623. * @param scene Defines the scene the group belongs to
  31624. */
  31625. constructor(
  31626. /** The name of the animation group */
  31627. name: string, scene?: Nullable<Scene>);
  31628. /**
  31629. * Add an animation (with its target) in the group
  31630. * @param animation defines the animation we want to add
  31631. * @param target defines the target of the animation
  31632. * @returns the TargetedAnimation object
  31633. */
  31634. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31635. /**
  31636. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31637. * It can add constant keys at begin or end
  31638. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31639. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31640. * @returns the animation group
  31641. */
  31642. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31643. /**
  31644. * Start all animations on given targets
  31645. * @param loop defines if animations must loop
  31646. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31647. * @param from defines the from key (optional)
  31648. * @param to defines the to key (optional)
  31649. * @returns the current animation group
  31650. */
  31651. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31652. /**
  31653. * Pause all animations
  31654. * @returns the animation group
  31655. */
  31656. pause(): AnimationGroup;
  31657. /**
  31658. * Play all animations to initial state
  31659. * This function will start() the animations if they were not started or will restart() them if they were paused
  31660. * @param loop defines if animations must loop
  31661. * @returns the animation group
  31662. */
  31663. play(loop?: boolean): AnimationGroup;
  31664. /**
  31665. * Reset all animations to initial state
  31666. * @returns the animation group
  31667. */
  31668. reset(): AnimationGroup;
  31669. /**
  31670. * Restart animations from key 0
  31671. * @returns the animation group
  31672. */
  31673. restart(): AnimationGroup;
  31674. /**
  31675. * Stop all animations
  31676. * @returns the animation group
  31677. */
  31678. stop(): AnimationGroup;
  31679. /**
  31680. * Set animation weight for all animatables
  31681. * @param weight defines the weight to use
  31682. * @return the animationGroup
  31683. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31684. */
  31685. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31686. /**
  31687. * Synchronize and normalize all animatables with a source animatable
  31688. * @param root defines the root animatable to synchronize with
  31689. * @return the animationGroup
  31690. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31691. */
  31692. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31693. /**
  31694. * Goes to a specific frame in this animation group
  31695. * @param frame the frame number to go to
  31696. * @return the animationGroup
  31697. */
  31698. goToFrame(frame: number): AnimationGroup;
  31699. /**
  31700. * Dispose all associated resources
  31701. */
  31702. dispose(): void;
  31703. private _checkAnimationGroupEnded;
  31704. /**
  31705. * Clone the current animation group and returns a copy
  31706. * @param newName defines the name of the new group
  31707. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31708. * @returns the new aniamtion group
  31709. */
  31710. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31711. /**
  31712. * Returns a new AnimationGroup object parsed from the source provided.
  31713. * @param parsedAnimationGroup defines the source
  31714. * @param scene defines the scene that will receive the animationGroup
  31715. * @returns a new AnimationGroup
  31716. */
  31717. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31718. /**
  31719. * Returns the string "AnimationGroup"
  31720. * @returns "AnimationGroup"
  31721. */
  31722. getClassName(): string;
  31723. /**
  31724. * Creates a detailled string about the object
  31725. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31726. * @returns a string representing the object
  31727. */
  31728. toString(fullDetails?: boolean): string;
  31729. }
  31730. }
  31731. declare module "babylonjs/scene" {
  31732. import { Nullable } from "babylonjs/types";
  31733. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31734. import { Observable } from "babylonjs/Misc/observable";
  31735. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31736. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31737. import { Geometry } from "babylonjs/Meshes/geometry";
  31738. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31741. import { Mesh } from "babylonjs/Meshes/mesh";
  31742. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31743. import { Bone } from "babylonjs/Bones/bone";
  31744. import { Skeleton } from "babylonjs/Bones/skeleton";
  31745. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31746. import { Camera } from "babylonjs/Cameras/camera";
  31747. import { AbstractScene } from "babylonjs/abstractScene";
  31748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31749. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31750. import { Material } from "babylonjs/Materials/material";
  31751. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31752. import { Effect } from "babylonjs/Materials/effect";
  31753. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31754. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31755. import { Light } from "babylonjs/Lights/light";
  31756. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31757. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31758. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31759. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31760. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31761. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31762. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31763. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31764. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31765. import { Engine } from "babylonjs/Engines/engine";
  31766. import { Node } from "babylonjs/node";
  31767. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31768. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31769. import { Ray } from "babylonjs/Culling/ray";
  31770. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31771. import { Animation } from "babylonjs/Animations/animation";
  31772. import { Animatable } from "babylonjs/Animations/animatable";
  31773. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31774. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31775. import { Collider } from "babylonjs/Collisions/collider";
  31776. /**
  31777. * Define an interface for all classes that will hold resources
  31778. */
  31779. export interface IDisposable {
  31780. /**
  31781. * Releases all held resources
  31782. */
  31783. dispose(): void;
  31784. }
  31785. /** Interface defining initialization parameters for Scene class */
  31786. export interface SceneOptions {
  31787. /**
  31788. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31789. * It will improve performance when the number of geometries becomes important.
  31790. */
  31791. useGeometryUniqueIdsMap?: boolean;
  31792. /**
  31793. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31794. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31795. */
  31796. useMaterialMeshMap?: boolean;
  31797. /**
  31798. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31799. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31800. */
  31801. useClonedMeshhMap?: boolean;
  31802. }
  31803. /**
  31804. * Represents a scene to be rendered by the engine.
  31805. * @see http://doc.babylonjs.com/features/scene
  31806. */
  31807. export class Scene extends AbstractScene implements IAnimatable {
  31808. private static _uniqueIdCounter;
  31809. /** The fog is deactivated */
  31810. static readonly FOGMODE_NONE: number;
  31811. /** The fog density is following an exponential function */
  31812. static readonly FOGMODE_EXP: number;
  31813. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31814. static readonly FOGMODE_EXP2: number;
  31815. /** The fog density is following a linear function. */
  31816. static readonly FOGMODE_LINEAR: number;
  31817. /**
  31818. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31819. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31820. */
  31821. static MinDeltaTime: number;
  31822. /**
  31823. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31824. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31825. */
  31826. static MaxDeltaTime: number;
  31827. /**
  31828. * Factory used to create the default material.
  31829. * @param name The name of the material to create
  31830. * @param scene The scene to create the material for
  31831. * @returns The default material
  31832. */
  31833. static DefaultMaterialFactory(scene: Scene): Material;
  31834. /**
  31835. * Factory used to create the a collision coordinator.
  31836. * @returns The collision coordinator
  31837. */
  31838. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31839. /** @hidden */
  31840. readonly _isScene: boolean;
  31841. /**
  31842. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31843. */
  31844. autoClear: boolean;
  31845. /**
  31846. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31847. */
  31848. autoClearDepthAndStencil: boolean;
  31849. /**
  31850. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31851. */
  31852. clearColor: Color4;
  31853. /**
  31854. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31855. */
  31856. ambientColor: Color3;
  31857. /** @hidden */
  31858. _environmentBRDFTexture: BaseTexture;
  31859. /** @hidden */
  31860. protected _environmentTexture: Nullable<BaseTexture>;
  31861. /**
  31862. * Texture used in all pbr material as the reflection texture.
  31863. * As in the majority of the scene they are the same (exception for multi room and so on),
  31864. * this is easier to reference from here than from all the materials.
  31865. */
  31866. /**
  31867. * Texture used in all pbr material as the reflection texture.
  31868. * As in the majority of the scene they are the same (exception for multi room and so on),
  31869. * this is easier to set here than in all the materials.
  31870. */
  31871. environmentTexture: Nullable<BaseTexture>;
  31872. /** @hidden */
  31873. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31874. /**
  31875. * Default image processing configuration used either in the rendering
  31876. * Forward main pass or through the imageProcessingPostProcess if present.
  31877. * As in the majority of the scene they are the same (exception for multi camera),
  31878. * this is easier to reference from here than from all the materials and post process.
  31879. *
  31880. * No setter as we it is a shared configuration, you can set the values instead.
  31881. */
  31882. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31883. private _forceWireframe;
  31884. /**
  31885. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31886. */
  31887. forceWireframe: boolean;
  31888. private _forcePointsCloud;
  31889. /**
  31890. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31891. */
  31892. forcePointsCloud: boolean;
  31893. /**
  31894. * Gets or sets the active clipplane 1
  31895. */
  31896. clipPlane: Nullable<Plane>;
  31897. /**
  31898. * Gets or sets the active clipplane 2
  31899. */
  31900. clipPlane2: Nullable<Plane>;
  31901. /**
  31902. * Gets or sets the active clipplane 3
  31903. */
  31904. clipPlane3: Nullable<Plane>;
  31905. /**
  31906. * Gets or sets the active clipplane 4
  31907. */
  31908. clipPlane4: Nullable<Plane>;
  31909. /**
  31910. * Gets or sets a boolean indicating if animations are enabled
  31911. */
  31912. animationsEnabled: boolean;
  31913. private _animationPropertiesOverride;
  31914. /**
  31915. * Gets or sets the animation properties override
  31916. */
  31917. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31918. /**
  31919. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31920. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31921. */
  31922. useConstantAnimationDeltaTime: boolean;
  31923. /**
  31924. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31925. * Please note that it requires to run a ray cast through the scene on every frame
  31926. */
  31927. constantlyUpdateMeshUnderPointer: boolean;
  31928. /**
  31929. * Defines the HTML cursor to use when hovering over interactive elements
  31930. */
  31931. hoverCursor: string;
  31932. /**
  31933. * Defines the HTML default cursor to use (empty by default)
  31934. */
  31935. defaultCursor: string;
  31936. /**
  31937. * This is used to call preventDefault() on pointer down
  31938. * in order to block unwanted artifacts like system double clicks
  31939. */
  31940. preventDefaultOnPointerDown: boolean;
  31941. /**
  31942. * This is used to call preventDefault() on pointer up
  31943. * in order to block unwanted artifacts like system double clicks
  31944. */
  31945. preventDefaultOnPointerUp: boolean;
  31946. /**
  31947. * Gets or sets user defined metadata
  31948. */
  31949. metadata: any;
  31950. /**
  31951. * For internal use only. Please do not use.
  31952. */
  31953. reservedDataStore: any;
  31954. /**
  31955. * Gets the name of the plugin used to load this scene (null by default)
  31956. */
  31957. loadingPluginName: string;
  31958. /**
  31959. * Use this array to add regular expressions used to disable offline support for specific urls
  31960. */
  31961. disableOfflineSupportExceptionRules: RegExp[];
  31962. /**
  31963. * An event triggered when the scene is disposed.
  31964. */
  31965. onDisposeObservable: Observable<Scene>;
  31966. private _onDisposeObserver;
  31967. /** Sets a function to be executed when this scene is disposed. */
  31968. onDispose: () => void;
  31969. /**
  31970. * An event triggered before rendering the scene (right after animations and physics)
  31971. */
  31972. onBeforeRenderObservable: Observable<Scene>;
  31973. private _onBeforeRenderObserver;
  31974. /** Sets a function to be executed before rendering this scene */
  31975. beforeRender: Nullable<() => void>;
  31976. /**
  31977. * An event triggered after rendering the scene
  31978. */
  31979. onAfterRenderObservable: Observable<Scene>;
  31980. private _onAfterRenderObserver;
  31981. /** Sets a function to be executed after rendering this scene */
  31982. afterRender: Nullable<() => void>;
  31983. /**
  31984. * An event triggered before animating the scene
  31985. */
  31986. onBeforeAnimationsObservable: Observable<Scene>;
  31987. /**
  31988. * An event triggered after animations processing
  31989. */
  31990. onAfterAnimationsObservable: Observable<Scene>;
  31991. /**
  31992. * An event triggered before draw calls are ready to be sent
  31993. */
  31994. onBeforeDrawPhaseObservable: Observable<Scene>;
  31995. /**
  31996. * An event triggered after draw calls have been sent
  31997. */
  31998. onAfterDrawPhaseObservable: Observable<Scene>;
  31999. /**
  32000. * An event triggered when the scene is ready
  32001. */
  32002. onReadyObservable: Observable<Scene>;
  32003. /**
  32004. * An event triggered before rendering a camera
  32005. */
  32006. onBeforeCameraRenderObservable: Observable<Camera>;
  32007. private _onBeforeCameraRenderObserver;
  32008. /** Sets a function to be executed before rendering a camera*/
  32009. beforeCameraRender: () => void;
  32010. /**
  32011. * An event triggered after rendering a camera
  32012. */
  32013. onAfterCameraRenderObservable: Observable<Camera>;
  32014. private _onAfterCameraRenderObserver;
  32015. /** Sets a function to be executed after rendering a camera*/
  32016. afterCameraRender: () => void;
  32017. /**
  32018. * An event triggered when active meshes evaluation is about to start
  32019. */
  32020. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32021. /**
  32022. * An event triggered when active meshes evaluation is done
  32023. */
  32024. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32025. /**
  32026. * An event triggered when particles rendering is about to start
  32027. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32028. */
  32029. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32030. /**
  32031. * An event triggered when particles rendering is done
  32032. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32033. */
  32034. onAfterParticlesRenderingObservable: Observable<Scene>;
  32035. /**
  32036. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32037. */
  32038. onDataLoadedObservable: Observable<Scene>;
  32039. /**
  32040. * An event triggered when a camera is created
  32041. */
  32042. onNewCameraAddedObservable: Observable<Camera>;
  32043. /**
  32044. * An event triggered when a camera is removed
  32045. */
  32046. onCameraRemovedObservable: Observable<Camera>;
  32047. /**
  32048. * An event triggered when a light is created
  32049. */
  32050. onNewLightAddedObservable: Observable<Light>;
  32051. /**
  32052. * An event triggered when a light is removed
  32053. */
  32054. onLightRemovedObservable: Observable<Light>;
  32055. /**
  32056. * An event triggered when a geometry is created
  32057. */
  32058. onNewGeometryAddedObservable: Observable<Geometry>;
  32059. /**
  32060. * An event triggered when a geometry is removed
  32061. */
  32062. onGeometryRemovedObservable: Observable<Geometry>;
  32063. /**
  32064. * An event triggered when a transform node is created
  32065. */
  32066. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32067. /**
  32068. * An event triggered when a transform node is removed
  32069. */
  32070. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32071. /**
  32072. * An event triggered when a mesh is created
  32073. */
  32074. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32075. /**
  32076. * An event triggered when a mesh is removed
  32077. */
  32078. onMeshRemovedObservable: Observable<AbstractMesh>;
  32079. /**
  32080. * An event triggered when a material is created
  32081. */
  32082. onNewMaterialAddedObservable: Observable<Material>;
  32083. /**
  32084. * An event triggered when a material is removed
  32085. */
  32086. onMaterialRemovedObservable: Observable<Material>;
  32087. /**
  32088. * An event triggered when a texture is created
  32089. */
  32090. onNewTextureAddedObservable: Observable<BaseTexture>;
  32091. /**
  32092. * An event triggered when a texture is removed
  32093. */
  32094. onTextureRemovedObservable: Observable<BaseTexture>;
  32095. /**
  32096. * An event triggered when render targets are about to be rendered
  32097. * Can happen multiple times per frame.
  32098. */
  32099. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32100. /**
  32101. * An event triggered when render targets were rendered.
  32102. * Can happen multiple times per frame.
  32103. */
  32104. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32105. /**
  32106. * An event triggered before calculating deterministic simulation step
  32107. */
  32108. onBeforeStepObservable: Observable<Scene>;
  32109. /**
  32110. * An event triggered after calculating deterministic simulation step
  32111. */
  32112. onAfterStepObservable: Observable<Scene>;
  32113. /**
  32114. * An event triggered when the activeCamera property is updated
  32115. */
  32116. onActiveCameraChanged: Observable<Scene>;
  32117. /**
  32118. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32119. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32120. * 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)
  32121. */
  32122. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32123. /**
  32124. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32125. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32126. * 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)
  32127. */
  32128. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32129. /**
  32130. * This Observable will when a mesh has been imported into the scene.
  32131. */
  32132. onMeshImportedObservable: Observable<AbstractMesh>;
  32133. /**
  32134. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32135. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32136. */
  32137. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32138. /** @hidden */
  32139. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32140. /**
  32141. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32142. */
  32143. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32144. /**
  32145. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32146. */
  32147. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32148. /**
  32149. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32150. */
  32151. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32152. private _onPointerMove;
  32153. private _onPointerDown;
  32154. private _onPointerUp;
  32155. /** Callback called when a pointer move is detected */
  32156. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32157. /** Callback called when a pointer down is detected */
  32158. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32159. /** Callback called when a pointer up is detected */
  32160. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32161. /** Callback called when a pointer pick is detected */
  32162. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32163. /**
  32164. * 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).
  32165. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32166. */
  32167. onPrePointerObservable: Observable<PointerInfoPre>;
  32168. /**
  32169. * Observable event triggered each time an input event is received from the rendering canvas
  32170. */
  32171. onPointerObservable: Observable<PointerInfo>;
  32172. /**
  32173. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32174. */
  32175. readonly unTranslatedPointer: Vector2;
  32176. /** The distance in pixel that you have to move to prevent some events */
  32177. static DragMovementThreshold: number;
  32178. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32179. static LongPressDelay: number;
  32180. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32181. static DoubleClickDelay: number;
  32182. /** If you need to check double click without raising a single click at first click, enable this flag */
  32183. static ExclusiveDoubleClickMode: boolean;
  32184. private _initClickEvent;
  32185. private _initActionManager;
  32186. private _delayedSimpleClick;
  32187. private _delayedSimpleClickTimeout;
  32188. private _previousDelayedSimpleClickTimeout;
  32189. private _meshPickProceed;
  32190. private _previousButtonPressed;
  32191. private _currentPickResult;
  32192. private _previousPickResult;
  32193. private _totalPointersPressed;
  32194. private _doubleClickOccured;
  32195. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32196. cameraToUseForPointers: Nullable<Camera>;
  32197. private _pointerX;
  32198. private _pointerY;
  32199. private _unTranslatedPointerX;
  32200. private _unTranslatedPointerY;
  32201. private _startingPointerPosition;
  32202. private _previousStartingPointerPosition;
  32203. private _startingPointerTime;
  32204. private _previousStartingPointerTime;
  32205. private _pointerCaptures;
  32206. private _timeAccumulator;
  32207. private _currentStepId;
  32208. private _currentInternalStep;
  32209. /** @hidden */
  32210. _mirroredCameraPosition: Nullable<Vector3>;
  32211. /**
  32212. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32213. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32214. */
  32215. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32216. /**
  32217. * Observable event triggered each time an keyboard event is received from the hosting window
  32218. */
  32219. onKeyboardObservable: Observable<KeyboardInfo>;
  32220. private _onKeyDown;
  32221. private _onKeyUp;
  32222. private _onCanvasFocusObserver;
  32223. private _onCanvasBlurObserver;
  32224. private _useRightHandedSystem;
  32225. /**
  32226. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32227. */
  32228. useRightHandedSystem: boolean;
  32229. /**
  32230. * Sets the step Id used by deterministic lock step
  32231. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32232. * @param newStepId defines the step Id
  32233. */
  32234. setStepId(newStepId: number): void;
  32235. /**
  32236. * Gets the step Id used by deterministic lock step
  32237. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32238. * @returns the step Id
  32239. */
  32240. getStepId(): number;
  32241. /**
  32242. * Gets the internal step used by deterministic lock step
  32243. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32244. * @returns the internal step
  32245. */
  32246. getInternalStep(): number;
  32247. private _fogEnabled;
  32248. /**
  32249. * Gets or sets a boolean indicating if fog is enabled on this scene
  32250. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32251. * (Default is true)
  32252. */
  32253. fogEnabled: boolean;
  32254. private _fogMode;
  32255. /**
  32256. * Gets or sets the fog mode to use
  32257. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32258. * | mode | value |
  32259. * | --- | --- |
  32260. * | FOGMODE_NONE | 0 |
  32261. * | FOGMODE_EXP | 1 |
  32262. * | FOGMODE_EXP2 | 2 |
  32263. * | FOGMODE_LINEAR | 3 |
  32264. */
  32265. fogMode: number;
  32266. /**
  32267. * Gets or sets the fog color to use
  32268. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32269. * (Default is Color3(0.2, 0.2, 0.3))
  32270. */
  32271. fogColor: Color3;
  32272. /**
  32273. * Gets or sets the fog density to use
  32274. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32275. * (Default is 0.1)
  32276. */
  32277. fogDensity: number;
  32278. /**
  32279. * Gets or sets the fog start distance to use
  32280. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32281. * (Default is 0)
  32282. */
  32283. fogStart: number;
  32284. /**
  32285. * Gets or sets the fog end distance to use
  32286. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32287. * (Default is 1000)
  32288. */
  32289. fogEnd: number;
  32290. private _shadowsEnabled;
  32291. /**
  32292. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32293. */
  32294. shadowsEnabled: boolean;
  32295. private _lightsEnabled;
  32296. /**
  32297. * Gets or sets a boolean indicating if lights are enabled on this scene
  32298. */
  32299. lightsEnabled: boolean;
  32300. /** All of the active cameras added to this scene. */
  32301. activeCameras: Camera[];
  32302. private _activeCamera;
  32303. /** Gets or sets the current active camera */
  32304. activeCamera: Nullable<Camera>;
  32305. private _defaultMaterial;
  32306. /** The default material used on meshes when no material is affected */
  32307. /** The default material used on meshes when no material is affected */
  32308. defaultMaterial: Material;
  32309. private _texturesEnabled;
  32310. /**
  32311. * Gets or sets a boolean indicating if textures are enabled on this scene
  32312. */
  32313. texturesEnabled: boolean;
  32314. /**
  32315. * Gets or sets a boolean indicating if particles are enabled on this scene
  32316. */
  32317. particlesEnabled: boolean;
  32318. /**
  32319. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32320. */
  32321. spritesEnabled: boolean;
  32322. private _skeletonsEnabled;
  32323. /**
  32324. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32325. */
  32326. skeletonsEnabled: boolean;
  32327. /**
  32328. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32329. */
  32330. lensFlaresEnabled: boolean;
  32331. /**
  32332. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32333. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32334. */
  32335. collisionsEnabled: boolean;
  32336. private _collisionCoordinator;
  32337. /** @hidden */
  32338. readonly collisionCoordinator: ICollisionCoordinator;
  32339. /**
  32340. * Defines the gravity applied to this scene (used only for collisions)
  32341. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32342. */
  32343. gravity: Vector3;
  32344. /**
  32345. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32346. */
  32347. postProcessesEnabled: boolean;
  32348. /**
  32349. * The list of postprocesses added to the scene
  32350. */
  32351. postProcesses: PostProcess[];
  32352. /**
  32353. * Gets the current postprocess manager
  32354. */
  32355. postProcessManager: PostProcessManager;
  32356. /**
  32357. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32358. */
  32359. renderTargetsEnabled: boolean;
  32360. /**
  32361. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32362. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32363. */
  32364. dumpNextRenderTargets: boolean;
  32365. /**
  32366. * The list of user defined render targets added to the scene
  32367. */
  32368. customRenderTargets: RenderTargetTexture[];
  32369. /**
  32370. * Defines if texture loading must be delayed
  32371. * If true, textures will only be loaded when they need to be rendered
  32372. */
  32373. useDelayedTextureLoading: boolean;
  32374. /**
  32375. * Gets the list of meshes imported to the scene through SceneLoader
  32376. */
  32377. importedMeshesFiles: String[];
  32378. /**
  32379. * Gets or sets a boolean indicating if probes are enabled on this scene
  32380. */
  32381. probesEnabled: boolean;
  32382. /**
  32383. * Gets or sets the current offline provider to use to store scene data
  32384. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32385. */
  32386. offlineProvider: IOfflineProvider;
  32387. /**
  32388. * Gets or sets the action manager associated with the scene
  32389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32390. */
  32391. actionManager: AbstractActionManager;
  32392. private _meshesForIntersections;
  32393. /**
  32394. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32395. */
  32396. proceduralTexturesEnabled: boolean;
  32397. private _engine;
  32398. private _totalVertices;
  32399. /** @hidden */
  32400. _activeIndices: PerfCounter;
  32401. /** @hidden */
  32402. _activeParticles: PerfCounter;
  32403. /** @hidden */
  32404. _activeBones: PerfCounter;
  32405. private _animationRatio;
  32406. /** @hidden */
  32407. _animationTimeLast: number;
  32408. /** @hidden */
  32409. _animationTime: number;
  32410. /**
  32411. * Gets or sets a general scale for animation speed
  32412. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32413. */
  32414. animationTimeScale: number;
  32415. /** @hidden */
  32416. _cachedMaterial: Nullable<Material>;
  32417. /** @hidden */
  32418. _cachedEffect: Nullable<Effect>;
  32419. /** @hidden */
  32420. _cachedVisibility: Nullable<number>;
  32421. private _renderId;
  32422. private _frameId;
  32423. private _executeWhenReadyTimeoutId;
  32424. private _intermediateRendering;
  32425. private _viewUpdateFlag;
  32426. private _projectionUpdateFlag;
  32427. private _alternateViewUpdateFlag;
  32428. private _alternateProjectionUpdateFlag;
  32429. /** @hidden */
  32430. _toBeDisposed: Nullable<IDisposable>[];
  32431. private _activeRequests;
  32432. /** @hidden */
  32433. _pendingData: any[];
  32434. private _isDisposed;
  32435. /**
  32436. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32437. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32438. */
  32439. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32440. private _activeMeshes;
  32441. private _processedMaterials;
  32442. private _renderTargets;
  32443. /** @hidden */
  32444. _activeParticleSystems: SmartArray<IParticleSystem>;
  32445. private _activeSkeletons;
  32446. private _softwareSkinnedMeshes;
  32447. private _renderingManager;
  32448. /** @hidden */
  32449. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32450. private _transformMatrix;
  32451. private _sceneUbo;
  32452. private _alternateSceneUbo;
  32453. private _viewMatrix;
  32454. private _projectionMatrix;
  32455. private _alternateViewMatrix;
  32456. private _alternateProjectionMatrix;
  32457. private _alternateTransformMatrix;
  32458. private _useAlternateCameraConfiguration;
  32459. private _alternateRendering;
  32460. private _wheelEventName;
  32461. /** @hidden */
  32462. _forcedViewPosition: Nullable<Vector3>;
  32463. /** @hidden */
  32464. readonly _isAlternateRenderingEnabled: boolean;
  32465. private _frustumPlanes;
  32466. /**
  32467. * Gets the list of frustum planes (built from the active camera)
  32468. */
  32469. readonly frustumPlanes: Plane[];
  32470. /**
  32471. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32472. * This is useful if there are more lights that the maximum simulteanous authorized
  32473. */
  32474. requireLightSorting: boolean;
  32475. /** @hidden */
  32476. readonly useMaterialMeshMap: boolean;
  32477. /** @hidden */
  32478. readonly useClonedMeshhMap: boolean;
  32479. private _pointerOverMesh;
  32480. private _pickedDownMesh;
  32481. private _pickedUpMesh;
  32482. private _externalData;
  32483. private _uid;
  32484. /**
  32485. * @hidden
  32486. * Backing store of defined scene components.
  32487. */
  32488. _components: ISceneComponent[];
  32489. /**
  32490. * @hidden
  32491. * Backing store of defined scene components.
  32492. */
  32493. _serializableComponents: ISceneSerializableComponent[];
  32494. /**
  32495. * List of components to register on the next registration step.
  32496. */
  32497. private _transientComponents;
  32498. /**
  32499. * Registers the transient components if needed.
  32500. */
  32501. private _registerTransientComponents;
  32502. /**
  32503. * @hidden
  32504. * Add a component to the scene.
  32505. * Note that the ccomponent could be registered on th next frame if this is called after
  32506. * the register component stage.
  32507. * @param component Defines the component to add to the scene
  32508. */
  32509. _addComponent(component: ISceneComponent): void;
  32510. /**
  32511. * @hidden
  32512. * Gets a component from the scene.
  32513. * @param name defines the name of the component to retrieve
  32514. * @returns the component or null if not present
  32515. */
  32516. _getComponent(name: string): Nullable<ISceneComponent>;
  32517. /**
  32518. * @hidden
  32519. * Defines the actions happening before camera updates.
  32520. */
  32521. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32522. /**
  32523. * @hidden
  32524. * Defines the actions happening before clear the canvas.
  32525. */
  32526. _beforeClearStage: Stage<SimpleStageAction>;
  32527. /**
  32528. * @hidden
  32529. * Defines the actions when collecting render targets for the frame.
  32530. */
  32531. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32532. /**
  32533. * @hidden
  32534. * Defines the actions happening for one camera in the frame.
  32535. */
  32536. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32537. /**
  32538. * @hidden
  32539. * Defines the actions happening during the per mesh ready checks.
  32540. */
  32541. _isReadyForMeshStage: Stage<MeshStageAction>;
  32542. /**
  32543. * @hidden
  32544. * Defines the actions happening before evaluate active mesh checks.
  32545. */
  32546. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32547. /**
  32548. * @hidden
  32549. * Defines the actions happening during the evaluate sub mesh checks.
  32550. */
  32551. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32552. /**
  32553. * @hidden
  32554. * Defines the actions happening during the active mesh stage.
  32555. */
  32556. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32557. /**
  32558. * @hidden
  32559. * Defines the actions happening during the per camera render target step.
  32560. */
  32561. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32562. /**
  32563. * @hidden
  32564. * Defines the actions happening just before the active camera is drawing.
  32565. */
  32566. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32567. /**
  32568. * @hidden
  32569. * Defines the actions happening just before a render target is drawing.
  32570. */
  32571. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32572. /**
  32573. * @hidden
  32574. * Defines the actions happening just before a rendering group is drawing.
  32575. */
  32576. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32577. /**
  32578. * @hidden
  32579. * Defines the actions happening just before a mesh is drawing.
  32580. */
  32581. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32582. /**
  32583. * @hidden
  32584. * Defines the actions happening just after a mesh has been drawn.
  32585. */
  32586. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32587. /**
  32588. * @hidden
  32589. * Defines the actions happening just after a rendering group has been drawn.
  32590. */
  32591. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32592. /**
  32593. * @hidden
  32594. * Defines the actions happening just after the active camera has been drawn.
  32595. */
  32596. _afterCameraDrawStage: Stage<CameraStageAction>;
  32597. /**
  32598. * @hidden
  32599. * Defines the actions happening just after a render target has been drawn.
  32600. */
  32601. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32602. /**
  32603. * @hidden
  32604. * Defines the actions happening just after rendering all cameras and computing intersections.
  32605. */
  32606. _afterRenderStage: Stage<SimpleStageAction>;
  32607. /**
  32608. * @hidden
  32609. * Defines the actions happening when a pointer move event happens.
  32610. */
  32611. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32612. /**
  32613. * @hidden
  32614. * Defines the actions happening when a pointer down event happens.
  32615. */
  32616. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32617. /**
  32618. * @hidden
  32619. * Defines the actions happening when a pointer up event happens.
  32620. */
  32621. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32622. /**
  32623. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32624. */
  32625. private geometriesByUniqueId;
  32626. /**
  32627. * Creates a new Scene
  32628. * @param engine defines the engine to use to render this scene
  32629. * @param options defines the scene options
  32630. */
  32631. constructor(engine: Engine, options?: SceneOptions);
  32632. private _defaultMeshCandidates;
  32633. /**
  32634. * @hidden
  32635. */
  32636. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32637. private _defaultSubMeshCandidates;
  32638. /**
  32639. * @hidden
  32640. */
  32641. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32642. /**
  32643. * Sets the default candidate providers for the scene.
  32644. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32645. * and getCollidingSubMeshCandidates to their default function
  32646. */
  32647. setDefaultCandidateProviders(): void;
  32648. /**
  32649. * Gets the mesh that is currently under the pointer
  32650. */
  32651. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32652. /**
  32653. * Gets or sets the current on-screen X position of the pointer
  32654. */
  32655. pointerX: number;
  32656. /**
  32657. * Gets or sets the current on-screen Y position of the pointer
  32658. */
  32659. pointerY: number;
  32660. /**
  32661. * Gets the cached material (ie. the latest rendered one)
  32662. * @returns the cached material
  32663. */
  32664. getCachedMaterial(): Nullable<Material>;
  32665. /**
  32666. * Gets the cached effect (ie. the latest rendered one)
  32667. * @returns the cached effect
  32668. */
  32669. getCachedEffect(): Nullable<Effect>;
  32670. /**
  32671. * Gets the cached visibility state (ie. the latest rendered one)
  32672. * @returns the cached visibility state
  32673. */
  32674. getCachedVisibility(): Nullable<number>;
  32675. /**
  32676. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32677. * @param material defines the current material
  32678. * @param effect defines the current effect
  32679. * @param visibility defines the current visibility state
  32680. * @returns true if one parameter is not cached
  32681. */
  32682. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32683. /**
  32684. * Gets the engine associated with the scene
  32685. * @returns an Engine
  32686. */
  32687. getEngine(): Engine;
  32688. /**
  32689. * Gets the total number of vertices rendered per frame
  32690. * @returns the total number of vertices rendered per frame
  32691. */
  32692. getTotalVertices(): number;
  32693. /**
  32694. * Gets the performance counter for total vertices
  32695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32696. */
  32697. readonly totalVerticesPerfCounter: PerfCounter;
  32698. /**
  32699. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32700. * @returns the total number of active indices rendered per frame
  32701. */
  32702. getActiveIndices(): number;
  32703. /**
  32704. * Gets the performance counter for active indices
  32705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32706. */
  32707. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32708. /**
  32709. * Gets the total number of active particles rendered per frame
  32710. * @returns the total number of active particles rendered per frame
  32711. */
  32712. getActiveParticles(): number;
  32713. /**
  32714. * Gets the performance counter for active particles
  32715. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32716. */
  32717. readonly activeParticlesPerfCounter: PerfCounter;
  32718. /**
  32719. * Gets the total number of active bones rendered per frame
  32720. * @returns the total number of active bones rendered per frame
  32721. */
  32722. getActiveBones(): number;
  32723. /**
  32724. * Gets the performance counter for active bones
  32725. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32726. */
  32727. readonly activeBonesPerfCounter: PerfCounter;
  32728. /**
  32729. * Gets the array of active meshes
  32730. * @returns an array of AbstractMesh
  32731. */
  32732. getActiveMeshes(): SmartArray<AbstractMesh>;
  32733. /**
  32734. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32735. * @returns a number
  32736. */
  32737. getAnimationRatio(): number;
  32738. /**
  32739. * Gets an unique Id for the current render phase
  32740. * @returns a number
  32741. */
  32742. getRenderId(): number;
  32743. /**
  32744. * Gets an unique Id for the current frame
  32745. * @returns a number
  32746. */
  32747. getFrameId(): number;
  32748. /** Call this function if you want to manually increment the render Id*/
  32749. incrementRenderId(): void;
  32750. private _updatePointerPosition;
  32751. private _createUbo;
  32752. private _createAlternateUbo;
  32753. private _setRayOnPointerInfo;
  32754. /**
  32755. * Use this method to simulate a pointer move on a mesh
  32756. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32757. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32758. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32759. * @returns the current scene
  32760. */
  32761. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32762. private _processPointerMove;
  32763. private _checkPrePointerObservable;
  32764. /**
  32765. * Use this method to simulate a pointer down on a mesh
  32766. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32767. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32768. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32769. * @returns the current scene
  32770. */
  32771. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32772. private _processPointerDown;
  32773. /**
  32774. * Use this method to simulate a pointer up on a mesh
  32775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32778. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32779. * @returns the current scene
  32780. */
  32781. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32782. private _processPointerUp;
  32783. /**
  32784. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32785. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32786. * @returns true if the pointer was captured
  32787. */
  32788. isPointerCaptured(pointerId?: number): boolean;
  32789. /** @hidden */
  32790. _isPointerSwiping(): boolean;
  32791. /**
  32792. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32793. * @param attachUp defines if you want to attach events to pointerup
  32794. * @param attachDown defines if you want to attach events to pointerdown
  32795. * @param attachMove defines if you want to attach events to pointermove
  32796. */
  32797. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32798. /** Detaches all event handlers*/
  32799. detachControl(): void;
  32800. /**
  32801. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32802. * Delay loaded resources are not taking in account
  32803. * @return true if all required resources are ready
  32804. */
  32805. isReady(): boolean;
  32806. /** Resets all cached information relative to material (including effect and visibility) */
  32807. resetCachedMaterial(): void;
  32808. /**
  32809. * Registers a function to be called before every frame render
  32810. * @param func defines the function to register
  32811. */
  32812. registerBeforeRender(func: () => void): void;
  32813. /**
  32814. * Unregisters a function called before every frame render
  32815. * @param func defines the function to unregister
  32816. */
  32817. unregisterBeforeRender(func: () => void): void;
  32818. /**
  32819. * Registers a function to be called after every frame render
  32820. * @param func defines the function to register
  32821. */
  32822. registerAfterRender(func: () => void): void;
  32823. /**
  32824. * Unregisters a function called after every frame render
  32825. * @param func defines the function to unregister
  32826. */
  32827. unregisterAfterRender(func: () => void): void;
  32828. private _executeOnceBeforeRender;
  32829. /**
  32830. * The provided function will run before render once and will be disposed afterwards.
  32831. * A timeout delay can be provided so that the function will be executed in N ms.
  32832. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32833. * @param func The function to be executed.
  32834. * @param timeout optional delay in ms
  32835. */
  32836. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32837. /** @hidden */
  32838. _addPendingData(data: any): void;
  32839. /** @hidden */
  32840. _removePendingData(data: any): void;
  32841. /**
  32842. * Returns the number of items waiting to be loaded
  32843. * @returns the number of items waiting to be loaded
  32844. */
  32845. getWaitingItemsCount(): number;
  32846. /**
  32847. * Returns a boolean indicating if the scene is still loading data
  32848. */
  32849. readonly isLoading: boolean;
  32850. /**
  32851. * Registers a function to be executed when the scene is ready
  32852. * @param {Function} func - the function to be executed
  32853. */
  32854. executeWhenReady(func: () => void): void;
  32855. /**
  32856. * Returns a promise that resolves when the scene is ready
  32857. * @returns A promise that resolves when the scene is ready
  32858. */
  32859. whenReadyAsync(): Promise<void>;
  32860. /** @hidden */
  32861. _checkIsReady(): void;
  32862. /**
  32863. * Gets all animatable attached to the scene
  32864. */
  32865. readonly animatables: Animatable[];
  32866. /**
  32867. * Resets the last animation time frame.
  32868. * Useful to override when animations start running when loading a scene for the first time.
  32869. */
  32870. resetLastAnimationTimeFrame(): void;
  32871. /** @hidden */
  32872. _switchToAlternateCameraConfiguration(active: boolean): void;
  32873. /**
  32874. * Gets the current view matrix
  32875. * @returns a Matrix
  32876. */
  32877. getViewMatrix(): Matrix;
  32878. /**
  32879. * Gets the current projection matrix
  32880. * @returns a Matrix
  32881. */
  32882. getProjectionMatrix(): Matrix;
  32883. /**
  32884. * Gets the current transform matrix
  32885. * @returns a Matrix made of View * Projection
  32886. */
  32887. getTransformMatrix(): Matrix;
  32888. /**
  32889. * Sets the current transform matrix
  32890. * @param view defines the View matrix to use
  32891. * @param projection defines the Projection matrix to use
  32892. */
  32893. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32894. /** @hidden */
  32895. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32896. /**
  32897. * Gets the uniform buffer used to store scene data
  32898. * @returns a UniformBuffer
  32899. */
  32900. getSceneUniformBuffer(): UniformBuffer;
  32901. /**
  32902. * Gets an unique (relatively to the current scene) Id
  32903. * @returns an unique number for the scene
  32904. */
  32905. getUniqueId(): number;
  32906. /**
  32907. * Add a mesh to the list of scene's meshes
  32908. * @param newMesh defines the mesh to add
  32909. * @param recursive if all child meshes should also be added to the scene
  32910. */
  32911. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32912. /**
  32913. * Remove a mesh for the list of scene's meshes
  32914. * @param toRemove defines the mesh to remove
  32915. * @param recursive if all child meshes should also be removed from the scene
  32916. * @returns the index where the mesh was in the mesh list
  32917. */
  32918. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32919. /**
  32920. * Add a transform node to the list of scene's transform nodes
  32921. * @param newTransformNode defines the transform node to add
  32922. */
  32923. addTransformNode(newTransformNode: TransformNode): void;
  32924. /**
  32925. * Remove a transform node for the list of scene's transform nodes
  32926. * @param toRemove defines the transform node to remove
  32927. * @returns the index where the transform node was in the transform node list
  32928. */
  32929. removeTransformNode(toRemove: TransformNode): number;
  32930. /**
  32931. * Remove a skeleton for the list of scene's skeletons
  32932. * @param toRemove defines the skeleton to remove
  32933. * @returns the index where the skeleton was in the skeleton list
  32934. */
  32935. removeSkeleton(toRemove: Skeleton): number;
  32936. /**
  32937. * Remove a morph target for the list of scene's morph targets
  32938. * @param toRemove defines the morph target to remove
  32939. * @returns the index where the morph target was in the morph target list
  32940. */
  32941. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32942. /**
  32943. * Remove a light for the list of scene's lights
  32944. * @param toRemove defines the light to remove
  32945. * @returns the index where the light was in the light list
  32946. */
  32947. removeLight(toRemove: Light): number;
  32948. /**
  32949. * Remove a camera for the list of scene's cameras
  32950. * @param toRemove defines the camera to remove
  32951. * @returns the index where the camera was in the camera list
  32952. */
  32953. removeCamera(toRemove: Camera): number;
  32954. /**
  32955. * Remove a particle system for the list of scene's particle systems
  32956. * @param toRemove defines the particle system to remove
  32957. * @returns the index where the particle system was in the particle system list
  32958. */
  32959. removeParticleSystem(toRemove: IParticleSystem): number;
  32960. /**
  32961. * Remove a animation for the list of scene's animations
  32962. * @param toRemove defines the animation to remove
  32963. * @returns the index where the animation was in the animation list
  32964. */
  32965. removeAnimation(toRemove: Animation): number;
  32966. /**
  32967. * Removes the given animation group from this scene.
  32968. * @param toRemove The animation group to remove
  32969. * @returns The index of the removed animation group
  32970. */
  32971. removeAnimationGroup(toRemove: AnimationGroup): number;
  32972. /**
  32973. * Removes the given multi-material from this scene.
  32974. * @param toRemove The multi-material to remove
  32975. * @returns The index of the removed multi-material
  32976. */
  32977. removeMultiMaterial(toRemove: MultiMaterial): number;
  32978. /**
  32979. * Removes the given material from this scene.
  32980. * @param toRemove The material to remove
  32981. * @returns The index of the removed material
  32982. */
  32983. removeMaterial(toRemove: Material): number;
  32984. /**
  32985. * Removes the given action manager from this scene.
  32986. * @param toRemove The action manager to remove
  32987. * @returns The index of the removed action manager
  32988. */
  32989. removeActionManager(toRemove: AbstractActionManager): number;
  32990. /**
  32991. * Removes the given texture from this scene.
  32992. * @param toRemove The texture to remove
  32993. * @returns The index of the removed texture
  32994. */
  32995. removeTexture(toRemove: BaseTexture): number;
  32996. /**
  32997. * Adds the given light to this scene
  32998. * @param newLight The light to add
  32999. */
  33000. addLight(newLight: Light): void;
  33001. /**
  33002. * Sorts the list list based on light priorities
  33003. */
  33004. sortLightsByPriority(): void;
  33005. /**
  33006. * Adds the given camera to this scene
  33007. * @param newCamera The camera to add
  33008. */
  33009. addCamera(newCamera: Camera): void;
  33010. /**
  33011. * Adds the given skeleton to this scene
  33012. * @param newSkeleton The skeleton to add
  33013. */
  33014. addSkeleton(newSkeleton: Skeleton): void;
  33015. /**
  33016. * Adds the given particle system to this scene
  33017. * @param newParticleSystem The particle system to add
  33018. */
  33019. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33020. /**
  33021. * Adds the given animation to this scene
  33022. * @param newAnimation The animation to add
  33023. */
  33024. addAnimation(newAnimation: Animation): void;
  33025. /**
  33026. * Adds the given animation group to this scene.
  33027. * @param newAnimationGroup The animation group to add
  33028. */
  33029. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33030. /**
  33031. * Adds the given multi-material to this scene
  33032. * @param newMultiMaterial The multi-material to add
  33033. */
  33034. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33035. /**
  33036. * Adds the given material to this scene
  33037. * @param newMaterial The material to add
  33038. */
  33039. addMaterial(newMaterial: Material): void;
  33040. /**
  33041. * Adds the given morph target to this scene
  33042. * @param newMorphTargetManager The morph target to add
  33043. */
  33044. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33045. /**
  33046. * Adds the given geometry to this scene
  33047. * @param newGeometry The geometry to add
  33048. */
  33049. addGeometry(newGeometry: Geometry): void;
  33050. /**
  33051. * Adds the given action manager to this scene
  33052. * @param newActionManager The action manager to add
  33053. */
  33054. addActionManager(newActionManager: AbstractActionManager): void;
  33055. /**
  33056. * Adds the given texture to this scene.
  33057. * @param newTexture The texture to add
  33058. */
  33059. addTexture(newTexture: BaseTexture): void;
  33060. /**
  33061. * Switch active camera
  33062. * @param newCamera defines the new active camera
  33063. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33064. */
  33065. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33066. /**
  33067. * sets the active camera of the scene using its ID
  33068. * @param id defines the camera's ID
  33069. * @return the new active camera or null if none found.
  33070. */
  33071. setActiveCameraByID(id: string): Nullable<Camera>;
  33072. /**
  33073. * sets the active camera of the scene using its name
  33074. * @param name defines the camera's name
  33075. * @returns the new active camera or null if none found.
  33076. */
  33077. setActiveCameraByName(name: string): Nullable<Camera>;
  33078. /**
  33079. * get an animation group using its name
  33080. * @param name defines the material's name
  33081. * @return the animation group or null if none found.
  33082. */
  33083. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33084. /**
  33085. * get a material using its id
  33086. * @param id defines the material's ID
  33087. * @return the material or null if none found.
  33088. */
  33089. getMaterialByID(id: string): Nullable<Material>;
  33090. /**
  33091. * Gets a material using its name
  33092. * @param name defines the material's name
  33093. * @return the material or null if none found.
  33094. */
  33095. getMaterialByName(name: string): Nullable<Material>;
  33096. /**
  33097. * Gets a camera using its id
  33098. * @param id defines the id to look for
  33099. * @returns the camera or null if not found
  33100. */
  33101. getCameraByID(id: string): Nullable<Camera>;
  33102. /**
  33103. * Gets a camera using its unique id
  33104. * @param uniqueId defines the unique id to look for
  33105. * @returns the camera or null if not found
  33106. */
  33107. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33108. /**
  33109. * Gets a camera using its name
  33110. * @param name defines the camera's name
  33111. * @return the camera or null if none found.
  33112. */
  33113. getCameraByName(name: string): Nullable<Camera>;
  33114. /**
  33115. * Gets a bone using its id
  33116. * @param id defines the bone's id
  33117. * @return the bone or null if not found
  33118. */
  33119. getBoneByID(id: string): Nullable<Bone>;
  33120. /**
  33121. * Gets a bone using its id
  33122. * @param name defines the bone's name
  33123. * @return the bone or null if not found
  33124. */
  33125. getBoneByName(name: string): Nullable<Bone>;
  33126. /**
  33127. * Gets a light node using its name
  33128. * @param name defines the the light's name
  33129. * @return the light or null if none found.
  33130. */
  33131. getLightByName(name: string): Nullable<Light>;
  33132. /**
  33133. * Gets a light node using its id
  33134. * @param id defines the light's id
  33135. * @return the light or null if none found.
  33136. */
  33137. getLightByID(id: string): Nullable<Light>;
  33138. /**
  33139. * Gets a light node using its scene-generated unique ID
  33140. * @param uniqueId defines the light's unique id
  33141. * @return the light or null if none found.
  33142. */
  33143. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33144. /**
  33145. * Gets a particle system by id
  33146. * @param id defines the particle system id
  33147. * @return the corresponding system or null if none found
  33148. */
  33149. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33150. /**
  33151. * Gets a geometry using its ID
  33152. * @param id defines the geometry's id
  33153. * @return the geometry or null if none found.
  33154. */
  33155. getGeometryByID(id: string): Nullable<Geometry>;
  33156. private _getGeometryByUniqueID;
  33157. /**
  33158. * Add a new geometry to this scene
  33159. * @param geometry defines the geometry to be added to the scene.
  33160. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33161. * @return a boolean defining if the geometry was added or not
  33162. */
  33163. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33164. /**
  33165. * Removes an existing geometry
  33166. * @param geometry defines the geometry to be removed from the scene
  33167. * @return a boolean defining if the geometry was removed or not
  33168. */
  33169. removeGeometry(geometry: Geometry): boolean;
  33170. /**
  33171. * Gets the list of geometries attached to the scene
  33172. * @returns an array of Geometry
  33173. */
  33174. getGeometries(): Geometry[];
  33175. /**
  33176. * Gets the first added mesh found of a given ID
  33177. * @param id defines the id to search for
  33178. * @return the mesh found or null if not found at all
  33179. */
  33180. getMeshByID(id: string): Nullable<AbstractMesh>;
  33181. /**
  33182. * Gets a list of meshes using their id
  33183. * @param id defines the id to search for
  33184. * @returns a list of meshes
  33185. */
  33186. getMeshesByID(id: string): Array<AbstractMesh>;
  33187. /**
  33188. * Gets the first added transform node found of a given ID
  33189. * @param id defines the id to search for
  33190. * @return the found transform node or null if not found at all.
  33191. */
  33192. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33193. /**
  33194. * Gets a list of transform nodes using their id
  33195. * @param id defines the id to search for
  33196. * @returns a list of transform nodes
  33197. */
  33198. getTransformNodesByID(id: string): Array<TransformNode>;
  33199. /**
  33200. * Gets a mesh with its auto-generated unique id
  33201. * @param uniqueId defines the unique id to search for
  33202. * @return the found mesh or null if not found at all.
  33203. */
  33204. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33205. /**
  33206. * Gets a the last added mesh using a given id
  33207. * @param id defines the id to search for
  33208. * @return the found mesh or null if not found at all.
  33209. */
  33210. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33211. /**
  33212. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33213. * @param id defines the id to search for
  33214. * @return the found node or null if not found at all
  33215. */
  33216. getLastEntryByID(id: string): Nullable<Node>;
  33217. /**
  33218. * Gets a node (Mesh, Camera, Light) using a given id
  33219. * @param id defines the id to search for
  33220. * @return the found node or null if not found at all
  33221. */
  33222. getNodeByID(id: string): Nullable<Node>;
  33223. /**
  33224. * Gets a node (Mesh, Camera, Light) using a given name
  33225. * @param name defines the name to search for
  33226. * @return the found node or null if not found at all.
  33227. */
  33228. getNodeByName(name: string): Nullable<Node>;
  33229. /**
  33230. * Gets a mesh using a given name
  33231. * @param name defines the name to search for
  33232. * @return the found mesh or null if not found at all.
  33233. */
  33234. getMeshByName(name: string): Nullable<AbstractMesh>;
  33235. /**
  33236. * Gets a transform node using a given name
  33237. * @param name defines the name to search for
  33238. * @return the found transform node or null if not found at all.
  33239. */
  33240. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33241. /**
  33242. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33243. * @param id defines the id to search for
  33244. * @return the found skeleton or null if not found at all.
  33245. */
  33246. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33247. /**
  33248. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33249. * @param id defines the id to search for
  33250. * @return the found skeleton or null if not found at all.
  33251. */
  33252. getSkeletonById(id: string): Nullable<Skeleton>;
  33253. /**
  33254. * Gets a skeleton using a given name
  33255. * @param name defines the name to search for
  33256. * @return the found skeleton or null if not found at all.
  33257. */
  33258. getSkeletonByName(name: string): Nullable<Skeleton>;
  33259. /**
  33260. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33261. * @param id defines the id to search for
  33262. * @return the found morph target manager or null if not found at all.
  33263. */
  33264. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33265. /**
  33266. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33267. * @param id defines the id to search for
  33268. * @return the found morph target or null if not found at all.
  33269. */
  33270. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33271. /**
  33272. * Gets a boolean indicating if the given mesh is active
  33273. * @param mesh defines the mesh to look for
  33274. * @returns true if the mesh is in the active list
  33275. */
  33276. isActiveMesh(mesh: AbstractMesh): boolean;
  33277. /**
  33278. * Return a unique id as a string which can serve as an identifier for the scene
  33279. */
  33280. readonly uid: string;
  33281. /**
  33282. * Add an externaly attached data from its key.
  33283. * This method call will fail and return false, if such key already exists.
  33284. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33285. * @param key the unique key that identifies the data
  33286. * @param data the data object to associate to the key for this Engine instance
  33287. * @return true if no such key were already present and the data was added successfully, false otherwise
  33288. */
  33289. addExternalData<T>(key: string, data: T): boolean;
  33290. /**
  33291. * Get an externaly attached data from its key
  33292. * @param key the unique key that identifies the data
  33293. * @return the associated data, if present (can be null), or undefined if not present
  33294. */
  33295. getExternalData<T>(key: string): Nullable<T>;
  33296. /**
  33297. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33298. * @param key the unique key that identifies the data
  33299. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33300. * @return the associated data, can be null if the factory returned null.
  33301. */
  33302. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33303. /**
  33304. * Remove an externaly attached data from the Engine instance
  33305. * @param key the unique key that identifies the data
  33306. * @return true if the data was successfully removed, false if it doesn't exist
  33307. */
  33308. removeExternalData(key: string): boolean;
  33309. private _evaluateSubMesh;
  33310. /**
  33311. * Clear the processed materials smart array preventing retention point in material dispose.
  33312. */
  33313. freeProcessedMaterials(): void;
  33314. private _preventFreeActiveMeshesAndRenderingGroups;
  33315. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33316. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33317. * when disposing several meshes in a row or a hierarchy of meshes.
  33318. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33319. */
  33320. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33321. /**
  33322. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33323. */
  33324. freeActiveMeshes(): void;
  33325. /**
  33326. * Clear the info related to rendering groups preventing retention points during dispose.
  33327. */
  33328. freeRenderingGroups(): void;
  33329. /** @hidden */
  33330. _isInIntermediateRendering(): boolean;
  33331. /**
  33332. * Lambda returning the list of potentially active meshes.
  33333. */
  33334. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33335. /**
  33336. * Lambda returning the list of potentially active sub meshes.
  33337. */
  33338. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33339. /**
  33340. * Lambda returning the list of potentially intersecting sub meshes.
  33341. */
  33342. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33343. /**
  33344. * Lambda returning the list of potentially colliding sub meshes.
  33345. */
  33346. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33347. private _activeMeshesFrozen;
  33348. /**
  33349. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33350. * @returns the current scene
  33351. */
  33352. freezeActiveMeshes(): Scene;
  33353. /**
  33354. * Use this function to restart evaluating active meshes on every frame
  33355. * @returns the current scene
  33356. */
  33357. unfreezeActiveMeshes(): Scene;
  33358. private _evaluateActiveMeshes;
  33359. private _activeMesh;
  33360. /**
  33361. * Update the transform matrix to update from the current active camera
  33362. * @param force defines a boolean used to force the update even if cache is up to date
  33363. */
  33364. updateTransformMatrix(force?: boolean): void;
  33365. /**
  33366. * 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)
  33367. * @param alternateCamera defines the camera to use
  33368. */
  33369. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33370. /** @hidden */
  33371. _allowPostProcessClearColor: boolean;
  33372. private _renderForCamera;
  33373. private _processSubCameras;
  33374. private _checkIntersections;
  33375. /** @hidden */
  33376. _advancePhysicsEngineStep(step: number): void;
  33377. /**
  33378. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33379. */
  33380. getDeterministicFrameTime: () => number;
  33381. /** @hidden */
  33382. _animate(): void;
  33383. /**
  33384. * Render the scene
  33385. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33386. */
  33387. render(updateCameras?: boolean): void;
  33388. /**
  33389. * Freeze all materials
  33390. * A frozen material will not be updatable but should be faster to render
  33391. */
  33392. freezeMaterials(): void;
  33393. /**
  33394. * Unfreeze all materials
  33395. * A frozen material will not be updatable but should be faster to render
  33396. */
  33397. unfreezeMaterials(): void;
  33398. /**
  33399. * Releases all held ressources
  33400. */
  33401. dispose(): void;
  33402. /**
  33403. * Gets if the scene is already disposed
  33404. */
  33405. readonly isDisposed: boolean;
  33406. /**
  33407. * Call this function to reduce memory footprint of the scene.
  33408. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33409. */
  33410. clearCachedVertexData(): void;
  33411. /**
  33412. * This function will remove the local cached buffer data from texture.
  33413. * It will save memory but will prevent the texture from being rebuilt
  33414. */
  33415. cleanCachedTextureBuffer(): void;
  33416. /**
  33417. * Get the world extend vectors with an optional filter
  33418. *
  33419. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33420. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33421. */
  33422. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33423. min: Vector3;
  33424. max: Vector3;
  33425. };
  33426. /**
  33427. * Creates a ray that can be used to pick in the scene
  33428. * @param x defines the x coordinate of the origin (on-screen)
  33429. * @param y defines the y coordinate of the origin (on-screen)
  33430. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33431. * @param camera defines the camera to use for the picking
  33432. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33433. * @returns a Ray
  33434. */
  33435. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33436. /**
  33437. * Creates a ray that can be used to pick in the scene
  33438. * @param x defines the x coordinate of the origin (on-screen)
  33439. * @param y defines the y coordinate of the origin (on-screen)
  33440. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33441. * @param result defines the ray where to store the picking ray
  33442. * @param camera defines the camera to use for the picking
  33443. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33444. * @returns the current scene
  33445. */
  33446. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33447. /**
  33448. * Creates a ray that can be used to pick in the scene
  33449. * @param x defines the x coordinate of the origin (on-screen)
  33450. * @param y defines the y coordinate of the origin (on-screen)
  33451. * @param camera defines the camera to use for the picking
  33452. * @returns a Ray
  33453. */
  33454. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33455. /**
  33456. * Creates a ray that can be used to pick in the scene
  33457. * @param x defines the x coordinate of the origin (on-screen)
  33458. * @param y defines the y coordinate of the origin (on-screen)
  33459. * @param result defines the ray where to store the picking ray
  33460. * @param camera defines the camera to use for the picking
  33461. * @returns the current scene
  33462. */
  33463. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33464. /** Launch a ray to try to pick a mesh in the scene
  33465. * @param x position on screen
  33466. * @param y position on screen
  33467. * @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
  33468. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33469. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33470. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33471. * @returns a PickingInfo
  33472. */
  33473. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33474. /** Use the given ray to pick a mesh in the scene
  33475. * @param ray The ray to use to pick meshes
  33476. * @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
  33477. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33479. * @returns a PickingInfo
  33480. */
  33481. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33482. /**
  33483. * Launch a ray to try to pick a mesh in the scene
  33484. * @param x X position on screen
  33485. * @param y Y position on screen
  33486. * @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
  33487. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33488. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33489. * @returns an array of PickingInfo
  33490. */
  33491. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33492. /**
  33493. * Launch a ray to try to pick a mesh in the scene
  33494. * @param ray Ray to use
  33495. * @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
  33496. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33497. * @returns an array of PickingInfo
  33498. */
  33499. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33500. /**
  33501. * Force the value of meshUnderPointer
  33502. * @param mesh defines the mesh to use
  33503. */
  33504. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33505. /**
  33506. * Gets the mesh under the pointer
  33507. * @returns a Mesh or null if no mesh is under the pointer
  33508. */
  33509. getPointerOverMesh(): Nullable<AbstractMesh>;
  33510. /** @hidden */
  33511. _rebuildGeometries(): void;
  33512. /** @hidden */
  33513. _rebuildTextures(): void;
  33514. private _getByTags;
  33515. /**
  33516. * Get a list of meshes by tags
  33517. * @param tagsQuery defines the tags query to use
  33518. * @param forEach defines a predicate used to filter results
  33519. * @returns an array of Mesh
  33520. */
  33521. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33522. /**
  33523. * Get a list of cameras by tags
  33524. * @param tagsQuery defines the tags query to use
  33525. * @param forEach defines a predicate used to filter results
  33526. * @returns an array of Camera
  33527. */
  33528. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33529. /**
  33530. * Get a list of lights by tags
  33531. * @param tagsQuery defines the tags query to use
  33532. * @param forEach defines a predicate used to filter results
  33533. * @returns an array of Light
  33534. */
  33535. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33536. /**
  33537. * Get a list of materials by tags
  33538. * @param tagsQuery defines the tags query to use
  33539. * @param forEach defines a predicate used to filter results
  33540. * @returns an array of Material
  33541. */
  33542. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33543. /**
  33544. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33545. * This allowed control for front to back rendering or reversly depending of the special needs.
  33546. *
  33547. * @param renderingGroupId The rendering group id corresponding to its index
  33548. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33549. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33550. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33551. */
  33552. 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;
  33553. /**
  33554. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33555. *
  33556. * @param renderingGroupId The rendering group id corresponding to its index
  33557. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33558. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33559. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33560. */
  33561. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33562. /**
  33563. * Gets the current auto clear configuration for one rendering group of the rendering
  33564. * manager.
  33565. * @param index the rendering group index to get the information for
  33566. * @returns The auto clear setup for the requested rendering group
  33567. */
  33568. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33569. private _blockMaterialDirtyMechanism;
  33570. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33571. blockMaterialDirtyMechanism: boolean;
  33572. /**
  33573. * Will flag all materials as dirty to trigger new shader compilation
  33574. * @param flag defines the flag used to specify which material part must be marked as dirty
  33575. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33576. */
  33577. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33578. /** @hidden */
  33579. _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;
  33580. /** @hidden */
  33581. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33582. }
  33583. }
  33584. declare module "babylonjs/assetContainer" {
  33585. import { AbstractScene } from "babylonjs/abstractScene";
  33586. import { Scene } from "babylonjs/scene";
  33587. import { Mesh } from "babylonjs/Meshes/mesh";
  33588. /**
  33589. * Set of assets to keep when moving a scene into an asset container.
  33590. */
  33591. export class KeepAssets extends AbstractScene {
  33592. }
  33593. /**
  33594. * Container with a set of assets that can be added or removed from a scene.
  33595. */
  33596. export class AssetContainer extends AbstractScene {
  33597. /**
  33598. * The scene the AssetContainer belongs to.
  33599. */
  33600. scene: Scene;
  33601. /**
  33602. * Instantiates an AssetContainer.
  33603. * @param scene The scene the AssetContainer belongs to.
  33604. */
  33605. constructor(scene: Scene);
  33606. /**
  33607. * Adds all the assets from the container to the scene.
  33608. */
  33609. addAllToScene(): void;
  33610. /**
  33611. * Removes all the assets in the container from the scene
  33612. */
  33613. removeAllFromScene(): void;
  33614. /**
  33615. * Disposes all the assets in the container
  33616. */
  33617. dispose(): void;
  33618. private _moveAssets;
  33619. /**
  33620. * Removes all the assets contained in the scene and adds them to the container.
  33621. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33622. */
  33623. moveAllFromScene(keepAssets?: KeepAssets): void;
  33624. /**
  33625. * 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.
  33626. * @returns the root mesh
  33627. */
  33628. createRootMesh(): Mesh;
  33629. }
  33630. }
  33631. declare module "babylonjs/abstractScene" {
  33632. import { Scene } from "babylonjs/scene";
  33633. import { Nullable } from "babylonjs/types";
  33634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33635. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33636. import { Geometry } from "babylonjs/Meshes/geometry";
  33637. import { Skeleton } from "babylonjs/Bones/skeleton";
  33638. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33639. import { AssetContainer } from "babylonjs/assetContainer";
  33640. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33641. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33642. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33643. import { Material } from "babylonjs/Materials/material";
  33644. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33645. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33646. import { Camera } from "babylonjs/Cameras/camera";
  33647. import { Light } from "babylonjs/Lights/light";
  33648. import { Node } from "babylonjs/node";
  33649. import { Animation } from "babylonjs/Animations/animation";
  33650. /**
  33651. * Defines how the parser contract is defined.
  33652. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33653. */
  33654. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33655. /**
  33656. * Defines how the individual parser contract is defined.
  33657. * These parser can parse an individual asset
  33658. */
  33659. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33660. /**
  33661. * Base class of the scene acting as a container for the different elements composing a scene.
  33662. * This class is dynamically extended by the different components of the scene increasing
  33663. * flexibility and reducing coupling
  33664. */
  33665. export abstract class AbstractScene {
  33666. /**
  33667. * Stores the list of available parsers in the application.
  33668. */
  33669. private static _BabylonFileParsers;
  33670. /**
  33671. * Stores the list of available individual parsers in the application.
  33672. */
  33673. private static _IndividualBabylonFileParsers;
  33674. /**
  33675. * Adds a parser in the list of available ones
  33676. * @param name Defines the name of the parser
  33677. * @param parser Defines the parser to add
  33678. */
  33679. static AddParser(name: string, parser: BabylonFileParser): void;
  33680. /**
  33681. * Gets a general parser from the list of avaialble ones
  33682. * @param name Defines the name of the parser
  33683. * @returns the requested parser or null
  33684. */
  33685. static GetParser(name: string): Nullable<BabylonFileParser>;
  33686. /**
  33687. * Adds n individual parser in the list of available ones
  33688. * @param name Defines the name of the parser
  33689. * @param parser Defines the parser to add
  33690. */
  33691. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33692. /**
  33693. * Gets an individual parser from the list of avaialble ones
  33694. * @param name Defines the name of the parser
  33695. * @returns the requested parser or null
  33696. */
  33697. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33698. /**
  33699. * Parser json data and populate both a scene and its associated container object
  33700. * @param jsonData Defines the data to parse
  33701. * @param scene Defines the scene to parse the data for
  33702. * @param container Defines the container attached to the parsing sequence
  33703. * @param rootUrl Defines the root url of the data
  33704. */
  33705. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33706. /**
  33707. * Gets the list of root nodes (ie. nodes with no parent)
  33708. */
  33709. rootNodes: Node[];
  33710. /** All of the cameras added to this scene
  33711. * @see http://doc.babylonjs.com/babylon101/cameras
  33712. */
  33713. cameras: Camera[];
  33714. /**
  33715. * All of the lights added to this scene
  33716. * @see http://doc.babylonjs.com/babylon101/lights
  33717. */
  33718. lights: Light[];
  33719. /**
  33720. * All of the (abstract) meshes added to this scene
  33721. */
  33722. meshes: AbstractMesh[];
  33723. /**
  33724. * The list of skeletons added to the scene
  33725. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33726. */
  33727. skeletons: Skeleton[];
  33728. /**
  33729. * All of the particle systems added to this scene
  33730. * @see http://doc.babylonjs.com/babylon101/particles
  33731. */
  33732. particleSystems: IParticleSystem[];
  33733. /**
  33734. * Gets a list of Animations associated with the scene
  33735. */
  33736. animations: Animation[];
  33737. /**
  33738. * All of the animation groups added to this scene
  33739. * @see http://doc.babylonjs.com/how_to/group
  33740. */
  33741. animationGroups: AnimationGroup[];
  33742. /**
  33743. * All of the multi-materials added to this scene
  33744. * @see http://doc.babylonjs.com/how_to/multi_materials
  33745. */
  33746. multiMaterials: MultiMaterial[];
  33747. /**
  33748. * All of the materials added to this scene
  33749. * In the context of a Scene, it is not supposed to be modified manually.
  33750. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33751. * Note also that the order of the Material wihin the array is not significant and might change.
  33752. * @see http://doc.babylonjs.com/babylon101/materials
  33753. */
  33754. materials: Material[];
  33755. /**
  33756. * The list of morph target managers added to the scene
  33757. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33758. */
  33759. morphTargetManagers: MorphTargetManager[];
  33760. /**
  33761. * The list of geometries used in the scene.
  33762. */
  33763. geometries: Geometry[];
  33764. /**
  33765. * All of the tranform nodes added to this scene
  33766. * In the context of a Scene, it is not supposed to be modified manually.
  33767. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33768. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33769. * @see http://doc.babylonjs.com/how_to/transformnode
  33770. */
  33771. transformNodes: TransformNode[];
  33772. /**
  33773. * ActionManagers available on the scene.
  33774. */
  33775. actionManagers: AbstractActionManager[];
  33776. /**
  33777. * Textures to keep.
  33778. */
  33779. textures: BaseTexture[];
  33780. }
  33781. }
  33782. declare module "babylonjs/Audio/sound" {
  33783. import { Observable } from "babylonjs/Misc/observable";
  33784. import { Vector3 } from "babylonjs/Maths/math";
  33785. import { Nullable } from "babylonjs/types";
  33786. import { Scene } from "babylonjs/scene";
  33787. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33788. /**
  33789. * Defines a sound that can be played in the application.
  33790. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33792. */
  33793. export class Sound {
  33794. /**
  33795. * The name of the sound in the scene.
  33796. */
  33797. name: string;
  33798. /**
  33799. * Does the sound autoplay once loaded.
  33800. */
  33801. autoplay: boolean;
  33802. /**
  33803. * Does the sound loop after it finishes playing once.
  33804. */
  33805. loop: boolean;
  33806. /**
  33807. * Does the sound use a custom attenuation curve to simulate the falloff
  33808. * happening when the source gets further away from the camera.
  33809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33810. */
  33811. useCustomAttenuation: boolean;
  33812. /**
  33813. * The sound track id this sound belongs to.
  33814. */
  33815. soundTrackId: number;
  33816. /**
  33817. * Is this sound currently played.
  33818. */
  33819. isPlaying: boolean;
  33820. /**
  33821. * Is this sound currently paused.
  33822. */
  33823. isPaused: boolean;
  33824. /**
  33825. * Does this sound enables spatial sound.
  33826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33827. */
  33828. spatialSound: boolean;
  33829. /**
  33830. * Define the reference distance the sound should be heard perfectly.
  33831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33832. */
  33833. refDistance: number;
  33834. /**
  33835. * Define the roll off factor of spatial sounds.
  33836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33837. */
  33838. rolloffFactor: number;
  33839. /**
  33840. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33842. */
  33843. maxDistance: number;
  33844. /**
  33845. * Define the distance attenuation model the sound will follow.
  33846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33847. */
  33848. distanceModel: string;
  33849. /**
  33850. * @hidden
  33851. * Back Compat
  33852. **/
  33853. onended: () => any;
  33854. /**
  33855. * Observable event when the current playing sound finishes.
  33856. */
  33857. onEndedObservable: Observable<Sound>;
  33858. private _panningModel;
  33859. private _playbackRate;
  33860. private _streaming;
  33861. private _startTime;
  33862. private _startOffset;
  33863. private _position;
  33864. /** @hidden */
  33865. _positionInEmitterSpace: boolean;
  33866. private _localDirection;
  33867. private _volume;
  33868. private _isReadyToPlay;
  33869. private _isDirectional;
  33870. private _readyToPlayCallback;
  33871. private _audioBuffer;
  33872. private _soundSource;
  33873. private _streamingSource;
  33874. private _soundPanner;
  33875. private _soundGain;
  33876. private _inputAudioNode;
  33877. private _outputAudioNode;
  33878. private _coneInnerAngle;
  33879. private _coneOuterAngle;
  33880. private _coneOuterGain;
  33881. private _scene;
  33882. private _connectedTransformNode;
  33883. private _customAttenuationFunction;
  33884. private _registerFunc;
  33885. private _isOutputConnected;
  33886. private _htmlAudioElement;
  33887. private _urlType;
  33888. /** @hidden */
  33889. static _SceneComponentInitialization: (scene: Scene) => void;
  33890. /**
  33891. * Create a sound and attach it to a scene
  33892. * @param name Name of your sound
  33893. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33894. * @param scene defines the scene the sound belongs to
  33895. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33896. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33897. */
  33898. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33899. /**
  33900. * Release the sound and its associated resources
  33901. */
  33902. dispose(): void;
  33903. /**
  33904. * Gets if the sounds is ready to be played or not.
  33905. * @returns true if ready, otherwise false
  33906. */
  33907. isReady(): boolean;
  33908. private _soundLoaded;
  33909. /**
  33910. * Sets the data of the sound from an audiobuffer
  33911. * @param audioBuffer The audioBuffer containing the data
  33912. */
  33913. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33914. /**
  33915. * Updates the current sounds options such as maxdistance, loop...
  33916. * @param options A JSON object containing values named as the object properties
  33917. */
  33918. updateOptions(options: any): void;
  33919. private _createSpatialParameters;
  33920. private _updateSpatialParameters;
  33921. /**
  33922. * Switch the panning model to HRTF:
  33923. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33925. */
  33926. switchPanningModelToHRTF(): void;
  33927. /**
  33928. * Switch the panning model to Equal Power:
  33929. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33931. */
  33932. switchPanningModelToEqualPower(): void;
  33933. private _switchPanningModel;
  33934. /**
  33935. * Connect this sound to a sound track audio node like gain...
  33936. * @param soundTrackAudioNode the sound track audio node to connect to
  33937. */
  33938. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33939. /**
  33940. * Transform this sound into a directional source
  33941. * @param coneInnerAngle Size of the inner cone in degree
  33942. * @param coneOuterAngle Size of the outer cone in degree
  33943. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33944. */
  33945. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33946. /**
  33947. * Gets or sets the inner angle for the directional cone.
  33948. */
  33949. /**
  33950. * Gets or sets the inner angle for the directional cone.
  33951. */
  33952. directionalConeInnerAngle: number;
  33953. /**
  33954. * Gets or sets the outer angle for the directional cone.
  33955. */
  33956. /**
  33957. * Gets or sets the outer angle for the directional cone.
  33958. */
  33959. directionalConeOuterAngle: number;
  33960. /**
  33961. * Sets the position of the emitter if spatial sound is enabled
  33962. * @param newPosition Defines the new posisiton
  33963. */
  33964. setPosition(newPosition: Vector3): void;
  33965. /**
  33966. * Sets the local direction of the emitter if spatial sound is enabled
  33967. * @param newLocalDirection Defines the new local direction
  33968. */
  33969. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33970. private _updateDirection;
  33971. /** @hidden */
  33972. updateDistanceFromListener(): void;
  33973. /**
  33974. * Sets a new custom attenuation function for the sound.
  33975. * @param callback Defines the function used for the attenuation
  33976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33977. */
  33978. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33979. /**
  33980. * Play the sound
  33981. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33982. * @param offset (optional) Start the sound setting it at a specific time
  33983. */
  33984. play(time?: number, offset?: number): void;
  33985. private _onended;
  33986. /**
  33987. * Stop the sound
  33988. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33989. */
  33990. stop(time?: number): void;
  33991. /**
  33992. * Put the sound in pause
  33993. */
  33994. pause(): void;
  33995. /**
  33996. * Sets a dedicated volume for this sounds
  33997. * @param newVolume Define the new volume of the sound
  33998. * @param time Define in how long the sound should be at this value
  33999. */
  34000. setVolume(newVolume: number, time?: number): void;
  34001. /**
  34002. * Set the sound play back rate
  34003. * @param newPlaybackRate Define the playback rate the sound should be played at
  34004. */
  34005. setPlaybackRate(newPlaybackRate: number): void;
  34006. /**
  34007. * Gets the volume of the sound.
  34008. * @returns the volume of the sound
  34009. */
  34010. getVolume(): number;
  34011. /**
  34012. * Attach the sound to a dedicated mesh
  34013. * @param transformNode The transform node to connect the sound with
  34014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34015. */
  34016. attachToMesh(transformNode: TransformNode): void;
  34017. /**
  34018. * Detach the sound from the previously attached mesh
  34019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34020. */
  34021. detachFromMesh(): void;
  34022. private _onRegisterAfterWorldMatrixUpdate;
  34023. /**
  34024. * Clone the current sound in the scene.
  34025. * @returns the new sound clone
  34026. */
  34027. clone(): Nullable<Sound>;
  34028. /**
  34029. * Gets the current underlying audio buffer containing the data
  34030. * @returns the audio buffer
  34031. */
  34032. getAudioBuffer(): Nullable<AudioBuffer>;
  34033. /**
  34034. * Serializes the Sound in a JSON representation
  34035. * @returns the JSON representation of the sound
  34036. */
  34037. serialize(): any;
  34038. /**
  34039. * Parse a JSON representation of a sound to innstantiate in a given scene
  34040. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34041. * @param scene Define the scene the new parsed sound should be created in
  34042. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34043. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34044. * @returns the newly parsed sound
  34045. */
  34046. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34047. }
  34048. }
  34049. declare module "babylonjs/Actions/directAudioActions" {
  34050. import { Action } from "babylonjs/Actions/action";
  34051. import { Condition } from "babylonjs/Actions/condition";
  34052. import { Sound } from "babylonjs/Audio/sound";
  34053. /**
  34054. * This defines an action helpful to play a defined sound on a triggered action.
  34055. */
  34056. export class PlaySoundAction extends Action {
  34057. private _sound;
  34058. /**
  34059. * Instantiate the action
  34060. * @param triggerOptions defines the trigger options
  34061. * @param sound defines the sound to play
  34062. * @param condition defines the trigger related conditions
  34063. */
  34064. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34065. /** @hidden */
  34066. _prepare(): void;
  34067. /**
  34068. * Execute the action and play the sound.
  34069. */
  34070. execute(): void;
  34071. /**
  34072. * Serializes the actions and its related information.
  34073. * @param parent defines the object to serialize in
  34074. * @returns the serialized object
  34075. */
  34076. serialize(parent: any): any;
  34077. }
  34078. /**
  34079. * This defines an action helpful to stop a defined sound on a triggered action.
  34080. */
  34081. export class StopSoundAction extends Action {
  34082. private _sound;
  34083. /**
  34084. * Instantiate the action
  34085. * @param triggerOptions defines the trigger options
  34086. * @param sound defines the sound to stop
  34087. * @param condition defines the trigger related conditions
  34088. */
  34089. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34090. /** @hidden */
  34091. _prepare(): void;
  34092. /**
  34093. * Execute the action and stop the sound.
  34094. */
  34095. execute(): void;
  34096. /**
  34097. * Serializes the actions and its related information.
  34098. * @param parent defines the object to serialize in
  34099. * @returns the serialized object
  34100. */
  34101. serialize(parent: any): any;
  34102. }
  34103. }
  34104. declare module "babylonjs/Actions/interpolateValueAction" {
  34105. import { Action } from "babylonjs/Actions/action";
  34106. import { Condition } from "babylonjs/Actions/condition";
  34107. import { Observable } from "babylonjs/Misc/observable";
  34108. /**
  34109. * This defines an action responsible to change the value of a property
  34110. * by interpolating between its current value and the newly set one once triggered.
  34111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34112. */
  34113. export class InterpolateValueAction extends Action {
  34114. /**
  34115. * Defines the path of the property where the value should be interpolated
  34116. */
  34117. propertyPath: string;
  34118. /**
  34119. * Defines the target value at the end of the interpolation.
  34120. */
  34121. value: any;
  34122. /**
  34123. * Defines the time it will take for the property to interpolate to the value.
  34124. */
  34125. duration: number;
  34126. /**
  34127. * Defines if the other scene animations should be stopped when the action has been triggered
  34128. */
  34129. stopOtherAnimations?: boolean;
  34130. /**
  34131. * Defines a callback raised once the interpolation animation has been done.
  34132. */
  34133. onInterpolationDone?: () => void;
  34134. /**
  34135. * Observable triggered once the interpolation animation has been done.
  34136. */
  34137. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34138. private _target;
  34139. private _effectiveTarget;
  34140. private _property;
  34141. /**
  34142. * Instantiate the action
  34143. * @param triggerOptions defines the trigger options
  34144. * @param target defines the object containing the value to interpolate
  34145. * @param propertyPath defines the path to the property in the target object
  34146. * @param value defines the target value at the end of the interpolation
  34147. * @param duration deines the time it will take for the property to interpolate to the value.
  34148. * @param condition defines the trigger related conditions
  34149. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34150. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34151. */
  34152. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34153. /** @hidden */
  34154. _prepare(): void;
  34155. /**
  34156. * Execute the action starts the value interpolation.
  34157. */
  34158. execute(): void;
  34159. /**
  34160. * Serializes the actions and its related information.
  34161. * @param parent defines the object to serialize in
  34162. * @returns the serialized object
  34163. */
  34164. serialize(parent: any): any;
  34165. }
  34166. }
  34167. declare module "babylonjs/Actions/index" {
  34168. export * from "babylonjs/Actions/action";
  34169. export * from "babylonjs/Actions/actionEvent";
  34170. export * from "babylonjs/Actions/actionManager";
  34171. export * from "babylonjs/Actions/condition";
  34172. export * from "babylonjs/Actions/directActions";
  34173. export * from "babylonjs/Actions/directAudioActions";
  34174. export * from "babylonjs/Actions/interpolateValueAction";
  34175. }
  34176. declare module "babylonjs/Animations/index" {
  34177. export * from "babylonjs/Animations/animatable";
  34178. export * from "babylonjs/Animations/animation";
  34179. export * from "babylonjs/Animations/animationGroup";
  34180. export * from "babylonjs/Animations/animationPropertiesOverride";
  34181. export * from "babylonjs/Animations/easing";
  34182. export * from "babylonjs/Animations/runtimeAnimation";
  34183. export * from "babylonjs/Animations/animationEvent";
  34184. export * from "babylonjs/Animations/animationGroup";
  34185. export * from "babylonjs/Animations/animationKey";
  34186. export * from "babylonjs/Animations/animationRange";
  34187. }
  34188. declare module "babylonjs/Audio/soundTrack" {
  34189. import { Sound } from "babylonjs/Audio/sound";
  34190. import { Analyser } from "babylonjs/Audio/analyser";
  34191. import { Scene } from "babylonjs/scene";
  34192. /**
  34193. * Options allowed during the creation of a sound track.
  34194. */
  34195. export interface ISoundTrackOptions {
  34196. /**
  34197. * The volume the sound track should take during creation
  34198. */
  34199. volume?: number;
  34200. /**
  34201. * Define if the sound track is the main sound track of the scene
  34202. */
  34203. mainTrack?: boolean;
  34204. }
  34205. /**
  34206. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34207. * It will be also used in a future release to apply effects on a specific track.
  34208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34209. */
  34210. export class SoundTrack {
  34211. /**
  34212. * The unique identifier of the sound track in the scene.
  34213. */
  34214. id: number;
  34215. /**
  34216. * The list of sounds included in the sound track.
  34217. */
  34218. soundCollection: Array<Sound>;
  34219. private _outputAudioNode;
  34220. private _scene;
  34221. private _isMainTrack;
  34222. private _connectedAnalyser;
  34223. private _options;
  34224. private _isInitialized;
  34225. /**
  34226. * Creates a new sound track.
  34227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34228. * @param scene Define the scene the sound track belongs to
  34229. * @param options
  34230. */
  34231. constructor(scene: Scene, options?: ISoundTrackOptions);
  34232. private _initializeSoundTrackAudioGraph;
  34233. /**
  34234. * Release the sound track and its associated resources
  34235. */
  34236. dispose(): void;
  34237. /**
  34238. * Adds a sound to this sound track
  34239. * @param sound define the cound to add
  34240. * @ignoreNaming
  34241. */
  34242. AddSound(sound: Sound): void;
  34243. /**
  34244. * Removes a sound to this sound track
  34245. * @param sound define the cound to remove
  34246. * @ignoreNaming
  34247. */
  34248. RemoveSound(sound: Sound): void;
  34249. /**
  34250. * Set a global volume for the full sound track.
  34251. * @param newVolume Define the new volume of the sound track
  34252. */
  34253. setVolume(newVolume: number): void;
  34254. /**
  34255. * Switch the panning model to HRTF:
  34256. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34258. */
  34259. switchPanningModelToHRTF(): void;
  34260. /**
  34261. * Switch the panning model to Equal Power:
  34262. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34264. */
  34265. switchPanningModelToEqualPower(): void;
  34266. /**
  34267. * Connect the sound track to an audio analyser allowing some amazing
  34268. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34270. * @param analyser The analyser to connect to the engine
  34271. */
  34272. connectToAnalyser(analyser: Analyser): void;
  34273. }
  34274. }
  34275. declare module "babylonjs/Audio/audioSceneComponent" {
  34276. import { Sound } from "babylonjs/Audio/sound";
  34277. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34278. import { Nullable } from "babylonjs/types";
  34279. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34280. import { Scene } from "babylonjs/scene";
  34281. import { AbstractScene } from "babylonjs/abstractScene";
  34282. module "babylonjs/abstractScene" {
  34283. interface AbstractScene {
  34284. /**
  34285. * The list of sounds used in the scene.
  34286. */
  34287. sounds: Nullable<Array<Sound>>;
  34288. }
  34289. }
  34290. module "babylonjs/scene" {
  34291. interface Scene {
  34292. /**
  34293. * @hidden
  34294. * Backing field
  34295. */
  34296. _mainSoundTrack: SoundTrack;
  34297. /**
  34298. * The main sound track played by the scene.
  34299. * It cotains your primary collection of sounds.
  34300. */
  34301. mainSoundTrack: SoundTrack;
  34302. /**
  34303. * The list of sound tracks added to the scene
  34304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34305. */
  34306. soundTracks: Nullable<Array<SoundTrack>>;
  34307. /**
  34308. * Gets a sound using a given name
  34309. * @param name defines the name to search for
  34310. * @return the found sound or null if not found at all.
  34311. */
  34312. getSoundByName(name: string): Nullable<Sound>;
  34313. /**
  34314. * Gets or sets if audio support is enabled
  34315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34316. */
  34317. audioEnabled: boolean;
  34318. /**
  34319. * Gets or sets if audio will be output to headphones
  34320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34321. */
  34322. headphone: boolean;
  34323. }
  34324. }
  34325. /**
  34326. * Defines the sound scene component responsible to manage any sounds
  34327. * in a given scene.
  34328. */
  34329. export class AudioSceneComponent implements ISceneSerializableComponent {
  34330. /**
  34331. * The component name helpfull to identify the component in the list of scene components.
  34332. */
  34333. readonly name: string;
  34334. /**
  34335. * The scene the component belongs to.
  34336. */
  34337. scene: Scene;
  34338. private _audioEnabled;
  34339. /**
  34340. * Gets whether audio is enabled or not.
  34341. * Please use related enable/disable method to switch state.
  34342. */
  34343. readonly audioEnabled: boolean;
  34344. private _headphone;
  34345. /**
  34346. * Gets whether audio is outputing to headphone or not.
  34347. * Please use the according Switch methods to change output.
  34348. */
  34349. readonly headphone: boolean;
  34350. /**
  34351. * Creates a new instance of the component for the given scene
  34352. * @param scene Defines the scene to register the component in
  34353. */
  34354. constructor(scene: Scene);
  34355. /**
  34356. * Registers the component in a given scene
  34357. */
  34358. register(): void;
  34359. /**
  34360. * Rebuilds the elements related to this component in case of
  34361. * context lost for instance.
  34362. */
  34363. rebuild(): void;
  34364. /**
  34365. * Serializes the component data to the specified json object
  34366. * @param serializationObject The object to serialize to
  34367. */
  34368. serialize(serializationObject: any): void;
  34369. /**
  34370. * Adds all the element from the container to the scene
  34371. * @param container the container holding the elements
  34372. */
  34373. addFromContainer(container: AbstractScene): void;
  34374. /**
  34375. * Removes all the elements in the container from the scene
  34376. * @param container contains the elements to remove
  34377. */
  34378. removeFromContainer(container: AbstractScene): void;
  34379. /**
  34380. * Disposes the component and the associated ressources.
  34381. */
  34382. dispose(): void;
  34383. /**
  34384. * Disables audio in the associated scene.
  34385. */
  34386. disableAudio(): void;
  34387. /**
  34388. * Enables audio in the associated scene.
  34389. */
  34390. enableAudio(): void;
  34391. /**
  34392. * Switch audio to headphone output.
  34393. */
  34394. switchAudioModeForHeadphones(): void;
  34395. /**
  34396. * Switch audio to normal speakers.
  34397. */
  34398. switchAudioModeForNormalSpeakers(): void;
  34399. private _afterRender;
  34400. }
  34401. }
  34402. declare module "babylonjs/Audio/weightedsound" {
  34403. import { Sound } from "babylonjs/Audio/sound";
  34404. /**
  34405. * Wraps one or more Sound objects and selects one with random weight for playback.
  34406. */
  34407. export class WeightedSound {
  34408. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34409. loop: boolean;
  34410. private _coneInnerAngle;
  34411. private _coneOuterAngle;
  34412. private _volume;
  34413. /** A Sound is currently playing. */
  34414. isPlaying: boolean;
  34415. /** A Sound is currently paused. */
  34416. isPaused: boolean;
  34417. private _sounds;
  34418. private _weights;
  34419. private _currentIndex?;
  34420. /**
  34421. * Creates a new WeightedSound from the list of sounds given.
  34422. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34423. * @param sounds Array of Sounds that will be selected from.
  34424. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34425. */
  34426. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34427. /**
  34428. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34429. */
  34430. /**
  34431. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34432. */
  34433. directionalConeInnerAngle: number;
  34434. /**
  34435. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34436. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34437. */
  34438. /**
  34439. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34440. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34441. */
  34442. directionalConeOuterAngle: number;
  34443. /**
  34444. * Playback volume.
  34445. */
  34446. /**
  34447. * Playback volume.
  34448. */
  34449. volume: number;
  34450. private _onended;
  34451. /**
  34452. * Suspend playback
  34453. */
  34454. pause(): void;
  34455. /**
  34456. * Stop playback
  34457. */
  34458. stop(): void;
  34459. /**
  34460. * Start playback.
  34461. * @param startOffset Position the clip head at a specific time in seconds.
  34462. */
  34463. play(startOffset?: number): void;
  34464. }
  34465. }
  34466. declare module "babylonjs/Audio/index" {
  34467. export * from "babylonjs/Audio/analyser";
  34468. export * from "babylonjs/Audio/audioEngine";
  34469. export * from "babylonjs/Audio/audioSceneComponent";
  34470. export * from "babylonjs/Audio/sound";
  34471. export * from "babylonjs/Audio/soundTrack";
  34472. export * from "babylonjs/Audio/weightedsound";
  34473. }
  34474. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34475. import { Behavior } from "babylonjs/Behaviors/behavior";
  34476. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34477. import { BackEase } from "babylonjs/Animations/easing";
  34478. /**
  34479. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34480. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34481. */
  34482. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34483. /**
  34484. * Gets the name of the behavior.
  34485. */
  34486. readonly name: string;
  34487. /**
  34488. * The easing function used by animations
  34489. */
  34490. static EasingFunction: BackEase;
  34491. /**
  34492. * The easing mode used by animations
  34493. */
  34494. static EasingMode: number;
  34495. /**
  34496. * The duration of the animation, in milliseconds
  34497. */
  34498. transitionDuration: number;
  34499. /**
  34500. * Length of the distance animated by the transition when lower radius is reached
  34501. */
  34502. lowerRadiusTransitionRange: number;
  34503. /**
  34504. * Length of the distance animated by the transition when upper radius is reached
  34505. */
  34506. upperRadiusTransitionRange: number;
  34507. private _autoTransitionRange;
  34508. /**
  34509. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34510. */
  34511. /**
  34512. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34513. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34514. */
  34515. autoTransitionRange: boolean;
  34516. private _attachedCamera;
  34517. private _onAfterCheckInputsObserver;
  34518. private _onMeshTargetChangedObserver;
  34519. /**
  34520. * Initializes the behavior.
  34521. */
  34522. init(): void;
  34523. /**
  34524. * Attaches the behavior to its arc rotate camera.
  34525. * @param camera Defines the camera to attach the behavior to
  34526. */
  34527. attach(camera: ArcRotateCamera): void;
  34528. /**
  34529. * Detaches the behavior from its current arc rotate camera.
  34530. */
  34531. detach(): void;
  34532. private _radiusIsAnimating;
  34533. private _radiusBounceTransition;
  34534. private _animatables;
  34535. private _cachedWheelPrecision;
  34536. /**
  34537. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34538. * @param radiusLimit The limit to check against.
  34539. * @return Bool to indicate if at limit.
  34540. */
  34541. private _isRadiusAtLimit;
  34542. /**
  34543. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34544. * @param radiusDelta The delta by which to animate to. Can be negative.
  34545. */
  34546. private _applyBoundRadiusAnimation;
  34547. /**
  34548. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34549. */
  34550. protected _clearAnimationLocks(): void;
  34551. /**
  34552. * Stops and removes all animations that have been applied to the camera
  34553. */
  34554. stopAllAnimations(): void;
  34555. }
  34556. }
  34557. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34558. import { Behavior } from "babylonjs/Behaviors/behavior";
  34559. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34560. import { ExponentialEase } from "babylonjs/Animations/easing";
  34561. import { Nullable } from "babylonjs/types";
  34562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34563. import { Vector3 } from "babylonjs/Maths/math";
  34564. /**
  34565. * 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.
  34566. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34567. */
  34568. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34569. /**
  34570. * Gets the name of the behavior.
  34571. */
  34572. readonly name: string;
  34573. private _mode;
  34574. private _radiusScale;
  34575. private _positionScale;
  34576. private _defaultElevation;
  34577. private _elevationReturnTime;
  34578. private _elevationReturnWaitTime;
  34579. private _zoomStopsAnimation;
  34580. private _framingTime;
  34581. /**
  34582. * The easing function used by animations
  34583. */
  34584. static EasingFunction: ExponentialEase;
  34585. /**
  34586. * The easing mode used by animations
  34587. */
  34588. static EasingMode: number;
  34589. /**
  34590. * Sets the current mode used by the behavior
  34591. */
  34592. /**
  34593. * Gets current mode used by the behavior.
  34594. */
  34595. mode: number;
  34596. /**
  34597. * Sets the scale applied to the radius (1 by default)
  34598. */
  34599. /**
  34600. * Gets the scale applied to the radius
  34601. */
  34602. radiusScale: number;
  34603. /**
  34604. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34605. */
  34606. /**
  34607. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34608. */
  34609. positionScale: number;
  34610. /**
  34611. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34612. * behaviour is triggered, in radians.
  34613. */
  34614. /**
  34615. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34616. * behaviour is triggered, in radians.
  34617. */
  34618. defaultElevation: number;
  34619. /**
  34620. * Sets the time (in milliseconds) taken to return to the default beta position.
  34621. * Negative value indicates camera should not return to default.
  34622. */
  34623. /**
  34624. * Gets the time (in milliseconds) taken to return to the default beta position.
  34625. * Negative value indicates camera should not return to default.
  34626. */
  34627. elevationReturnTime: number;
  34628. /**
  34629. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34630. */
  34631. /**
  34632. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34633. */
  34634. elevationReturnWaitTime: number;
  34635. /**
  34636. * Sets the flag that indicates if user zooming should stop animation.
  34637. */
  34638. /**
  34639. * Gets the flag that indicates if user zooming should stop animation.
  34640. */
  34641. zoomStopsAnimation: boolean;
  34642. /**
  34643. * Sets the transition time when framing the mesh, in milliseconds
  34644. */
  34645. /**
  34646. * Gets the transition time when framing the mesh, in milliseconds
  34647. */
  34648. framingTime: number;
  34649. /**
  34650. * Define if the behavior should automatically change the configured
  34651. * camera limits and sensibilities.
  34652. */
  34653. autoCorrectCameraLimitsAndSensibility: boolean;
  34654. private _onPrePointerObservableObserver;
  34655. private _onAfterCheckInputsObserver;
  34656. private _onMeshTargetChangedObserver;
  34657. private _attachedCamera;
  34658. private _isPointerDown;
  34659. private _lastInteractionTime;
  34660. /**
  34661. * Initializes the behavior.
  34662. */
  34663. init(): void;
  34664. /**
  34665. * Attaches the behavior to its arc rotate camera.
  34666. * @param camera Defines the camera to attach the behavior to
  34667. */
  34668. attach(camera: ArcRotateCamera): void;
  34669. /**
  34670. * Detaches the behavior from its current arc rotate camera.
  34671. */
  34672. detach(): void;
  34673. private _animatables;
  34674. private _betaIsAnimating;
  34675. private _betaTransition;
  34676. private _radiusTransition;
  34677. private _vectorTransition;
  34678. /**
  34679. * Targets the given mesh and updates zoom level accordingly.
  34680. * @param mesh The mesh to target.
  34681. * @param radius Optional. If a cached radius position already exists, overrides default.
  34682. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34683. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34684. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34685. */
  34686. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34687. /**
  34688. * Targets the given mesh with its children and updates zoom level accordingly.
  34689. * @param mesh The mesh to target.
  34690. * @param radius Optional. If a cached radius position already exists, overrides default.
  34691. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34692. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34693. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34694. */
  34695. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34696. /**
  34697. * Targets the given meshes with their children and updates zoom level accordingly.
  34698. * @param meshes The mesh to target.
  34699. * @param radius Optional. If a cached radius position already exists, overrides default.
  34700. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34701. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34702. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34703. */
  34704. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34705. /**
  34706. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34707. * @param minimumWorld Determines the smaller position of the bounding box extend
  34708. * @param maximumWorld Determines the bigger position of the bounding box extend
  34709. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34710. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34711. */
  34712. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34713. /**
  34714. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34715. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34716. * frustum width.
  34717. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34718. * to fully enclose the mesh in the viewing frustum.
  34719. */
  34720. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34721. /**
  34722. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34723. * is automatically returned to its default position (expected to be above ground plane).
  34724. */
  34725. private _maintainCameraAboveGround;
  34726. /**
  34727. * Returns the frustum slope based on the canvas ratio and camera FOV
  34728. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34729. */
  34730. private _getFrustumSlope;
  34731. /**
  34732. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34733. */
  34734. private _clearAnimationLocks;
  34735. /**
  34736. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34737. */
  34738. private _applyUserInteraction;
  34739. /**
  34740. * Stops and removes all animations that have been applied to the camera
  34741. */
  34742. stopAllAnimations(): void;
  34743. /**
  34744. * Gets a value indicating if the user is moving the camera
  34745. */
  34746. readonly isUserIsMoving: boolean;
  34747. /**
  34748. * The camera can move all the way towards the mesh.
  34749. */
  34750. static IgnoreBoundsSizeMode: number;
  34751. /**
  34752. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34753. */
  34754. static FitFrustumSidesMode: number;
  34755. }
  34756. }
  34757. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  34758. import { Nullable } from "babylonjs/types";
  34759. import { Camera } from "babylonjs/Cameras/camera";
  34760. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34761. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34762. /**
  34763. * Base class for Camera Pointer Inputs.
  34764. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34765. * for example usage.
  34766. */
  34767. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34768. /**
  34769. * Defines the camera the input is attached to.
  34770. */
  34771. abstract camera: Camera;
  34772. /**
  34773. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34774. */
  34775. protected _altKey: boolean;
  34776. protected _ctrlKey: boolean;
  34777. protected _metaKey: boolean;
  34778. protected _shiftKey: boolean;
  34779. /**
  34780. * Which mouse buttons were pressed at time of last mouse event.
  34781. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34782. */
  34783. protected _buttonsPressed: number;
  34784. /**
  34785. * Defines the buttons associated with the input to handle camera move.
  34786. */
  34787. buttons: number[];
  34788. /**
  34789. * Attach the input controls to a specific dom element to get the input from.
  34790. * @param element Defines the element the controls should be listened from
  34791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34792. */
  34793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34794. /**
  34795. * Detach the current controls from the specified dom element.
  34796. * @param element Defines the element to stop listening the inputs from
  34797. */
  34798. detachControl(element: Nullable<HTMLElement>): void;
  34799. /**
  34800. * Gets the class name of the current input.
  34801. * @returns the class name
  34802. */
  34803. getClassName(): string;
  34804. /**
  34805. * Get the friendly name associated with the input class.
  34806. * @returns the input friendly name
  34807. */
  34808. getSimpleName(): string;
  34809. /**
  34810. * Called on pointer POINTERDOUBLETAP event.
  34811. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34812. */
  34813. protected onDoubleTap(type: string): void;
  34814. /**
  34815. * Called on pointer POINTERMOVE event if only a single touch is active.
  34816. * Override this method to provide functionality.
  34817. */
  34818. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34819. /**
  34820. * Called on pointer POINTERMOVE event if multiple touches are active.
  34821. * Override this method to provide functionality.
  34822. */
  34823. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34824. /**
  34825. * Called on JS contextmenu event.
  34826. * Override this method to provide functionality.
  34827. */
  34828. protected onContextMenu(evt: PointerEvent): void;
  34829. /**
  34830. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34831. * press.
  34832. * Override this method to provide functionality.
  34833. */
  34834. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34835. /**
  34836. * Called each time a new POINTERUP event occurs. Ie, for each button
  34837. * release.
  34838. * Override this method to provide functionality.
  34839. */
  34840. protected onButtonUp(evt: PointerEvent): void;
  34841. /**
  34842. * Called when window becomes inactive.
  34843. * Override this method to provide functionality.
  34844. */
  34845. protected onLostFocus(): void;
  34846. private _pointerInput;
  34847. private _observer;
  34848. private _onLostFocus;
  34849. }
  34850. }
  34851. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34852. import { Nullable } from "babylonjs/types";
  34853. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34854. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  34855. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  34856. /**
  34857. * Manage the pointers inputs to control an arc rotate camera.
  34858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34859. */
  34860. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34861. /**
  34862. * Defines the camera the input is attached to.
  34863. */
  34864. camera: ArcRotateCamera;
  34865. /**
  34866. * Gets the class name of the current input.
  34867. * @returns the class name
  34868. */
  34869. getClassName(): string;
  34870. /**
  34871. * Defines the buttons associated with the input to handle camera move.
  34872. */
  34873. buttons: number[];
  34874. /**
  34875. * Defines the pointer angular sensibility along the X axis or how fast is
  34876. * the camera rotating.
  34877. */
  34878. angularSensibilityX: number;
  34879. /**
  34880. * Defines the pointer angular sensibility along the Y axis or how fast is
  34881. * the camera rotating.
  34882. */
  34883. angularSensibilityY: number;
  34884. /**
  34885. * Defines the pointer pinch precision or how fast is the camera zooming.
  34886. */
  34887. pinchPrecision: number;
  34888. /**
  34889. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34890. * from 0.
  34891. * It defines the percentage of current camera.radius to use as delta when
  34892. * pinch zoom is used.
  34893. */
  34894. pinchDeltaPercentage: number;
  34895. /**
  34896. * Defines the pointer panning sensibility or how fast is the camera moving.
  34897. */
  34898. panningSensibility: number;
  34899. /**
  34900. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34901. */
  34902. multiTouchPanning: boolean;
  34903. /**
  34904. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34905. * zoom (pinch) through multitouch.
  34906. */
  34907. multiTouchPanAndZoom: boolean;
  34908. /**
  34909. * Revers pinch action direction.
  34910. */
  34911. pinchInwards: boolean;
  34912. private _isPanClick;
  34913. private _twoFingerActivityCount;
  34914. private _isPinching;
  34915. /**
  34916. * Called on pointer POINTERMOVE event if only a single touch is active.
  34917. */
  34918. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34919. /**
  34920. * Called on pointer POINTERDOUBLETAP event.
  34921. */
  34922. protected onDoubleTap(type: string): void;
  34923. /**
  34924. * Called on pointer POINTERMOVE event if multiple touches are active.
  34925. */
  34926. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34927. /**
  34928. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34929. * press.
  34930. */
  34931. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  34932. /**
  34933. * Called each time a new POINTERUP event occurs. Ie, for each button
  34934. * release.
  34935. */
  34936. protected onButtonUp(evt: PointerEvent): void;
  34937. /**
  34938. * Called when window becomes inactive.
  34939. */
  34940. protected onLostFocus(): void;
  34941. }
  34942. }
  34943. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34944. import { Nullable } from "babylonjs/types";
  34945. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34946. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34947. /**
  34948. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34950. */
  34951. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34952. /**
  34953. * Defines the camera the input is attached to.
  34954. */
  34955. camera: ArcRotateCamera;
  34956. /**
  34957. * Defines the list of key codes associated with the up action (increase alpha)
  34958. */
  34959. keysUp: number[];
  34960. /**
  34961. * Defines the list of key codes associated with the down action (decrease alpha)
  34962. */
  34963. keysDown: number[];
  34964. /**
  34965. * Defines the list of key codes associated with the left action (increase beta)
  34966. */
  34967. keysLeft: number[];
  34968. /**
  34969. * Defines the list of key codes associated with the right action (decrease beta)
  34970. */
  34971. keysRight: number[];
  34972. /**
  34973. * Defines the list of key codes associated with the reset action.
  34974. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34975. */
  34976. keysReset: number[];
  34977. /**
  34978. * Defines the panning sensibility of the inputs.
  34979. * (How fast is the camera paning)
  34980. */
  34981. panningSensibility: number;
  34982. /**
  34983. * Defines the zooming sensibility of the inputs.
  34984. * (How fast is the camera zooming)
  34985. */
  34986. zoomingSensibility: number;
  34987. /**
  34988. * Defines wether maintaining the alt key down switch the movement mode from
  34989. * orientation to zoom.
  34990. */
  34991. useAltToZoom: boolean;
  34992. /**
  34993. * Rotation speed of the camera
  34994. */
  34995. angularSpeed: number;
  34996. private _keys;
  34997. private _ctrlPressed;
  34998. private _altPressed;
  34999. private _onCanvasBlurObserver;
  35000. private _onKeyboardObserver;
  35001. private _engine;
  35002. private _scene;
  35003. /**
  35004. * Attach the input controls to a specific dom element to get the input from.
  35005. * @param element Defines the element the controls should be listened from
  35006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35007. */
  35008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35009. /**
  35010. * Detach the current controls from the specified dom element.
  35011. * @param element Defines the element to stop listening the inputs from
  35012. */
  35013. detachControl(element: Nullable<HTMLElement>): void;
  35014. /**
  35015. * Update the current camera state depending on the inputs that have been used this frame.
  35016. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35017. */
  35018. checkInputs(): void;
  35019. /**
  35020. * Gets the class name of the current intput.
  35021. * @returns the class name
  35022. */
  35023. getClassName(): string;
  35024. /**
  35025. * Get the friendly name associated with the input class.
  35026. * @returns the input friendly name
  35027. */
  35028. getSimpleName(): string;
  35029. }
  35030. }
  35031. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35032. import { Nullable } from "babylonjs/types";
  35033. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35034. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35035. /**
  35036. * Manage the mouse wheel inputs to control an arc rotate camera.
  35037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35038. */
  35039. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35040. /**
  35041. * Defines the camera the input is attached to.
  35042. */
  35043. camera: ArcRotateCamera;
  35044. /**
  35045. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35046. */
  35047. wheelPrecision: number;
  35048. /**
  35049. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35050. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35051. */
  35052. wheelDeltaPercentage: number;
  35053. private _wheel;
  35054. private _observer;
  35055. /**
  35056. * Attach the input controls to a specific dom element to get the input from.
  35057. * @param element Defines the element the controls should be listened from
  35058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35059. */
  35060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35061. /**
  35062. * Detach the current controls from the specified dom element.
  35063. * @param element Defines the element to stop listening the inputs from
  35064. */
  35065. detachControl(element: Nullable<HTMLElement>): void;
  35066. /**
  35067. * Gets the class name of the current intput.
  35068. * @returns the class name
  35069. */
  35070. getClassName(): string;
  35071. /**
  35072. * Get the friendly name associated with the input class.
  35073. * @returns the input friendly name
  35074. */
  35075. getSimpleName(): string;
  35076. }
  35077. }
  35078. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35079. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35080. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35081. /**
  35082. * Default Inputs manager for the ArcRotateCamera.
  35083. * It groups all the default supported inputs for ease of use.
  35084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35085. */
  35086. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35087. /**
  35088. * Instantiates a new ArcRotateCameraInputsManager.
  35089. * @param camera Defines the camera the inputs belong to
  35090. */
  35091. constructor(camera: ArcRotateCamera);
  35092. /**
  35093. * Add mouse wheel input support to the input manager.
  35094. * @returns the current input manager
  35095. */
  35096. addMouseWheel(): ArcRotateCameraInputsManager;
  35097. /**
  35098. * Add pointers input support to the input manager.
  35099. * @returns the current input manager
  35100. */
  35101. addPointers(): ArcRotateCameraInputsManager;
  35102. /**
  35103. * Add keyboard input support to the input manager.
  35104. * @returns the current input manager
  35105. */
  35106. addKeyboard(): ArcRotateCameraInputsManager;
  35107. }
  35108. }
  35109. declare module "babylonjs/Cameras/arcRotateCamera" {
  35110. import { Observable } from "babylonjs/Misc/observable";
  35111. import { Nullable } from "babylonjs/types";
  35112. import { Scene } from "babylonjs/scene";
  35113. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35115. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35116. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35117. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35118. import { Camera } from "babylonjs/Cameras/camera";
  35119. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35120. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35121. import { Collider } from "babylonjs/Collisions/collider";
  35122. /**
  35123. * This represents an orbital type of camera.
  35124. *
  35125. * 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.
  35126. * 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.
  35127. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35128. */
  35129. export class ArcRotateCamera extends TargetCamera {
  35130. /**
  35131. * Defines the rotation angle of the camera along the longitudinal axis.
  35132. */
  35133. alpha: number;
  35134. /**
  35135. * Defines the rotation angle of the camera along the latitudinal axis.
  35136. */
  35137. beta: number;
  35138. /**
  35139. * Defines the radius of the camera from it s target point.
  35140. */
  35141. radius: number;
  35142. protected _target: Vector3;
  35143. protected _targetHost: Nullable<AbstractMesh>;
  35144. /**
  35145. * Defines the target point of the camera.
  35146. * The camera looks towards it form the radius distance.
  35147. */
  35148. target: Vector3;
  35149. /**
  35150. * Define the current local position of the camera in the scene
  35151. */
  35152. position: Vector3;
  35153. /**
  35154. * Current inertia value on the longitudinal axis.
  35155. * The bigger this number the longer it will take for the camera to stop.
  35156. */
  35157. inertialAlphaOffset: number;
  35158. /**
  35159. * Current inertia value on the latitudinal axis.
  35160. * The bigger this number the longer it will take for the camera to stop.
  35161. */
  35162. inertialBetaOffset: number;
  35163. /**
  35164. * Current inertia value on the radius axis.
  35165. * The bigger this number the longer it will take for the camera to stop.
  35166. */
  35167. inertialRadiusOffset: number;
  35168. /**
  35169. * Minimum allowed angle on the longitudinal axis.
  35170. * This can help limiting how the Camera is able to move in the scene.
  35171. */
  35172. lowerAlphaLimit: Nullable<number>;
  35173. /**
  35174. * Maximum allowed angle on the longitudinal axis.
  35175. * This can help limiting how the Camera is able to move in the scene.
  35176. */
  35177. upperAlphaLimit: Nullable<number>;
  35178. /**
  35179. * Minimum allowed angle on the latitudinal axis.
  35180. * This can help limiting how the Camera is able to move in the scene.
  35181. */
  35182. lowerBetaLimit: number;
  35183. /**
  35184. * Maximum allowed angle on the latitudinal axis.
  35185. * This can help limiting how the Camera is able to move in the scene.
  35186. */
  35187. upperBetaLimit: number;
  35188. /**
  35189. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35190. * This can help limiting how the Camera is able to move in the scene.
  35191. */
  35192. lowerRadiusLimit: Nullable<number>;
  35193. /**
  35194. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35195. * This can help limiting how the Camera is able to move in the scene.
  35196. */
  35197. upperRadiusLimit: Nullable<number>;
  35198. /**
  35199. * Defines the current inertia value used during panning of the camera along the X axis.
  35200. */
  35201. inertialPanningX: number;
  35202. /**
  35203. * Defines the current inertia value used during panning of the camera along the Y axis.
  35204. */
  35205. inertialPanningY: number;
  35206. /**
  35207. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35208. * Basically if your fingers moves away from more than this distance you will be considered
  35209. * in pinch mode.
  35210. */
  35211. pinchToPanMaxDistance: number;
  35212. /**
  35213. * Defines the maximum distance the camera can pan.
  35214. * This could help keeping the cammera always in your scene.
  35215. */
  35216. panningDistanceLimit: Nullable<number>;
  35217. /**
  35218. * Defines the target of the camera before paning.
  35219. */
  35220. panningOriginTarget: Vector3;
  35221. /**
  35222. * Defines the value of the inertia used during panning.
  35223. * 0 would mean stop inertia and one would mean no decelleration at all.
  35224. */
  35225. panningInertia: number;
  35226. /**
  35227. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35228. */
  35229. angularSensibilityX: number;
  35230. /**
  35231. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35232. */
  35233. angularSensibilityY: number;
  35234. /**
  35235. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35236. */
  35237. pinchPrecision: number;
  35238. /**
  35239. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35240. * It will be used instead of pinchDeltaPrecision if different from 0.
  35241. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35242. */
  35243. pinchDeltaPercentage: number;
  35244. /**
  35245. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35246. */
  35247. panningSensibility: number;
  35248. /**
  35249. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35250. */
  35251. keysUp: number[];
  35252. /**
  35253. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35254. */
  35255. keysDown: number[];
  35256. /**
  35257. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35258. */
  35259. keysLeft: number[];
  35260. /**
  35261. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35262. */
  35263. keysRight: number[];
  35264. /**
  35265. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35266. */
  35267. wheelPrecision: number;
  35268. /**
  35269. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35270. * It will be used instead of pinchDeltaPrecision if different from 0.
  35271. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35272. */
  35273. wheelDeltaPercentage: number;
  35274. /**
  35275. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35276. */
  35277. zoomOnFactor: number;
  35278. /**
  35279. * Defines a screen offset for the camera position.
  35280. */
  35281. targetScreenOffset: Vector2;
  35282. /**
  35283. * Allows the camera to be completely reversed.
  35284. * If false the camera can not arrive upside down.
  35285. */
  35286. allowUpsideDown: boolean;
  35287. /**
  35288. * Define if double tap/click is used to restore the previously saved state of the camera.
  35289. */
  35290. useInputToRestoreState: boolean;
  35291. /** @hidden */
  35292. _viewMatrix: Matrix;
  35293. /** @hidden */
  35294. _useCtrlForPanning: boolean;
  35295. /** @hidden */
  35296. _panningMouseButton: number;
  35297. /**
  35298. * Defines the input associated to the camera.
  35299. */
  35300. inputs: ArcRotateCameraInputsManager;
  35301. /** @hidden */
  35302. _reset: () => void;
  35303. /**
  35304. * Defines the allowed panning axis.
  35305. */
  35306. panningAxis: Vector3;
  35307. protected _localDirection: Vector3;
  35308. protected _transformedDirection: Vector3;
  35309. private _bouncingBehavior;
  35310. /**
  35311. * Gets the bouncing behavior of the camera if it has been enabled.
  35312. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35313. */
  35314. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35315. /**
  35316. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35317. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35318. */
  35319. useBouncingBehavior: boolean;
  35320. private _framingBehavior;
  35321. /**
  35322. * Gets the framing behavior of the camera if it has been enabled.
  35323. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35324. */
  35325. readonly framingBehavior: Nullable<FramingBehavior>;
  35326. /**
  35327. * Defines if the framing behavior of the camera is enabled on the camera.
  35328. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35329. */
  35330. useFramingBehavior: boolean;
  35331. private _autoRotationBehavior;
  35332. /**
  35333. * Gets the auto rotation behavior of the camera if it has been enabled.
  35334. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35335. */
  35336. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35337. /**
  35338. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35339. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35340. */
  35341. useAutoRotationBehavior: boolean;
  35342. /**
  35343. * Observable triggered when the mesh target has been changed on the camera.
  35344. */
  35345. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35346. /**
  35347. * Event raised when the camera is colliding with a mesh.
  35348. */
  35349. onCollide: (collidedMesh: AbstractMesh) => void;
  35350. /**
  35351. * Defines whether the camera should check collision with the objects oh the scene.
  35352. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35353. */
  35354. checkCollisions: boolean;
  35355. /**
  35356. * Defines the collision radius of the camera.
  35357. * This simulates a sphere around the camera.
  35358. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35359. */
  35360. collisionRadius: Vector3;
  35361. protected _collider: Collider;
  35362. protected _previousPosition: Vector3;
  35363. protected _collisionVelocity: Vector3;
  35364. protected _newPosition: Vector3;
  35365. protected _previousAlpha: number;
  35366. protected _previousBeta: number;
  35367. protected _previousRadius: number;
  35368. protected _collisionTriggered: boolean;
  35369. protected _targetBoundingCenter: Nullable<Vector3>;
  35370. private _computationVector;
  35371. private _tempAxisVector;
  35372. private _tempAxisRotationMatrix;
  35373. /**
  35374. * Instantiates a new ArcRotateCamera in a given scene
  35375. * @param name Defines the name of the camera
  35376. * @param alpha Defines the camera rotation along the logitudinal axis
  35377. * @param beta Defines the camera rotation along the latitudinal axis
  35378. * @param radius Defines the camera distance from its target
  35379. * @param target Defines the camera target
  35380. * @param scene Defines the scene the camera belongs to
  35381. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35382. */
  35383. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35384. /** @hidden */
  35385. _initCache(): void;
  35386. /** @hidden */
  35387. _updateCache(ignoreParentClass?: boolean): void;
  35388. protected _getTargetPosition(): Vector3;
  35389. private _storedAlpha;
  35390. private _storedBeta;
  35391. private _storedRadius;
  35392. private _storedTarget;
  35393. /**
  35394. * Stores the current state of the camera (alpha, beta, radius and target)
  35395. * @returns the camera itself
  35396. */
  35397. storeState(): Camera;
  35398. /**
  35399. * @hidden
  35400. * Restored camera state. You must call storeState() first
  35401. */
  35402. _restoreStateValues(): boolean;
  35403. /** @hidden */
  35404. _isSynchronizedViewMatrix(): boolean;
  35405. /**
  35406. * Attached controls to the current camera.
  35407. * @param element Defines the element the controls should be listened from
  35408. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35409. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35410. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35411. */
  35412. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35413. /**
  35414. * Detach the current controls from the camera.
  35415. * The camera will stop reacting to inputs.
  35416. * @param element Defines the element to stop listening the inputs from
  35417. */
  35418. detachControl(element: HTMLElement): void;
  35419. /** @hidden */
  35420. _checkInputs(): void;
  35421. protected _checkLimits(): void;
  35422. /**
  35423. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35424. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35425. */
  35426. rebuildAnglesAndRadius(updateView?: boolean): void;
  35427. /**
  35428. * Use a position to define the current camera related information like aplha, beta and radius
  35429. * @param position Defines the position to set the camera at
  35430. */
  35431. setPosition(position: Vector3): void;
  35432. /**
  35433. * Defines the target the camera should look at.
  35434. * This will automatically adapt alpha beta and radius to fit within the new target.
  35435. * @param target Defines the new target as a Vector or a mesh
  35436. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35437. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35438. */
  35439. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35440. /** @hidden */
  35441. _getViewMatrix(): Matrix;
  35442. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35443. /**
  35444. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35445. * @param meshes Defines the mesh to zoom on
  35446. * @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)
  35447. */
  35448. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35449. /**
  35450. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35451. * The target will be changed but the radius
  35452. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35453. * @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)
  35454. */
  35455. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35456. min: Vector3;
  35457. max: Vector3;
  35458. distance: number;
  35459. }, doNotUpdateMaxZ?: boolean): void;
  35460. /**
  35461. * @override
  35462. * Override Camera.createRigCamera
  35463. */
  35464. createRigCamera(name: string, cameraIndex: number): Camera;
  35465. /**
  35466. * @hidden
  35467. * @override
  35468. * Override Camera._updateRigCameras
  35469. */
  35470. _updateRigCameras(): void;
  35471. /**
  35472. * Destroy the camera and release the current resources hold by it.
  35473. */
  35474. dispose(): void;
  35475. /**
  35476. * Gets the current object class name.
  35477. * @return the class name
  35478. */
  35479. getClassName(): string;
  35480. }
  35481. }
  35482. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35483. import { Behavior } from "babylonjs/Behaviors/behavior";
  35484. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35485. /**
  35486. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35487. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35488. */
  35489. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35490. /**
  35491. * Gets the name of the behavior.
  35492. */
  35493. readonly name: string;
  35494. private _zoomStopsAnimation;
  35495. private _idleRotationSpeed;
  35496. private _idleRotationWaitTime;
  35497. private _idleRotationSpinupTime;
  35498. /**
  35499. * Sets the flag that indicates if user zooming should stop animation.
  35500. */
  35501. /**
  35502. * Gets the flag that indicates if user zooming should stop animation.
  35503. */
  35504. zoomStopsAnimation: boolean;
  35505. /**
  35506. * Sets the default speed at which the camera rotates around the model.
  35507. */
  35508. /**
  35509. * Gets the default speed at which the camera rotates around the model.
  35510. */
  35511. idleRotationSpeed: number;
  35512. /**
  35513. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35514. */
  35515. /**
  35516. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35517. */
  35518. idleRotationWaitTime: number;
  35519. /**
  35520. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35521. */
  35522. /**
  35523. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35524. */
  35525. idleRotationSpinupTime: number;
  35526. /**
  35527. * Gets a value indicating if the camera is currently rotating because of this behavior
  35528. */
  35529. readonly rotationInProgress: boolean;
  35530. private _onPrePointerObservableObserver;
  35531. private _onAfterCheckInputsObserver;
  35532. private _attachedCamera;
  35533. private _isPointerDown;
  35534. private _lastFrameTime;
  35535. private _lastInteractionTime;
  35536. private _cameraRotationSpeed;
  35537. /**
  35538. * Initializes the behavior.
  35539. */
  35540. init(): void;
  35541. /**
  35542. * Attaches the behavior to its arc rotate camera.
  35543. * @param camera Defines the camera to attach the behavior to
  35544. */
  35545. attach(camera: ArcRotateCamera): void;
  35546. /**
  35547. * Detaches the behavior from its current arc rotate camera.
  35548. */
  35549. detach(): void;
  35550. /**
  35551. * Returns true if user is scrolling.
  35552. * @return true if user is scrolling.
  35553. */
  35554. private _userIsZooming;
  35555. private _lastFrameRadius;
  35556. private _shouldAnimationStopForInteraction;
  35557. /**
  35558. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35559. */
  35560. private _applyUserInteraction;
  35561. private _userIsMoving;
  35562. }
  35563. }
  35564. declare module "babylonjs/Behaviors/Cameras/index" {
  35565. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35566. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35567. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35568. }
  35569. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35570. import { Mesh } from "babylonjs/Meshes/mesh";
  35571. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35572. import { Behavior } from "babylonjs/Behaviors/behavior";
  35573. /**
  35574. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35575. */
  35576. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35577. private ui;
  35578. /**
  35579. * The name of the behavior
  35580. */
  35581. name: string;
  35582. /**
  35583. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35584. */
  35585. distanceAwayFromFace: number;
  35586. /**
  35587. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35588. */
  35589. distanceAwayFromBottomOfFace: number;
  35590. private _faceVectors;
  35591. private _target;
  35592. private _scene;
  35593. private _onRenderObserver;
  35594. private _tmpMatrix;
  35595. private _tmpVector;
  35596. /**
  35597. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35598. * @param ui The transform node that should be attched to the mesh
  35599. */
  35600. constructor(ui: TransformNode);
  35601. /**
  35602. * Initializes the behavior
  35603. */
  35604. init(): void;
  35605. private _closestFace;
  35606. private _zeroVector;
  35607. private _lookAtTmpMatrix;
  35608. private _lookAtToRef;
  35609. /**
  35610. * Attaches the AttachToBoxBehavior to the passed in mesh
  35611. * @param target The mesh that the specified node will be attached to
  35612. */
  35613. attach(target: Mesh): void;
  35614. /**
  35615. * Detaches the behavior from the mesh
  35616. */
  35617. detach(): void;
  35618. }
  35619. }
  35620. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35621. import { Behavior } from "babylonjs/Behaviors/behavior";
  35622. import { Mesh } from "babylonjs/Meshes/mesh";
  35623. /**
  35624. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35625. */
  35626. export class FadeInOutBehavior implements Behavior<Mesh> {
  35627. /**
  35628. * Time in milliseconds to delay before fading in (Default: 0)
  35629. */
  35630. delay: number;
  35631. /**
  35632. * Time in milliseconds for the mesh to fade in (Default: 300)
  35633. */
  35634. fadeInTime: number;
  35635. private _millisecondsPerFrame;
  35636. private _hovered;
  35637. private _hoverValue;
  35638. private _ownerNode;
  35639. /**
  35640. * Instatiates the FadeInOutBehavior
  35641. */
  35642. constructor();
  35643. /**
  35644. * The name of the behavior
  35645. */
  35646. readonly name: string;
  35647. /**
  35648. * Initializes the behavior
  35649. */
  35650. init(): void;
  35651. /**
  35652. * Attaches the fade behavior on the passed in mesh
  35653. * @param ownerNode The mesh that will be faded in/out once attached
  35654. */
  35655. attach(ownerNode: Mesh): void;
  35656. /**
  35657. * Detaches the behavior from the mesh
  35658. */
  35659. detach(): void;
  35660. /**
  35661. * Triggers the mesh to begin fading in or out
  35662. * @param value if the object should fade in or out (true to fade in)
  35663. */
  35664. fadeIn(value: boolean): void;
  35665. private _update;
  35666. private _setAllVisibility;
  35667. }
  35668. }
  35669. declare module "babylonjs/Misc/pivotTools" {
  35670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35671. /**
  35672. * Class containing a set of static utilities functions for managing Pivots
  35673. * @hidden
  35674. */
  35675. export class PivotTools {
  35676. private static _PivotCached;
  35677. private static _OldPivotPoint;
  35678. private static _PivotTranslation;
  35679. private static _PivotTmpVector;
  35680. /** @hidden */
  35681. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35682. /** @hidden */
  35683. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35684. }
  35685. }
  35686. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35687. import { Scene } from "babylonjs/scene";
  35688. import { Vector4, Plane } from "babylonjs/Maths/math";
  35689. import { Mesh } from "babylonjs/Meshes/mesh";
  35690. /**
  35691. * Class containing static functions to help procedurally build meshes
  35692. */
  35693. export class PlaneBuilder {
  35694. /**
  35695. * Creates a plane mesh
  35696. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35697. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35698. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35702. * @param name defines the name of the mesh
  35703. * @param options defines the options used to create the mesh
  35704. * @param scene defines the hosting scene
  35705. * @returns the plane mesh
  35706. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35707. */
  35708. static CreatePlane(name: string, options: {
  35709. size?: number;
  35710. width?: number;
  35711. height?: number;
  35712. sideOrientation?: number;
  35713. frontUVs?: Vector4;
  35714. backUVs?: Vector4;
  35715. updatable?: boolean;
  35716. sourcePlane?: Plane;
  35717. }, scene: Scene): Mesh;
  35718. }
  35719. }
  35720. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35721. import { Behavior } from "babylonjs/Behaviors/behavior";
  35722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35723. import { Observable } from "babylonjs/Misc/observable";
  35724. import { Vector3 } from "babylonjs/Maths/math";
  35725. import { Ray } from "babylonjs/Culling/ray";
  35726. import "babylonjs/Meshes/Builders/planeBuilder";
  35727. /**
  35728. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35729. */
  35730. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35731. private static _AnyMouseID;
  35732. private _attachedNode;
  35733. private _dragPlane;
  35734. private _scene;
  35735. private _pointerObserver;
  35736. private _beforeRenderObserver;
  35737. private static _planeScene;
  35738. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35739. /**
  35740. * 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)
  35741. */
  35742. maxDragAngle: number;
  35743. /**
  35744. * @hidden
  35745. */
  35746. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35747. /**
  35748. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35749. */
  35750. currentDraggingPointerID: number;
  35751. /**
  35752. * The last position where the pointer hit the drag plane in world space
  35753. */
  35754. lastDragPosition: Vector3;
  35755. /**
  35756. * If the behavior is currently in a dragging state
  35757. */
  35758. dragging: boolean;
  35759. /**
  35760. * 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)
  35761. */
  35762. dragDeltaRatio: number;
  35763. /**
  35764. * If the drag plane orientation should be updated during the dragging (Default: true)
  35765. */
  35766. updateDragPlane: boolean;
  35767. private _debugMode;
  35768. private _moving;
  35769. /**
  35770. * Fires each time the attached mesh is dragged with the pointer
  35771. * * delta between last drag position and current drag position in world space
  35772. * * dragDistance along the drag axis
  35773. * * dragPlaneNormal normal of the current drag plane used during the drag
  35774. * * dragPlanePoint in world space where the drag intersects the drag plane
  35775. */
  35776. onDragObservable: Observable<{
  35777. delta: Vector3;
  35778. dragPlanePoint: Vector3;
  35779. dragPlaneNormal: Vector3;
  35780. dragDistance: number;
  35781. pointerId: number;
  35782. }>;
  35783. /**
  35784. * Fires each time a drag begins (eg. mouse down on mesh)
  35785. */
  35786. onDragStartObservable: Observable<{
  35787. dragPlanePoint: Vector3;
  35788. pointerId: number;
  35789. }>;
  35790. /**
  35791. * Fires each time a drag ends (eg. mouse release after drag)
  35792. */
  35793. onDragEndObservable: Observable<{
  35794. dragPlanePoint: Vector3;
  35795. pointerId: number;
  35796. }>;
  35797. /**
  35798. * If the attached mesh should be moved when dragged
  35799. */
  35800. moveAttached: boolean;
  35801. /**
  35802. * If the drag behavior will react to drag events (Default: true)
  35803. */
  35804. enabled: boolean;
  35805. /**
  35806. * If camera controls should be detached during the drag
  35807. */
  35808. detachCameraControls: boolean;
  35809. /**
  35810. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35811. */
  35812. useObjectOrienationForDragging: boolean;
  35813. private _options;
  35814. /**
  35815. * Creates a pointer drag behavior that can be attached to a mesh
  35816. * @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)
  35817. */
  35818. constructor(options?: {
  35819. dragAxis?: Vector3;
  35820. dragPlaneNormal?: Vector3;
  35821. });
  35822. /**
  35823. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35824. */
  35825. validateDrag: (targetPosition: Vector3) => boolean;
  35826. /**
  35827. * The name of the behavior
  35828. */
  35829. readonly name: string;
  35830. /**
  35831. * Initializes the behavior
  35832. */
  35833. init(): void;
  35834. private _tmpVector;
  35835. private _alternatePickedPoint;
  35836. private _worldDragAxis;
  35837. private _targetPosition;
  35838. private _attachedElement;
  35839. /**
  35840. * Attaches the drag behavior the passed in mesh
  35841. * @param ownerNode The mesh that will be dragged around once attached
  35842. */
  35843. attach(ownerNode: AbstractMesh): void;
  35844. /**
  35845. * Force relase the drag action by code.
  35846. */
  35847. releaseDrag(): void;
  35848. private _startDragRay;
  35849. private _lastPointerRay;
  35850. /**
  35851. * Simulates the start of a pointer drag event on the behavior
  35852. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35853. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35854. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35855. */
  35856. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35857. private _startDrag;
  35858. private _dragDelta;
  35859. private _moveDrag;
  35860. private _pickWithRayOnDragPlane;
  35861. private _pointA;
  35862. private _pointB;
  35863. private _pointC;
  35864. private _lineA;
  35865. private _lineB;
  35866. private _localAxis;
  35867. private _lookAt;
  35868. private _updateDragPlanePosition;
  35869. /**
  35870. * Detaches the behavior from the mesh
  35871. */
  35872. detach(): void;
  35873. }
  35874. }
  35875. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35876. import { Mesh } from "babylonjs/Meshes/mesh";
  35877. import { Behavior } from "babylonjs/Behaviors/behavior";
  35878. /**
  35879. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35880. */
  35881. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35882. private _dragBehaviorA;
  35883. private _dragBehaviorB;
  35884. private _startDistance;
  35885. private _initialScale;
  35886. private _targetScale;
  35887. private _ownerNode;
  35888. private _sceneRenderObserver;
  35889. /**
  35890. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35891. */
  35892. constructor();
  35893. /**
  35894. * The name of the behavior
  35895. */
  35896. readonly name: string;
  35897. /**
  35898. * Initializes the behavior
  35899. */
  35900. init(): void;
  35901. private _getCurrentDistance;
  35902. /**
  35903. * Attaches the scale behavior the passed in mesh
  35904. * @param ownerNode The mesh that will be scaled around once attached
  35905. */
  35906. attach(ownerNode: Mesh): void;
  35907. /**
  35908. * Detaches the behavior from the mesh
  35909. */
  35910. detach(): void;
  35911. }
  35912. }
  35913. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35914. import { Behavior } from "babylonjs/Behaviors/behavior";
  35915. import { Mesh } from "babylonjs/Meshes/mesh";
  35916. import { Observable } from "babylonjs/Misc/observable";
  35917. /**
  35918. * 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
  35919. */
  35920. export class SixDofDragBehavior implements Behavior<Mesh> {
  35921. private static _virtualScene;
  35922. private _ownerNode;
  35923. private _sceneRenderObserver;
  35924. private _scene;
  35925. private _targetPosition;
  35926. private _virtualOriginMesh;
  35927. private _virtualDragMesh;
  35928. private _pointerObserver;
  35929. private _moving;
  35930. private _startingOrientation;
  35931. /**
  35932. * 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)
  35933. */
  35934. private zDragFactor;
  35935. /**
  35936. * If the object should rotate to face the drag origin
  35937. */
  35938. rotateDraggedObject: boolean;
  35939. /**
  35940. * If the behavior is currently in a dragging state
  35941. */
  35942. dragging: boolean;
  35943. /**
  35944. * 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)
  35945. */
  35946. dragDeltaRatio: number;
  35947. /**
  35948. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35949. */
  35950. currentDraggingPointerID: number;
  35951. /**
  35952. * If camera controls should be detached during the drag
  35953. */
  35954. detachCameraControls: boolean;
  35955. /**
  35956. * Fires each time a drag starts
  35957. */
  35958. onDragStartObservable: Observable<{}>;
  35959. /**
  35960. * Fires each time a drag ends (eg. mouse release after drag)
  35961. */
  35962. onDragEndObservable: Observable<{}>;
  35963. /**
  35964. * 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
  35965. */
  35966. constructor();
  35967. /**
  35968. * The name of the behavior
  35969. */
  35970. readonly name: string;
  35971. /**
  35972. * Initializes the behavior
  35973. */
  35974. init(): void;
  35975. /**
  35976. * Attaches the scale behavior the passed in mesh
  35977. * @param ownerNode The mesh that will be scaled around once attached
  35978. */
  35979. attach(ownerNode: Mesh): void;
  35980. /**
  35981. * Detaches the behavior from the mesh
  35982. */
  35983. detach(): void;
  35984. }
  35985. }
  35986. declare module "babylonjs/Behaviors/Meshes/index" {
  35987. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35988. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35989. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35990. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35991. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35992. }
  35993. declare module "babylonjs/Behaviors/index" {
  35994. export * from "babylonjs/Behaviors/behavior";
  35995. export * from "babylonjs/Behaviors/Cameras/index";
  35996. export * from "babylonjs/Behaviors/Meshes/index";
  35997. }
  35998. declare module "babylonjs/Bones/boneIKController" {
  35999. import { Bone } from "babylonjs/Bones/bone";
  36000. import { Vector3 } from "babylonjs/Maths/math";
  36001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36002. import { Nullable } from "babylonjs/types";
  36003. /**
  36004. * Class used to apply inverse kinematics to bones
  36005. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36006. */
  36007. export class BoneIKController {
  36008. private static _tmpVecs;
  36009. private static _tmpQuat;
  36010. private static _tmpMats;
  36011. /**
  36012. * Gets or sets the target mesh
  36013. */
  36014. targetMesh: AbstractMesh;
  36015. /** Gets or sets the mesh used as pole */
  36016. poleTargetMesh: AbstractMesh;
  36017. /**
  36018. * Gets or sets the bone used as pole
  36019. */
  36020. poleTargetBone: Nullable<Bone>;
  36021. /**
  36022. * Gets or sets the target position
  36023. */
  36024. targetPosition: Vector3;
  36025. /**
  36026. * Gets or sets the pole target position
  36027. */
  36028. poleTargetPosition: Vector3;
  36029. /**
  36030. * Gets or sets the pole target local offset
  36031. */
  36032. poleTargetLocalOffset: Vector3;
  36033. /**
  36034. * Gets or sets the pole angle
  36035. */
  36036. poleAngle: number;
  36037. /**
  36038. * Gets or sets the mesh associated with the controller
  36039. */
  36040. mesh: AbstractMesh;
  36041. /**
  36042. * 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)
  36043. */
  36044. slerpAmount: number;
  36045. private _bone1Quat;
  36046. private _bone1Mat;
  36047. private _bone2Ang;
  36048. private _bone1;
  36049. private _bone2;
  36050. private _bone1Length;
  36051. private _bone2Length;
  36052. private _maxAngle;
  36053. private _maxReach;
  36054. private _rightHandedSystem;
  36055. private _bendAxis;
  36056. private _slerping;
  36057. private _adjustRoll;
  36058. /**
  36059. * Gets or sets maximum allowed angle
  36060. */
  36061. maxAngle: number;
  36062. /**
  36063. * Creates a new BoneIKController
  36064. * @param mesh defines the mesh to control
  36065. * @param bone defines the bone to control
  36066. * @param options defines options to set up the controller
  36067. */
  36068. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36069. targetMesh?: AbstractMesh;
  36070. poleTargetMesh?: AbstractMesh;
  36071. poleTargetBone?: Bone;
  36072. poleTargetLocalOffset?: Vector3;
  36073. poleAngle?: number;
  36074. bendAxis?: Vector3;
  36075. maxAngle?: number;
  36076. slerpAmount?: number;
  36077. });
  36078. private _setMaxAngle;
  36079. /**
  36080. * Force the controller to update the bones
  36081. */
  36082. update(): void;
  36083. }
  36084. }
  36085. declare module "babylonjs/Bones/boneLookController" {
  36086. import { Vector3, Space } from "babylonjs/Maths/math";
  36087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36088. import { Bone } from "babylonjs/Bones/bone";
  36089. /**
  36090. * Class used to make a bone look toward a point in space
  36091. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36092. */
  36093. export class BoneLookController {
  36094. private static _tmpVecs;
  36095. private static _tmpQuat;
  36096. private static _tmpMats;
  36097. /**
  36098. * The target Vector3 that the bone will look at
  36099. */
  36100. target: Vector3;
  36101. /**
  36102. * The mesh that the bone is attached to
  36103. */
  36104. mesh: AbstractMesh;
  36105. /**
  36106. * The bone that will be looking to the target
  36107. */
  36108. bone: Bone;
  36109. /**
  36110. * The up axis of the coordinate system that is used when the bone is rotated
  36111. */
  36112. upAxis: Vector3;
  36113. /**
  36114. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36115. */
  36116. upAxisSpace: Space;
  36117. /**
  36118. * Used to make an adjustment to the yaw of the bone
  36119. */
  36120. adjustYaw: number;
  36121. /**
  36122. * Used to make an adjustment to the pitch of the bone
  36123. */
  36124. adjustPitch: number;
  36125. /**
  36126. * Used to make an adjustment to the roll of the bone
  36127. */
  36128. adjustRoll: number;
  36129. /**
  36130. * 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)
  36131. */
  36132. slerpAmount: number;
  36133. private _minYaw;
  36134. private _maxYaw;
  36135. private _minPitch;
  36136. private _maxPitch;
  36137. private _minYawSin;
  36138. private _minYawCos;
  36139. private _maxYawSin;
  36140. private _maxYawCos;
  36141. private _midYawConstraint;
  36142. private _minPitchTan;
  36143. private _maxPitchTan;
  36144. private _boneQuat;
  36145. private _slerping;
  36146. private _transformYawPitch;
  36147. private _transformYawPitchInv;
  36148. private _firstFrameSkipped;
  36149. private _yawRange;
  36150. private _fowardAxis;
  36151. /**
  36152. * Gets or sets the minimum yaw angle that the bone can look to
  36153. */
  36154. minYaw: number;
  36155. /**
  36156. * Gets or sets the maximum yaw angle that the bone can look to
  36157. */
  36158. maxYaw: number;
  36159. /**
  36160. * Gets or sets the minimum pitch angle that the bone can look to
  36161. */
  36162. minPitch: number;
  36163. /**
  36164. * Gets or sets the maximum pitch angle that the bone can look to
  36165. */
  36166. maxPitch: number;
  36167. /**
  36168. * Create a BoneLookController
  36169. * @param mesh the mesh that the bone belongs to
  36170. * @param bone the bone that will be looking to the target
  36171. * @param target the target Vector3 to look at
  36172. * @param options optional settings:
  36173. * * maxYaw: the maximum angle the bone will yaw to
  36174. * * minYaw: the minimum angle the bone will yaw to
  36175. * * maxPitch: the maximum angle the bone will pitch to
  36176. * * minPitch: the minimum angle the bone will yaw to
  36177. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36178. * * upAxis: the up axis of the coordinate system
  36179. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36180. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36181. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36182. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36183. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36184. * * adjustRoll: used to make an adjustment to the roll of the bone
  36185. **/
  36186. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36187. maxYaw?: number;
  36188. minYaw?: number;
  36189. maxPitch?: number;
  36190. minPitch?: number;
  36191. slerpAmount?: number;
  36192. upAxis?: Vector3;
  36193. upAxisSpace?: Space;
  36194. yawAxis?: Vector3;
  36195. pitchAxis?: Vector3;
  36196. adjustYaw?: number;
  36197. adjustPitch?: number;
  36198. adjustRoll?: number;
  36199. });
  36200. /**
  36201. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36202. */
  36203. update(): void;
  36204. private _getAngleDiff;
  36205. private _getAngleBetween;
  36206. private _isAngleBetween;
  36207. }
  36208. }
  36209. declare module "babylonjs/Bones/index" {
  36210. export * from "babylonjs/Bones/bone";
  36211. export * from "babylonjs/Bones/boneIKController";
  36212. export * from "babylonjs/Bones/boneLookController";
  36213. export * from "babylonjs/Bones/skeleton";
  36214. }
  36215. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36216. import { Nullable } from "babylonjs/types";
  36217. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36218. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36219. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36220. /**
  36221. * Manage the gamepad inputs to control an arc rotate camera.
  36222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36223. */
  36224. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36225. /**
  36226. * Defines the camera the input is attached to.
  36227. */
  36228. camera: ArcRotateCamera;
  36229. /**
  36230. * Defines the gamepad the input is gathering event from.
  36231. */
  36232. gamepad: Nullable<Gamepad>;
  36233. /**
  36234. * Defines the gamepad rotation sensiblity.
  36235. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36236. */
  36237. gamepadRotationSensibility: number;
  36238. /**
  36239. * Defines the gamepad move sensiblity.
  36240. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36241. */
  36242. gamepadMoveSensibility: number;
  36243. private _onGamepadConnectedObserver;
  36244. private _onGamepadDisconnectedObserver;
  36245. /**
  36246. * Attach the input controls to a specific dom element to get the input from.
  36247. * @param element Defines the element the controls should be listened from
  36248. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36249. */
  36250. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36251. /**
  36252. * Detach the current controls from the specified dom element.
  36253. * @param element Defines the element to stop listening the inputs from
  36254. */
  36255. detachControl(element: Nullable<HTMLElement>): void;
  36256. /**
  36257. * Update the current camera state depending on the inputs that have been used this frame.
  36258. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36259. */
  36260. checkInputs(): void;
  36261. /**
  36262. * Gets the class name of the current intput.
  36263. * @returns the class name
  36264. */
  36265. getClassName(): string;
  36266. /**
  36267. * Get the friendly name associated with the input class.
  36268. * @returns the input friendly name
  36269. */
  36270. getSimpleName(): string;
  36271. }
  36272. }
  36273. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36274. import { Nullable } from "babylonjs/types";
  36275. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36276. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36277. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36278. interface ArcRotateCameraInputsManager {
  36279. /**
  36280. * Add orientation input support to the input manager.
  36281. * @returns the current input manager
  36282. */
  36283. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36284. }
  36285. }
  36286. /**
  36287. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36289. */
  36290. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36291. /**
  36292. * Defines the camera the input is attached to.
  36293. */
  36294. camera: ArcRotateCamera;
  36295. /**
  36296. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36297. */
  36298. alphaCorrection: number;
  36299. /**
  36300. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36301. */
  36302. gammaCorrection: number;
  36303. private _alpha;
  36304. private _gamma;
  36305. private _dirty;
  36306. private _deviceOrientationHandler;
  36307. /**
  36308. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36309. */
  36310. constructor();
  36311. /**
  36312. * Attach the input controls to a specific dom element to get the input from.
  36313. * @param element Defines the element the controls should be listened from
  36314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36315. */
  36316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36317. /** @hidden */
  36318. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36319. /**
  36320. * Update the current camera state depending on the inputs that have been used this frame.
  36321. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36322. */
  36323. checkInputs(): void;
  36324. /**
  36325. * Detach the current controls from the specified dom element.
  36326. * @param element Defines the element to stop listening the inputs from
  36327. */
  36328. detachControl(element: Nullable<HTMLElement>): void;
  36329. /**
  36330. * Gets the class name of the current intput.
  36331. * @returns the class name
  36332. */
  36333. getClassName(): string;
  36334. /**
  36335. * Get the friendly name associated with the input class.
  36336. * @returns the input friendly name
  36337. */
  36338. getSimpleName(): string;
  36339. }
  36340. }
  36341. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36342. import { Nullable } from "babylonjs/types";
  36343. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36344. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36345. /**
  36346. * Listen to mouse events to control the camera.
  36347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36348. */
  36349. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36350. /**
  36351. * Defines the camera the input is attached to.
  36352. */
  36353. camera: FlyCamera;
  36354. /**
  36355. * Defines if touch is enabled. (Default is true.)
  36356. */
  36357. touchEnabled: boolean;
  36358. /**
  36359. * Defines the buttons associated with the input to handle camera rotation.
  36360. */
  36361. buttons: number[];
  36362. /**
  36363. * Assign buttons for Yaw control.
  36364. */
  36365. buttonsYaw: number[];
  36366. /**
  36367. * Assign buttons for Pitch control.
  36368. */
  36369. buttonsPitch: number[];
  36370. /**
  36371. * Assign buttons for Roll control.
  36372. */
  36373. buttonsRoll: number[];
  36374. /**
  36375. * Detect if any button is being pressed while mouse is moved.
  36376. * -1 = Mouse locked.
  36377. * 0 = Left button.
  36378. * 1 = Middle Button.
  36379. * 2 = Right Button.
  36380. */
  36381. activeButton: number;
  36382. /**
  36383. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36384. * Higher values reduce its sensitivity.
  36385. */
  36386. angularSensibility: number;
  36387. private _mousemoveCallback;
  36388. private _observer;
  36389. private _rollObserver;
  36390. private previousPosition;
  36391. private noPreventDefault;
  36392. private element;
  36393. /**
  36394. * Listen to mouse events to control the camera.
  36395. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36397. */
  36398. constructor(touchEnabled?: boolean);
  36399. /**
  36400. * Attach the mouse control to the HTML DOM element.
  36401. * @param element Defines the element that listens to the input events.
  36402. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36403. */
  36404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36405. /**
  36406. * Detach the current controls from the specified dom element.
  36407. * @param element Defines the element to stop listening the inputs from
  36408. */
  36409. detachControl(element: Nullable<HTMLElement>): void;
  36410. /**
  36411. * Gets the class name of the current input.
  36412. * @returns the class name.
  36413. */
  36414. getClassName(): string;
  36415. /**
  36416. * Get the friendly name associated with the input class.
  36417. * @returns the input's friendly name.
  36418. */
  36419. getSimpleName(): string;
  36420. private _pointerInput;
  36421. private _onMouseMove;
  36422. /**
  36423. * Rotate camera by mouse offset.
  36424. */
  36425. private rotateCamera;
  36426. }
  36427. }
  36428. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36429. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36430. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36431. /**
  36432. * Default Inputs manager for the FlyCamera.
  36433. * It groups all the default supported inputs for ease of use.
  36434. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36435. */
  36436. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36437. /**
  36438. * Instantiates a new FlyCameraInputsManager.
  36439. * @param camera Defines the camera the inputs belong to.
  36440. */
  36441. constructor(camera: FlyCamera);
  36442. /**
  36443. * Add keyboard input support to the input manager.
  36444. * @returns the new FlyCameraKeyboardMoveInput().
  36445. */
  36446. addKeyboard(): FlyCameraInputsManager;
  36447. /**
  36448. * Add mouse input support to the input manager.
  36449. * @param touchEnabled Enable touch screen support.
  36450. * @returns the new FlyCameraMouseInput().
  36451. */
  36452. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36453. }
  36454. }
  36455. declare module "babylonjs/Cameras/flyCamera" {
  36456. import { Scene } from "babylonjs/scene";
  36457. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36459. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36460. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36461. /**
  36462. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36463. * such as in a 3D Space Shooter or a Flight Simulator.
  36464. */
  36465. export class FlyCamera extends TargetCamera {
  36466. /**
  36467. * Define the collision ellipsoid of the camera.
  36468. * This is helpful for simulating a camera body, like a player's body.
  36469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36470. */
  36471. ellipsoid: Vector3;
  36472. /**
  36473. * Define an offset for the position of the ellipsoid around the camera.
  36474. * This can be helpful if the camera is attached away from the player's body center,
  36475. * such as at its head.
  36476. */
  36477. ellipsoidOffset: Vector3;
  36478. /**
  36479. * Enable or disable collisions of the camera with the rest of the scene objects.
  36480. */
  36481. checkCollisions: boolean;
  36482. /**
  36483. * Enable or disable gravity on the camera.
  36484. */
  36485. applyGravity: boolean;
  36486. /**
  36487. * Define the current direction the camera is moving to.
  36488. */
  36489. cameraDirection: Vector3;
  36490. /**
  36491. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36492. * This overrides and empties cameraRotation.
  36493. */
  36494. rotationQuaternion: Quaternion;
  36495. /**
  36496. * Track Roll to maintain the wanted Rolling when looking around.
  36497. */
  36498. _trackRoll: number;
  36499. /**
  36500. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36501. */
  36502. rollCorrect: number;
  36503. /**
  36504. * Mimic a banked turn, Rolling the camera when Yawing.
  36505. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36506. */
  36507. bankedTurn: boolean;
  36508. /**
  36509. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36510. */
  36511. bankedTurnLimit: number;
  36512. /**
  36513. * Value of 0 disables the banked Roll.
  36514. * Value of 1 is equal to the Yaw angle in radians.
  36515. */
  36516. bankedTurnMultiplier: number;
  36517. /**
  36518. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36519. */
  36520. inputs: FlyCameraInputsManager;
  36521. /**
  36522. * Gets the input sensibility for mouse input.
  36523. * Higher values reduce sensitivity.
  36524. */
  36525. /**
  36526. * Sets the input sensibility for a mouse input.
  36527. * Higher values reduce sensitivity.
  36528. */
  36529. angularSensibility: number;
  36530. /**
  36531. * Get the keys for camera movement forward.
  36532. */
  36533. /**
  36534. * Set the keys for camera movement forward.
  36535. */
  36536. keysForward: number[];
  36537. /**
  36538. * Get the keys for camera movement backward.
  36539. */
  36540. keysBackward: number[];
  36541. /**
  36542. * Get the keys for camera movement up.
  36543. */
  36544. /**
  36545. * Set the keys for camera movement up.
  36546. */
  36547. keysUp: number[];
  36548. /**
  36549. * Get the keys for camera movement down.
  36550. */
  36551. /**
  36552. * Set the keys for camera movement down.
  36553. */
  36554. keysDown: number[];
  36555. /**
  36556. * Get the keys for camera movement left.
  36557. */
  36558. /**
  36559. * Set the keys for camera movement left.
  36560. */
  36561. keysLeft: number[];
  36562. /**
  36563. * Set the keys for camera movement right.
  36564. */
  36565. /**
  36566. * Set the keys for camera movement right.
  36567. */
  36568. keysRight: number[];
  36569. /**
  36570. * Event raised when the camera collides with a mesh in the scene.
  36571. */
  36572. onCollide: (collidedMesh: AbstractMesh) => void;
  36573. private _collider;
  36574. private _needMoveForGravity;
  36575. private _oldPosition;
  36576. private _diffPosition;
  36577. private _newPosition;
  36578. /** @hidden */
  36579. _localDirection: Vector3;
  36580. /** @hidden */
  36581. _transformedDirection: Vector3;
  36582. /**
  36583. * Instantiates a FlyCamera.
  36584. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36585. * such as in a 3D Space Shooter or a Flight Simulator.
  36586. * @param name Define the name of the camera in the scene.
  36587. * @param position Define the starting position of the camera in the scene.
  36588. * @param scene Define the scene the camera belongs to.
  36589. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36590. */
  36591. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36592. /**
  36593. * Attach a control to the HTML DOM element.
  36594. * @param element Defines the element that listens to the input events.
  36595. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36596. */
  36597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36598. /**
  36599. * Detach a control from the HTML DOM element.
  36600. * The camera will stop reacting to that input.
  36601. * @param element Defines the element that listens to the input events.
  36602. */
  36603. detachControl(element: HTMLElement): void;
  36604. private _collisionMask;
  36605. /**
  36606. * Get the mask that the camera ignores in collision events.
  36607. */
  36608. /**
  36609. * Set the mask that the camera ignores in collision events.
  36610. */
  36611. collisionMask: number;
  36612. /** @hidden */
  36613. _collideWithWorld(displacement: Vector3): void;
  36614. /** @hidden */
  36615. private _onCollisionPositionChange;
  36616. /** @hidden */
  36617. _checkInputs(): void;
  36618. /** @hidden */
  36619. _decideIfNeedsToMove(): boolean;
  36620. /** @hidden */
  36621. _updatePosition(): void;
  36622. /**
  36623. * Restore the Roll to its target value at the rate specified.
  36624. * @param rate - Higher means slower restoring.
  36625. * @hidden
  36626. */
  36627. restoreRoll(rate: number): void;
  36628. /**
  36629. * Destroy the camera and release the current resources held by it.
  36630. */
  36631. dispose(): void;
  36632. /**
  36633. * Get the current object class name.
  36634. * @returns the class name.
  36635. */
  36636. getClassName(): string;
  36637. }
  36638. }
  36639. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36640. import { Nullable } from "babylonjs/types";
  36641. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36642. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36643. /**
  36644. * Listen to keyboard events to control the camera.
  36645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36646. */
  36647. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36648. /**
  36649. * Defines the camera the input is attached to.
  36650. */
  36651. camera: FlyCamera;
  36652. /**
  36653. * The list of keyboard keys used to control the forward move of the camera.
  36654. */
  36655. keysForward: number[];
  36656. /**
  36657. * The list of keyboard keys used to control the backward move of the camera.
  36658. */
  36659. keysBackward: number[];
  36660. /**
  36661. * The list of keyboard keys used to control the forward move of the camera.
  36662. */
  36663. keysUp: number[];
  36664. /**
  36665. * The list of keyboard keys used to control the backward move of the camera.
  36666. */
  36667. keysDown: number[];
  36668. /**
  36669. * The list of keyboard keys used to control the right strafe move of the camera.
  36670. */
  36671. keysRight: number[];
  36672. /**
  36673. * The list of keyboard keys used to control the left strafe move of the camera.
  36674. */
  36675. keysLeft: number[];
  36676. private _keys;
  36677. private _onCanvasBlurObserver;
  36678. private _onKeyboardObserver;
  36679. private _engine;
  36680. private _scene;
  36681. /**
  36682. * Attach the input controls to a specific dom element to get the input from.
  36683. * @param element Defines the element the controls should be listened from
  36684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36685. */
  36686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36687. /**
  36688. * Detach the current controls from the specified dom element.
  36689. * @param element Defines the element to stop listening the inputs from
  36690. */
  36691. detachControl(element: Nullable<HTMLElement>): void;
  36692. /**
  36693. * Gets the class name of the current intput.
  36694. * @returns the class name
  36695. */
  36696. getClassName(): string;
  36697. /** @hidden */
  36698. _onLostFocus(e: FocusEvent): void;
  36699. /**
  36700. * Get the friendly name associated with the input class.
  36701. * @returns the input friendly name
  36702. */
  36703. getSimpleName(): string;
  36704. /**
  36705. * Update the current camera state depending on the inputs that have been used this frame.
  36706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36707. */
  36708. checkInputs(): void;
  36709. }
  36710. }
  36711. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36712. import { Nullable } from "babylonjs/types";
  36713. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36714. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36715. /**
  36716. * Manage the mouse wheel inputs to control a follow camera.
  36717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36718. */
  36719. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36720. /**
  36721. * Defines the camera the input is attached to.
  36722. */
  36723. camera: FollowCamera;
  36724. /**
  36725. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36726. */
  36727. axisControlRadius: boolean;
  36728. /**
  36729. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36730. */
  36731. axisControlHeight: boolean;
  36732. /**
  36733. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36734. */
  36735. axisControlRotation: boolean;
  36736. /**
  36737. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36738. * relation to mouseWheel events.
  36739. */
  36740. wheelPrecision: number;
  36741. /**
  36742. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36743. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36744. */
  36745. wheelDeltaPercentage: number;
  36746. private _wheel;
  36747. private _observer;
  36748. /**
  36749. * Attach the input controls to a specific dom element to get the input from.
  36750. * @param element Defines the element the controls should be listened from
  36751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36752. */
  36753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36754. /**
  36755. * Detach the current controls from the specified dom element.
  36756. * @param element Defines the element to stop listening the inputs from
  36757. */
  36758. detachControl(element: Nullable<HTMLElement>): void;
  36759. /**
  36760. * Gets the class name of the current intput.
  36761. * @returns the class name
  36762. */
  36763. getClassName(): string;
  36764. /**
  36765. * Get the friendly name associated with the input class.
  36766. * @returns the input friendly name
  36767. */
  36768. getSimpleName(): string;
  36769. }
  36770. }
  36771. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  36772. import { Nullable } from "babylonjs/types";
  36773. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36774. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36775. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36776. /**
  36777. * Manage the pointers inputs to control an follow camera.
  36778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36779. */
  36780. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36781. /**
  36782. * Defines the camera the input is attached to.
  36783. */
  36784. camera: FollowCamera;
  36785. /**
  36786. * Gets the class name of the current input.
  36787. * @returns the class name
  36788. */
  36789. getClassName(): string;
  36790. /**
  36791. * Defines the pointer angular sensibility along the X axis or how fast is
  36792. * the camera rotating.
  36793. * A negative number will reverse the axis direction.
  36794. */
  36795. angularSensibilityX: number;
  36796. /**
  36797. * Defines the pointer angular sensibility along the Y axis or how fast is
  36798. * the camera rotating.
  36799. * A negative number will reverse the axis direction.
  36800. */
  36801. angularSensibilityY: number;
  36802. /**
  36803. * Defines the pointer pinch precision or how fast is the camera zooming.
  36804. * A negative number will reverse the axis direction.
  36805. */
  36806. pinchPrecision: number;
  36807. /**
  36808. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36809. * from 0.
  36810. * It defines the percentage of current camera.radius to use as delta when
  36811. * pinch zoom is used.
  36812. */
  36813. pinchDeltaPercentage: number;
  36814. /**
  36815. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36816. */
  36817. axisXControlRadius: boolean;
  36818. /**
  36819. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36820. */
  36821. axisXControlHeight: boolean;
  36822. /**
  36823. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36824. */
  36825. axisXControlRotation: boolean;
  36826. /**
  36827. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36828. */
  36829. axisYControlRadius: boolean;
  36830. /**
  36831. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36832. */
  36833. axisYControlHeight: boolean;
  36834. /**
  36835. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36836. */
  36837. axisYControlRotation: boolean;
  36838. /**
  36839. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36840. */
  36841. axisPinchControlRadius: boolean;
  36842. /**
  36843. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36844. */
  36845. axisPinchControlHeight: boolean;
  36846. /**
  36847. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36848. */
  36849. axisPinchControlRotation: boolean;
  36850. /**
  36851. * Log error messages if basic misconfiguration has occurred.
  36852. */
  36853. warningEnable: boolean;
  36854. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36855. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36856. private _warningCounter;
  36857. private _warning;
  36858. }
  36859. }
  36860. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36861. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36862. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36863. /**
  36864. * Default Inputs manager for the FollowCamera.
  36865. * It groups all the default supported inputs for ease of use.
  36866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36867. */
  36868. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36869. /**
  36870. * Instantiates a new FollowCameraInputsManager.
  36871. * @param camera Defines the camera the inputs belong to
  36872. */
  36873. constructor(camera: FollowCamera);
  36874. /**
  36875. * Add keyboard input support to the input manager.
  36876. * @returns the current input manager
  36877. */
  36878. addKeyboard(): FollowCameraInputsManager;
  36879. /**
  36880. * Add mouse wheel input support to the input manager.
  36881. * @returns the current input manager
  36882. */
  36883. addMouseWheel(): FollowCameraInputsManager;
  36884. /**
  36885. * Add pointers input support to the input manager.
  36886. * @returns the current input manager
  36887. */
  36888. addPointers(): FollowCameraInputsManager;
  36889. /**
  36890. * Add orientation input support to the input manager.
  36891. * @returns the current input manager
  36892. */
  36893. addVRDeviceOrientation(): FollowCameraInputsManager;
  36894. }
  36895. }
  36896. declare module "babylonjs/Cameras/followCamera" {
  36897. import { Nullable } from "babylonjs/types";
  36898. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36899. import { Scene } from "babylonjs/scene";
  36900. import { Vector3 } from "babylonjs/Maths/math";
  36901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36902. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  36903. /**
  36904. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36905. * an arc rotate version arcFollowCamera are available.
  36906. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36907. */
  36908. export class FollowCamera extends TargetCamera {
  36909. /**
  36910. * Distance the follow camera should follow an object at
  36911. */
  36912. radius: number;
  36913. /**
  36914. * Minimum allowed distance of the camera to the axis of rotation
  36915. * (The camera can not get closer).
  36916. * This can help limiting how the Camera is able to move in the scene.
  36917. */
  36918. lowerRadiusLimit: Nullable<number>;
  36919. /**
  36920. * Maximum allowed distance of the camera to the axis of rotation
  36921. * (The camera can not get further).
  36922. * This can help limiting how the Camera is able to move in the scene.
  36923. */
  36924. upperRadiusLimit: Nullable<number>;
  36925. /**
  36926. * Define a rotation offset between the camera and the object it follows
  36927. */
  36928. rotationOffset: number;
  36929. /**
  36930. * Minimum allowed angle to camera position relative to target object.
  36931. * This can help limiting how the Camera is able to move in the scene.
  36932. */
  36933. lowerRotationOffsetLimit: Nullable<number>;
  36934. /**
  36935. * Maximum allowed angle to camera position relative to target object.
  36936. * This can help limiting how the Camera is able to move in the scene.
  36937. */
  36938. upperRotationOffsetLimit: Nullable<number>;
  36939. /**
  36940. * Define a height offset between the camera and the object it follows.
  36941. * It can help following an object from the top (like a car chaing a plane)
  36942. */
  36943. heightOffset: number;
  36944. /**
  36945. * Minimum allowed height of camera position relative to target object.
  36946. * This can help limiting how the Camera is able to move in the scene.
  36947. */
  36948. lowerHeightOffsetLimit: Nullable<number>;
  36949. /**
  36950. * Maximum allowed height of camera position relative to target object.
  36951. * This can help limiting how the Camera is able to move in the scene.
  36952. */
  36953. upperHeightOffsetLimit: Nullable<number>;
  36954. /**
  36955. * Define how fast the camera can accelerate to follow it s target.
  36956. */
  36957. cameraAcceleration: number;
  36958. /**
  36959. * Define the speed limit of the camera following an object.
  36960. */
  36961. maxCameraSpeed: number;
  36962. /**
  36963. * Define the target of the camera.
  36964. */
  36965. lockedTarget: Nullable<AbstractMesh>;
  36966. /**
  36967. * Defines the input associated with the camera.
  36968. */
  36969. inputs: FollowCameraInputsManager;
  36970. /**
  36971. * Instantiates the follow camera.
  36972. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36973. * @param name Define the name of the camera in the scene
  36974. * @param position Define the position of the camera
  36975. * @param scene Define the scene the camera belong to
  36976. * @param lockedTarget Define the target of the camera
  36977. */
  36978. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36979. private _follow;
  36980. /**
  36981. * Attached controls to the current camera.
  36982. * @param element Defines the element the controls should be listened from
  36983. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36984. */
  36985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36986. /**
  36987. * Detach the current controls from the camera.
  36988. * The camera will stop reacting to inputs.
  36989. * @param element Defines the element to stop listening the inputs from
  36990. */
  36991. detachControl(element: HTMLElement): void;
  36992. /** @hidden */
  36993. _checkInputs(): void;
  36994. private _checkLimits;
  36995. /**
  36996. * Gets the camera class name.
  36997. * @returns the class name
  36998. */
  36999. getClassName(): string;
  37000. }
  37001. /**
  37002. * Arc Rotate version of the follow camera.
  37003. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37004. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37005. */
  37006. export class ArcFollowCamera extends TargetCamera {
  37007. /** The longitudinal angle of the camera */
  37008. alpha: number;
  37009. /** The latitudinal angle of the camera */
  37010. beta: number;
  37011. /** The radius of the camera from its target */
  37012. radius: number;
  37013. /** Define the camera target (the messh it should follow) */
  37014. target: Nullable<AbstractMesh>;
  37015. private _cartesianCoordinates;
  37016. /**
  37017. * Instantiates a new ArcFollowCamera
  37018. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37019. * @param name Define the name of the camera
  37020. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37021. * @param beta Define the rotation angle of the camera around the elevation axis
  37022. * @param radius Define the radius of the camera from its target point
  37023. * @param target Define the target of the camera
  37024. * @param scene Define the scene the camera belongs to
  37025. */
  37026. constructor(name: string,
  37027. /** The longitudinal angle of the camera */
  37028. alpha: number,
  37029. /** The latitudinal angle of the camera */
  37030. beta: number,
  37031. /** The radius of the camera from its target */
  37032. radius: number,
  37033. /** Define the camera target (the messh it should follow) */
  37034. target: Nullable<AbstractMesh>, scene: Scene);
  37035. private _follow;
  37036. /** @hidden */
  37037. _checkInputs(): void;
  37038. /**
  37039. * Returns the class name of the object.
  37040. * It is mostly used internally for serialization purposes.
  37041. */
  37042. getClassName(): string;
  37043. }
  37044. }
  37045. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37046. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37047. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37048. import { Nullable } from "babylonjs/types";
  37049. /**
  37050. * Manage the keyboard inputs to control the movement of a follow camera.
  37051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37052. */
  37053. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37054. /**
  37055. * Defines the camera the input is attached to.
  37056. */
  37057. camera: FollowCamera;
  37058. /**
  37059. * Defines the list of key codes associated with the up action (increase heightOffset)
  37060. */
  37061. keysHeightOffsetIncr: number[];
  37062. /**
  37063. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37064. */
  37065. keysHeightOffsetDecr: number[];
  37066. /**
  37067. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37068. */
  37069. keysHeightOffsetModifierAlt: boolean;
  37070. /**
  37071. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37072. */
  37073. keysHeightOffsetModifierCtrl: boolean;
  37074. /**
  37075. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37076. */
  37077. keysHeightOffsetModifierShift: boolean;
  37078. /**
  37079. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37080. */
  37081. keysRotationOffsetIncr: number[];
  37082. /**
  37083. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37084. */
  37085. keysRotationOffsetDecr: number[];
  37086. /**
  37087. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37088. */
  37089. keysRotationOffsetModifierAlt: boolean;
  37090. /**
  37091. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37092. */
  37093. keysRotationOffsetModifierCtrl: boolean;
  37094. /**
  37095. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37096. */
  37097. keysRotationOffsetModifierShift: boolean;
  37098. /**
  37099. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37100. */
  37101. keysRadiusIncr: number[];
  37102. /**
  37103. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37104. */
  37105. keysRadiusDecr: number[];
  37106. /**
  37107. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37108. */
  37109. keysRadiusModifierAlt: boolean;
  37110. /**
  37111. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37112. */
  37113. keysRadiusModifierCtrl: boolean;
  37114. /**
  37115. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37116. */
  37117. keysRadiusModifierShift: boolean;
  37118. /**
  37119. * Defines the rate of change of heightOffset.
  37120. */
  37121. heightSensibility: number;
  37122. /**
  37123. * Defines the rate of change of rotationOffset.
  37124. */
  37125. rotationSensibility: number;
  37126. /**
  37127. * Defines the rate of change of radius.
  37128. */
  37129. radiusSensibility: number;
  37130. private _keys;
  37131. private _ctrlPressed;
  37132. private _altPressed;
  37133. private _shiftPressed;
  37134. private _onCanvasBlurObserver;
  37135. private _onKeyboardObserver;
  37136. private _engine;
  37137. private _scene;
  37138. /**
  37139. * Attach the input controls to a specific dom element to get the input from.
  37140. * @param element Defines the element the controls should be listened from
  37141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37142. */
  37143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37144. /**
  37145. * Detach the current controls from the specified dom element.
  37146. * @param element Defines the element to stop listening the inputs from
  37147. */
  37148. detachControl(element: Nullable<HTMLElement>): void;
  37149. /**
  37150. * Update the current camera state depending on the inputs that have been used this frame.
  37151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37152. */
  37153. checkInputs(): void;
  37154. /**
  37155. * Gets the class name of the current input.
  37156. * @returns the class name
  37157. */
  37158. getClassName(): string;
  37159. /**
  37160. * Get the friendly name associated with the input class.
  37161. * @returns the input friendly name
  37162. */
  37163. getSimpleName(): string;
  37164. /**
  37165. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37166. * allow modification of the heightOffset value.
  37167. */
  37168. private _modifierHeightOffset;
  37169. /**
  37170. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37171. * allow modification of the rotationOffset value.
  37172. */
  37173. private _modifierRotationOffset;
  37174. /**
  37175. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37176. * allow modification of the radius value.
  37177. */
  37178. private _modifierRadius;
  37179. }
  37180. }
  37181. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37182. import { Nullable } from "babylonjs/types";
  37183. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37184. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37185. module "babylonjs/Cameras/freeCameraInputsManager" {
  37186. interface FreeCameraInputsManager {
  37187. /**
  37188. * Add orientation input support to the input manager.
  37189. * @returns the current input manager
  37190. */
  37191. addDeviceOrientation(): FreeCameraInputsManager;
  37192. }
  37193. }
  37194. /**
  37195. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37196. * Screen rotation is taken into account.
  37197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37198. */
  37199. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37200. private _camera;
  37201. private _screenOrientationAngle;
  37202. private _constantTranform;
  37203. private _screenQuaternion;
  37204. private _alpha;
  37205. private _beta;
  37206. private _gamma;
  37207. /**
  37208. * Instantiates a new input
  37209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37210. */
  37211. constructor();
  37212. /**
  37213. * Define the camera controlled by the input.
  37214. */
  37215. camera: FreeCamera;
  37216. /**
  37217. * Attach the input controls to a specific dom element to get the input from.
  37218. * @param element Defines the element the controls should be listened from
  37219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37220. */
  37221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37222. private _orientationChanged;
  37223. private _deviceOrientation;
  37224. /**
  37225. * Detach the current controls from the specified dom element.
  37226. * @param element Defines the element to stop listening the inputs from
  37227. */
  37228. detachControl(element: Nullable<HTMLElement>): void;
  37229. /**
  37230. * Update the current camera state depending on the inputs that have been used this frame.
  37231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37232. */
  37233. checkInputs(): void;
  37234. /**
  37235. * Gets the class name of the current intput.
  37236. * @returns the class name
  37237. */
  37238. getClassName(): string;
  37239. /**
  37240. * Get the friendly name associated with the input class.
  37241. * @returns the input friendly name
  37242. */
  37243. getSimpleName(): string;
  37244. }
  37245. }
  37246. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37247. import { Nullable } from "babylonjs/types";
  37248. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37249. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37250. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37251. /**
  37252. * Manage the gamepad inputs to control a free camera.
  37253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37254. */
  37255. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37256. /**
  37257. * Define the camera the input is attached to.
  37258. */
  37259. camera: FreeCamera;
  37260. /**
  37261. * Define the Gamepad controlling the input
  37262. */
  37263. gamepad: Nullable<Gamepad>;
  37264. /**
  37265. * Defines the gamepad rotation sensiblity.
  37266. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37267. */
  37268. gamepadAngularSensibility: number;
  37269. /**
  37270. * Defines the gamepad move sensiblity.
  37271. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37272. */
  37273. gamepadMoveSensibility: number;
  37274. private _onGamepadConnectedObserver;
  37275. private _onGamepadDisconnectedObserver;
  37276. private _cameraTransform;
  37277. private _deltaTransform;
  37278. private _vector3;
  37279. private _vector2;
  37280. /**
  37281. * Attach the input controls to a specific dom element to get the input from.
  37282. * @param element Defines the element the controls should be listened from
  37283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37284. */
  37285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37286. /**
  37287. * Detach the current controls from the specified dom element.
  37288. * @param element Defines the element to stop listening the inputs from
  37289. */
  37290. detachControl(element: Nullable<HTMLElement>): void;
  37291. /**
  37292. * Update the current camera state depending on the inputs that have been used this frame.
  37293. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37294. */
  37295. checkInputs(): void;
  37296. /**
  37297. * Gets the class name of the current intput.
  37298. * @returns the class name
  37299. */
  37300. getClassName(): string;
  37301. /**
  37302. * Get the friendly name associated with the input class.
  37303. * @returns the input friendly name
  37304. */
  37305. getSimpleName(): string;
  37306. }
  37307. }
  37308. declare module "babylonjs/Misc/virtualJoystick" {
  37309. import { Nullable } from "babylonjs/types";
  37310. import { Vector3 } from "babylonjs/Maths/math";
  37311. /**
  37312. * Defines the potential axis of a Joystick
  37313. */
  37314. export enum JoystickAxis {
  37315. /** X axis */
  37316. X = 0,
  37317. /** Y axis */
  37318. Y = 1,
  37319. /** Z axis */
  37320. Z = 2
  37321. }
  37322. /**
  37323. * Class used to define virtual joystick (used in touch mode)
  37324. */
  37325. export class VirtualJoystick {
  37326. /**
  37327. * Gets or sets a boolean indicating that left and right values must be inverted
  37328. */
  37329. reverseLeftRight: boolean;
  37330. /**
  37331. * Gets or sets a boolean indicating that up and down values must be inverted
  37332. */
  37333. reverseUpDown: boolean;
  37334. /**
  37335. * Gets the offset value for the position (ie. the change of the position value)
  37336. */
  37337. deltaPosition: Vector3;
  37338. /**
  37339. * Gets a boolean indicating if the virtual joystick was pressed
  37340. */
  37341. pressed: boolean;
  37342. /**
  37343. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37344. */
  37345. static Canvas: Nullable<HTMLCanvasElement>;
  37346. private static _globalJoystickIndex;
  37347. private static vjCanvasContext;
  37348. private static vjCanvasWidth;
  37349. private static vjCanvasHeight;
  37350. private static halfWidth;
  37351. private _action;
  37352. private _axisTargetedByLeftAndRight;
  37353. private _axisTargetedByUpAndDown;
  37354. private _joystickSensibility;
  37355. private _inversedSensibility;
  37356. private _joystickPointerID;
  37357. private _joystickColor;
  37358. private _joystickPointerPos;
  37359. private _joystickPreviousPointerPos;
  37360. private _joystickPointerStartPos;
  37361. private _deltaJoystickVector;
  37362. private _leftJoystick;
  37363. private _touches;
  37364. private _onPointerDownHandlerRef;
  37365. private _onPointerMoveHandlerRef;
  37366. private _onPointerUpHandlerRef;
  37367. private _onResize;
  37368. /**
  37369. * Creates a new virtual joystick
  37370. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37371. */
  37372. constructor(leftJoystick?: boolean);
  37373. /**
  37374. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37375. * @param newJoystickSensibility defines the new sensibility
  37376. */
  37377. setJoystickSensibility(newJoystickSensibility: number): void;
  37378. private _onPointerDown;
  37379. private _onPointerMove;
  37380. private _onPointerUp;
  37381. /**
  37382. * Change the color of the virtual joystick
  37383. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37384. */
  37385. setJoystickColor(newColor: string): void;
  37386. /**
  37387. * Defines a callback to call when the joystick is touched
  37388. * @param action defines the callback
  37389. */
  37390. setActionOnTouch(action: () => any): void;
  37391. /**
  37392. * Defines which axis you'd like to control for left & right
  37393. * @param axis defines the axis to use
  37394. */
  37395. setAxisForLeftRight(axis: JoystickAxis): void;
  37396. /**
  37397. * Defines which axis you'd like to control for up & down
  37398. * @param axis defines the axis to use
  37399. */
  37400. setAxisForUpDown(axis: JoystickAxis): void;
  37401. private _drawVirtualJoystick;
  37402. /**
  37403. * Release internal HTML canvas
  37404. */
  37405. releaseCanvas(): void;
  37406. }
  37407. }
  37408. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37409. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37410. import { Nullable } from "babylonjs/types";
  37411. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37412. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37413. module "babylonjs/Cameras/freeCameraInputsManager" {
  37414. interface FreeCameraInputsManager {
  37415. /**
  37416. * Add virtual joystick input support to the input manager.
  37417. * @returns the current input manager
  37418. */
  37419. addVirtualJoystick(): FreeCameraInputsManager;
  37420. }
  37421. }
  37422. /**
  37423. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37425. */
  37426. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37427. /**
  37428. * Defines the camera the input is attached to.
  37429. */
  37430. camera: FreeCamera;
  37431. private _leftjoystick;
  37432. private _rightjoystick;
  37433. /**
  37434. * Gets the left stick of the virtual joystick.
  37435. * @returns The virtual Joystick
  37436. */
  37437. getLeftJoystick(): VirtualJoystick;
  37438. /**
  37439. * Gets the right stick of the virtual joystick.
  37440. * @returns The virtual Joystick
  37441. */
  37442. getRightJoystick(): VirtualJoystick;
  37443. /**
  37444. * Update the current camera state depending on the inputs that have been used this frame.
  37445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37446. */
  37447. checkInputs(): void;
  37448. /**
  37449. * Attach the input controls to a specific dom element to get the input from.
  37450. * @param element Defines the element the controls should be listened from
  37451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37452. */
  37453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37454. /**
  37455. * Detach the current controls from the specified dom element.
  37456. * @param element Defines the element to stop listening the inputs from
  37457. */
  37458. detachControl(element: Nullable<HTMLElement>): void;
  37459. /**
  37460. * Gets the class name of the current intput.
  37461. * @returns the class name
  37462. */
  37463. getClassName(): string;
  37464. /**
  37465. * Get the friendly name associated with the input class.
  37466. * @returns the input friendly name
  37467. */
  37468. getSimpleName(): string;
  37469. }
  37470. }
  37471. declare module "babylonjs/Cameras/Inputs/index" {
  37472. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37473. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37474. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37475. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37476. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37477. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37478. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37479. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37480. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37481. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37482. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37483. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37484. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37485. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37486. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37487. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37488. }
  37489. declare module "babylonjs/Cameras/touchCamera" {
  37490. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37491. import { Scene } from "babylonjs/scene";
  37492. import { Vector3 } from "babylonjs/Maths/math";
  37493. /**
  37494. * This represents a FPS type of camera controlled by touch.
  37495. * This is like a universal camera minus the Gamepad controls.
  37496. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37497. */
  37498. export class TouchCamera extends FreeCamera {
  37499. /**
  37500. * Defines the touch sensibility for rotation.
  37501. * The higher the faster.
  37502. */
  37503. touchAngularSensibility: number;
  37504. /**
  37505. * Defines the touch sensibility for move.
  37506. * The higher the faster.
  37507. */
  37508. touchMoveSensibility: number;
  37509. /**
  37510. * Instantiates a new touch camera.
  37511. * This represents a FPS type of camera controlled by touch.
  37512. * This is like a universal camera minus the Gamepad controls.
  37513. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37514. * @param name Define the name of the camera in the scene
  37515. * @param position Define the start position of the camera in the scene
  37516. * @param scene Define the scene the camera belongs to
  37517. */
  37518. constructor(name: string, position: Vector3, scene: Scene);
  37519. /**
  37520. * Gets the current object class name.
  37521. * @return the class name
  37522. */
  37523. getClassName(): string;
  37524. /** @hidden */
  37525. _setupInputs(): void;
  37526. }
  37527. }
  37528. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37529. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37530. import { Scene } from "babylonjs/scene";
  37531. import { Vector3, Axis } from "babylonjs/Maths/math";
  37532. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37533. /**
  37534. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37535. * being tilted forward or back and left or right.
  37536. */
  37537. export class DeviceOrientationCamera extends FreeCamera {
  37538. private _initialQuaternion;
  37539. private _quaternionCache;
  37540. /**
  37541. * Creates a new device orientation camera
  37542. * @param name The name of the camera
  37543. * @param position The start position camera
  37544. * @param scene The scene the camera belongs to
  37545. */
  37546. constructor(name: string, position: Vector3, scene: Scene);
  37547. /**
  37548. * Gets the current instance class name ("DeviceOrientationCamera").
  37549. * This helps avoiding instanceof at run time.
  37550. * @returns the class name
  37551. */
  37552. getClassName(): string;
  37553. /**
  37554. * @hidden
  37555. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37556. */
  37557. _checkInputs(): void;
  37558. /**
  37559. * Reset the camera to its default orientation on the specified axis only.
  37560. * @param axis The axis to reset
  37561. */
  37562. resetToCurrentRotation(axis?: Axis): void;
  37563. }
  37564. }
  37565. declare module "babylonjs/Cameras/universalCamera" {
  37566. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37567. import { Scene } from "babylonjs/scene";
  37568. import { Vector3 } from "babylonjs/Maths/math";
  37569. /**
  37570. * 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,
  37571. * which still works and will still be found in many Playgrounds.
  37572. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37573. */
  37574. export class UniversalCamera extends TouchCamera {
  37575. /**
  37576. * Defines the gamepad rotation sensiblity.
  37577. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37578. */
  37579. gamepadAngularSensibility: number;
  37580. /**
  37581. * Defines the gamepad move sensiblity.
  37582. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37583. */
  37584. gamepadMoveSensibility: number;
  37585. /**
  37586. * 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,
  37587. * which still works and will still be found in many Playgrounds.
  37588. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37589. * @param name Define the name of the camera in the scene
  37590. * @param position Define the start position of the camera in the scene
  37591. * @param scene Define the scene the camera belongs to
  37592. */
  37593. constructor(name: string, position: Vector3, scene: Scene);
  37594. /**
  37595. * Gets the current object class name.
  37596. * @return the class name
  37597. */
  37598. getClassName(): string;
  37599. }
  37600. }
  37601. declare module "babylonjs/Cameras/gamepadCamera" {
  37602. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37603. import { Scene } from "babylonjs/scene";
  37604. import { Vector3 } from "babylonjs/Maths/math";
  37605. /**
  37606. * This represents a FPS type of camera. This is only here for back compat purpose.
  37607. * Please use the UniversalCamera instead as both are identical.
  37608. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37609. */
  37610. export class GamepadCamera extends UniversalCamera {
  37611. /**
  37612. * Instantiates a new Gamepad Camera
  37613. * This represents a FPS type of camera. This is only here for back compat purpose.
  37614. * Please use the UniversalCamera instead as both are identical.
  37615. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37616. * @param name Define the name of the camera in the scene
  37617. * @param position Define the start position of the camera in the scene
  37618. * @param scene Define the scene the camera belongs to
  37619. */
  37620. constructor(name: string, position: Vector3, scene: Scene);
  37621. /**
  37622. * Gets the current object class name.
  37623. * @return the class name
  37624. */
  37625. getClassName(): string;
  37626. }
  37627. }
  37628. declare module "babylonjs/Shaders/pass.fragment" {
  37629. /** @hidden */
  37630. export var passPixelShader: {
  37631. name: string;
  37632. shader: string;
  37633. };
  37634. }
  37635. declare module "babylonjs/Shaders/passCube.fragment" {
  37636. /** @hidden */
  37637. export var passCubePixelShader: {
  37638. name: string;
  37639. shader: string;
  37640. };
  37641. }
  37642. declare module "babylonjs/PostProcesses/passPostProcess" {
  37643. import { Nullable } from "babylonjs/types";
  37644. import { Camera } from "babylonjs/Cameras/camera";
  37645. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37646. import { Engine } from "babylonjs/Engines/engine";
  37647. import "babylonjs/Shaders/pass.fragment";
  37648. import "babylonjs/Shaders/passCube.fragment";
  37649. /**
  37650. * PassPostProcess which produces an output the same as it's input
  37651. */
  37652. export class PassPostProcess extends PostProcess {
  37653. /**
  37654. * Creates the PassPostProcess
  37655. * @param name The name of the effect.
  37656. * @param options The required width/height ratio to downsize to before computing the render pass.
  37657. * @param camera The camera to apply the render pass to.
  37658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37659. * @param engine The engine which the post process will be applied. (default: current engine)
  37660. * @param reusable If the post process can be reused on the same frame. (default: false)
  37661. * @param textureType The type of texture to be used when performing the post processing.
  37662. * @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)
  37663. */
  37664. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37665. }
  37666. /**
  37667. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37668. */
  37669. export class PassCubePostProcess extends PostProcess {
  37670. private _face;
  37671. /**
  37672. * Gets or sets the cube face to display.
  37673. * * 0 is +X
  37674. * * 1 is -X
  37675. * * 2 is +Y
  37676. * * 3 is -Y
  37677. * * 4 is +Z
  37678. * * 5 is -Z
  37679. */
  37680. face: number;
  37681. /**
  37682. * Creates the PassCubePostProcess
  37683. * @param name The name of the effect.
  37684. * @param options The required width/height ratio to downsize to before computing the render pass.
  37685. * @param camera The camera to apply the render pass to.
  37686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37687. * @param engine The engine which the post process will be applied. (default: current engine)
  37688. * @param reusable If the post process can be reused on the same frame. (default: false)
  37689. * @param textureType The type of texture to be used when performing the post processing.
  37690. * @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)
  37691. */
  37692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37693. }
  37694. }
  37695. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37696. /** @hidden */
  37697. export var anaglyphPixelShader: {
  37698. name: string;
  37699. shader: string;
  37700. };
  37701. }
  37702. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37703. import { Engine } from "babylonjs/Engines/engine";
  37704. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37705. import { Camera } from "babylonjs/Cameras/camera";
  37706. import "babylonjs/Shaders/anaglyph.fragment";
  37707. /**
  37708. * Postprocess used to generate anaglyphic rendering
  37709. */
  37710. export class AnaglyphPostProcess extends PostProcess {
  37711. private _passedProcess;
  37712. /**
  37713. * Creates a new AnaglyphPostProcess
  37714. * @param name defines postprocess name
  37715. * @param options defines creation options or target ratio scale
  37716. * @param rigCameras defines cameras using this postprocess
  37717. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37718. * @param engine defines hosting engine
  37719. * @param reusable defines if the postprocess will be reused multiple times per frame
  37720. */
  37721. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37722. }
  37723. }
  37724. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37725. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37726. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37727. import { Scene } from "babylonjs/scene";
  37728. import { Vector3 } from "babylonjs/Maths/math";
  37729. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37730. /**
  37731. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37732. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37733. */
  37734. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37735. /**
  37736. * Creates a new AnaglyphArcRotateCamera
  37737. * @param name defines camera name
  37738. * @param alpha defines alpha angle (in radians)
  37739. * @param beta defines beta angle (in radians)
  37740. * @param radius defines radius
  37741. * @param target defines camera target
  37742. * @param interaxialDistance defines distance between each color axis
  37743. * @param scene defines the hosting scene
  37744. */
  37745. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37746. /**
  37747. * Gets camera class name
  37748. * @returns AnaglyphArcRotateCamera
  37749. */
  37750. getClassName(): string;
  37751. }
  37752. }
  37753. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37754. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37755. import { Scene } from "babylonjs/scene";
  37756. import { Vector3 } from "babylonjs/Maths/math";
  37757. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37758. /**
  37759. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37760. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37761. */
  37762. export class AnaglyphFreeCamera extends FreeCamera {
  37763. /**
  37764. * Creates a new AnaglyphFreeCamera
  37765. * @param name defines camera name
  37766. * @param position defines initial position
  37767. * @param interaxialDistance defines distance between each color axis
  37768. * @param scene defines the hosting scene
  37769. */
  37770. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37771. /**
  37772. * Gets camera class name
  37773. * @returns AnaglyphFreeCamera
  37774. */
  37775. getClassName(): string;
  37776. }
  37777. }
  37778. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37779. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37780. import { Scene } from "babylonjs/scene";
  37781. import { Vector3 } from "babylonjs/Maths/math";
  37782. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37783. /**
  37784. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37785. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37786. */
  37787. export class AnaglyphGamepadCamera extends GamepadCamera {
  37788. /**
  37789. * Creates a new AnaglyphGamepadCamera
  37790. * @param name defines camera name
  37791. * @param position defines initial position
  37792. * @param interaxialDistance defines distance between each color axis
  37793. * @param scene defines the hosting scene
  37794. */
  37795. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37796. /**
  37797. * Gets camera class name
  37798. * @returns AnaglyphGamepadCamera
  37799. */
  37800. getClassName(): string;
  37801. }
  37802. }
  37803. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37804. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37805. import { Scene } from "babylonjs/scene";
  37806. import { Vector3 } from "babylonjs/Maths/math";
  37807. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37808. /**
  37809. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37810. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37811. */
  37812. export class AnaglyphUniversalCamera extends UniversalCamera {
  37813. /**
  37814. * Creates a new AnaglyphUniversalCamera
  37815. * @param name defines camera name
  37816. * @param position defines initial position
  37817. * @param interaxialDistance defines distance between each color axis
  37818. * @param scene defines the hosting scene
  37819. */
  37820. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37821. /**
  37822. * Gets camera class name
  37823. * @returns AnaglyphUniversalCamera
  37824. */
  37825. getClassName(): string;
  37826. }
  37827. }
  37828. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37829. /** @hidden */
  37830. export var stereoscopicInterlacePixelShader: {
  37831. name: string;
  37832. shader: string;
  37833. };
  37834. }
  37835. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37836. import { Camera } from "babylonjs/Cameras/camera";
  37837. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37838. import { Engine } from "babylonjs/Engines/engine";
  37839. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37840. /**
  37841. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37842. */
  37843. export class StereoscopicInterlacePostProcess extends PostProcess {
  37844. private _stepSize;
  37845. private _passedProcess;
  37846. /**
  37847. * Initializes a StereoscopicInterlacePostProcess
  37848. * @param name The name of the effect.
  37849. * @param rigCameras The rig cameras to be appled to the post process
  37850. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37852. * @param engine The engine which the post process will be applied. (default: current engine)
  37853. * @param reusable If the post process can be reused on the same frame. (default: false)
  37854. */
  37855. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37856. }
  37857. }
  37858. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37859. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37860. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37861. import { Scene } from "babylonjs/scene";
  37862. import { Vector3 } from "babylonjs/Maths/math";
  37863. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37864. /**
  37865. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37866. * @see http://doc.babylonjs.com/features/cameras
  37867. */
  37868. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37869. /**
  37870. * Creates a new StereoscopicArcRotateCamera
  37871. * @param name defines camera name
  37872. * @param alpha defines alpha angle (in radians)
  37873. * @param beta defines beta angle (in radians)
  37874. * @param radius defines radius
  37875. * @param target defines camera target
  37876. * @param interaxialDistance defines distance between each color axis
  37877. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37878. * @param scene defines the hosting scene
  37879. */
  37880. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37881. /**
  37882. * Gets camera class name
  37883. * @returns StereoscopicArcRotateCamera
  37884. */
  37885. getClassName(): string;
  37886. }
  37887. }
  37888. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37889. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37890. import { Scene } from "babylonjs/scene";
  37891. import { Vector3 } from "babylonjs/Maths/math";
  37892. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37893. /**
  37894. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37895. * @see http://doc.babylonjs.com/features/cameras
  37896. */
  37897. export class StereoscopicFreeCamera extends FreeCamera {
  37898. /**
  37899. * Creates a new StereoscopicFreeCamera
  37900. * @param name defines camera name
  37901. * @param position defines initial position
  37902. * @param interaxialDistance defines distance between each color axis
  37903. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37904. * @param scene defines the hosting scene
  37905. */
  37906. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37907. /**
  37908. * Gets camera class name
  37909. * @returns StereoscopicFreeCamera
  37910. */
  37911. getClassName(): string;
  37912. }
  37913. }
  37914. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37915. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37916. import { Scene } from "babylonjs/scene";
  37917. import { Vector3 } from "babylonjs/Maths/math";
  37918. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37919. /**
  37920. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37921. * @see http://doc.babylonjs.com/features/cameras
  37922. */
  37923. export class StereoscopicGamepadCamera extends GamepadCamera {
  37924. /**
  37925. * Creates a new StereoscopicGamepadCamera
  37926. * @param name defines camera name
  37927. * @param position defines initial position
  37928. * @param interaxialDistance defines distance between each color axis
  37929. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37930. * @param scene defines the hosting scene
  37931. */
  37932. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37933. /**
  37934. * Gets camera class name
  37935. * @returns StereoscopicGamepadCamera
  37936. */
  37937. getClassName(): string;
  37938. }
  37939. }
  37940. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37941. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37942. import { Scene } from "babylonjs/scene";
  37943. import { Vector3 } from "babylonjs/Maths/math";
  37944. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37945. /**
  37946. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37947. * @see http://doc.babylonjs.com/features/cameras
  37948. */
  37949. export class StereoscopicUniversalCamera extends UniversalCamera {
  37950. /**
  37951. * Creates a new StereoscopicUniversalCamera
  37952. * @param name defines camera name
  37953. * @param position defines initial position
  37954. * @param interaxialDistance defines distance between each color axis
  37955. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37956. * @param scene defines the hosting scene
  37957. */
  37958. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37959. /**
  37960. * Gets camera class name
  37961. * @returns StereoscopicUniversalCamera
  37962. */
  37963. getClassName(): string;
  37964. }
  37965. }
  37966. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37967. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37968. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37969. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37970. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37971. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37972. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37973. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37974. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37975. }
  37976. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37977. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37978. import { Scene } from "babylonjs/scene";
  37979. import { Vector3 } from "babylonjs/Maths/math";
  37980. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37981. /**
  37982. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37983. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37984. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37985. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37986. */
  37987. export class VirtualJoysticksCamera extends FreeCamera {
  37988. /**
  37989. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37990. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37991. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37992. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37993. * @param name Define the name of the camera in the scene
  37994. * @param position Define the start position of the camera in the scene
  37995. * @param scene Define the scene the camera belongs to
  37996. */
  37997. constructor(name: string, position: Vector3, scene: Scene);
  37998. /**
  37999. * Gets the current object class name.
  38000. * @return the class name
  38001. */
  38002. getClassName(): string;
  38003. }
  38004. }
  38005. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38006. import { Matrix } from "babylonjs/Maths/math";
  38007. /**
  38008. * This represents all the required metrics to create a VR camera.
  38009. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38010. */
  38011. export class VRCameraMetrics {
  38012. /**
  38013. * Define the horizontal resolution off the screen.
  38014. */
  38015. hResolution: number;
  38016. /**
  38017. * Define the vertical resolution off the screen.
  38018. */
  38019. vResolution: number;
  38020. /**
  38021. * Define the horizontal screen size.
  38022. */
  38023. hScreenSize: number;
  38024. /**
  38025. * Define the vertical screen size.
  38026. */
  38027. vScreenSize: number;
  38028. /**
  38029. * Define the vertical screen center position.
  38030. */
  38031. vScreenCenter: number;
  38032. /**
  38033. * Define the distance of the eyes to the screen.
  38034. */
  38035. eyeToScreenDistance: number;
  38036. /**
  38037. * Define the distance between both lenses
  38038. */
  38039. lensSeparationDistance: number;
  38040. /**
  38041. * Define the distance between both viewer's eyes.
  38042. */
  38043. interpupillaryDistance: number;
  38044. /**
  38045. * Define the distortion factor of the VR postprocess.
  38046. * Please, touch with care.
  38047. */
  38048. distortionK: number[];
  38049. /**
  38050. * Define the chromatic aberration correction factors for the VR post process.
  38051. */
  38052. chromaAbCorrection: number[];
  38053. /**
  38054. * Define the scale factor of the post process.
  38055. * The smaller the better but the slower.
  38056. */
  38057. postProcessScaleFactor: number;
  38058. /**
  38059. * Define an offset for the lens center.
  38060. */
  38061. lensCenterOffset: number;
  38062. /**
  38063. * Define if the current vr camera should compensate the distortion of the lense or not.
  38064. */
  38065. compensateDistortion: boolean;
  38066. /**
  38067. * Gets the rendering aspect ratio based on the provided resolutions.
  38068. */
  38069. readonly aspectRatio: number;
  38070. /**
  38071. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38072. */
  38073. readonly aspectRatioFov: number;
  38074. /**
  38075. * @hidden
  38076. */
  38077. readonly leftHMatrix: Matrix;
  38078. /**
  38079. * @hidden
  38080. */
  38081. readonly rightHMatrix: Matrix;
  38082. /**
  38083. * @hidden
  38084. */
  38085. readonly leftPreViewMatrix: Matrix;
  38086. /**
  38087. * @hidden
  38088. */
  38089. readonly rightPreViewMatrix: Matrix;
  38090. /**
  38091. * Get the default VRMetrics based on the most generic setup.
  38092. * @returns the default vr metrics
  38093. */
  38094. static GetDefault(): VRCameraMetrics;
  38095. }
  38096. }
  38097. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38098. /** @hidden */
  38099. export var vrDistortionCorrectionPixelShader: {
  38100. name: string;
  38101. shader: string;
  38102. };
  38103. }
  38104. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38105. import { Camera } from "babylonjs/Cameras/camera";
  38106. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38107. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38108. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38109. /**
  38110. * VRDistortionCorrectionPostProcess used for mobile VR
  38111. */
  38112. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38113. private _isRightEye;
  38114. private _distortionFactors;
  38115. private _postProcessScaleFactor;
  38116. private _lensCenterOffset;
  38117. private _scaleIn;
  38118. private _scaleFactor;
  38119. private _lensCenter;
  38120. /**
  38121. * Initializes the VRDistortionCorrectionPostProcess
  38122. * @param name The name of the effect.
  38123. * @param camera The camera to apply the render pass to.
  38124. * @param isRightEye If this is for the right eye distortion
  38125. * @param vrMetrics All the required metrics for the VR camera
  38126. */
  38127. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38128. }
  38129. }
  38130. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38131. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38132. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38133. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38134. import { Scene } from "babylonjs/scene";
  38135. import { Vector3 } from "babylonjs/Maths/math";
  38136. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38137. import "babylonjs/Cameras/RigModes/vrRigMode";
  38138. /**
  38139. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38140. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38141. */
  38142. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38143. /**
  38144. * Creates a new VRDeviceOrientationArcRotateCamera
  38145. * @param name defines camera name
  38146. * @param alpha defines the camera rotation along the logitudinal axis
  38147. * @param beta defines the camera rotation along the latitudinal axis
  38148. * @param radius defines the camera distance from its target
  38149. * @param target defines the camera target
  38150. * @param scene defines the scene the camera belongs to
  38151. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38152. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38153. */
  38154. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38155. /**
  38156. * Gets camera class name
  38157. * @returns VRDeviceOrientationArcRotateCamera
  38158. */
  38159. getClassName(): string;
  38160. }
  38161. }
  38162. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38163. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38164. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38165. import { Scene } from "babylonjs/scene";
  38166. import { Vector3 } from "babylonjs/Maths/math";
  38167. import "babylonjs/Cameras/RigModes/vrRigMode";
  38168. /**
  38169. * Camera used to simulate VR rendering (based on FreeCamera)
  38170. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38171. */
  38172. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38173. /**
  38174. * Creates a new VRDeviceOrientationFreeCamera
  38175. * @param name defines camera name
  38176. * @param position defines the start position of the camera
  38177. * @param scene defines the scene the camera belongs to
  38178. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38179. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38180. */
  38181. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38182. /**
  38183. * Gets camera class name
  38184. * @returns VRDeviceOrientationFreeCamera
  38185. */
  38186. getClassName(): string;
  38187. }
  38188. }
  38189. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38190. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38191. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38192. import { Scene } from "babylonjs/scene";
  38193. import { Vector3 } from "babylonjs/Maths/math";
  38194. /**
  38195. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38196. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38197. */
  38198. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38199. /**
  38200. * Creates a new VRDeviceOrientationGamepadCamera
  38201. * @param name defines camera name
  38202. * @param position defines the start position of the camera
  38203. * @param scene defines the scene the camera belongs to
  38204. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38205. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38206. */
  38207. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38208. /**
  38209. * Gets camera class name
  38210. * @returns VRDeviceOrientationGamepadCamera
  38211. */
  38212. getClassName(): string;
  38213. }
  38214. }
  38215. declare module "babylonjs/Gamepads/xboxGamepad" {
  38216. import { Observable } from "babylonjs/Misc/observable";
  38217. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38218. /**
  38219. * Defines supported buttons for XBox360 compatible gamepads
  38220. */
  38221. export enum Xbox360Button {
  38222. /** A */
  38223. A = 0,
  38224. /** B */
  38225. B = 1,
  38226. /** X */
  38227. X = 2,
  38228. /** Y */
  38229. Y = 3,
  38230. /** Start */
  38231. Start = 4,
  38232. /** Back */
  38233. Back = 5,
  38234. /** Left button */
  38235. LB = 6,
  38236. /** Right button */
  38237. RB = 7,
  38238. /** Left stick */
  38239. LeftStick = 8,
  38240. /** Right stick */
  38241. RightStick = 9
  38242. }
  38243. /** Defines values for XBox360 DPad */
  38244. export enum Xbox360Dpad {
  38245. /** Up */
  38246. Up = 0,
  38247. /** Down */
  38248. Down = 1,
  38249. /** Left */
  38250. Left = 2,
  38251. /** Right */
  38252. Right = 3
  38253. }
  38254. /**
  38255. * Defines a XBox360 gamepad
  38256. */
  38257. export class Xbox360Pad extends Gamepad {
  38258. private _leftTrigger;
  38259. private _rightTrigger;
  38260. private _onlefttriggerchanged;
  38261. private _onrighttriggerchanged;
  38262. private _onbuttondown;
  38263. private _onbuttonup;
  38264. private _ondpaddown;
  38265. private _ondpadup;
  38266. /** Observable raised when a button is pressed */
  38267. onButtonDownObservable: Observable<Xbox360Button>;
  38268. /** Observable raised when a button is released */
  38269. onButtonUpObservable: Observable<Xbox360Button>;
  38270. /** Observable raised when a pad is pressed */
  38271. onPadDownObservable: Observable<Xbox360Dpad>;
  38272. /** Observable raised when a pad is released */
  38273. onPadUpObservable: Observable<Xbox360Dpad>;
  38274. private _buttonA;
  38275. private _buttonB;
  38276. private _buttonX;
  38277. private _buttonY;
  38278. private _buttonBack;
  38279. private _buttonStart;
  38280. private _buttonLB;
  38281. private _buttonRB;
  38282. private _buttonLeftStick;
  38283. private _buttonRightStick;
  38284. private _dPadUp;
  38285. private _dPadDown;
  38286. private _dPadLeft;
  38287. private _dPadRight;
  38288. private _isXboxOnePad;
  38289. /**
  38290. * Creates a new XBox360 gamepad object
  38291. * @param id defines the id of this gamepad
  38292. * @param index defines its index
  38293. * @param gamepad defines the internal HTML gamepad object
  38294. * @param xboxOne defines if it is a XBox One gamepad
  38295. */
  38296. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38297. /**
  38298. * Defines the callback to call when left trigger is pressed
  38299. * @param callback defines the callback to use
  38300. */
  38301. onlefttriggerchanged(callback: (value: number) => void): void;
  38302. /**
  38303. * Defines the callback to call when right trigger is pressed
  38304. * @param callback defines the callback to use
  38305. */
  38306. onrighttriggerchanged(callback: (value: number) => void): void;
  38307. /**
  38308. * Gets the left trigger value
  38309. */
  38310. /**
  38311. * Sets the left trigger value
  38312. */
  38313. leftTrigger: number;
  38314. /**
  38315. * Gets the right trigger value
  38316. */
  38317. /**
  38318. * Sets the right trigger value
  38319. */
  38320. rightTrigger: number;
  38321. /**
  38322. * Defines the callback to call when a button is pressed
  38323. * @param callback defines the callback to use
  38324. */
  38325. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38326. /**
  38327. * Defines the callback to call when a button is released
  38328. * @param callback defines the callback to use
  38329. */
  38330. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38331. /**
  38332. * Defines the callback to call when a pad is pressed
  38333. * @param callback defines the callback to use
  38334. */
  38335. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38336. /**
  38337. * Defines the callback to call when a pad is released
  38338. * @param callback defines the callback to use
  38339. */
  38340. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38341. private _setButtonValue;
  38342. private _setDPadValue;
  38343. /**
  38344. * Gets the value of the `A` button
  38345. */
  38346. /**
  38347. * Sets the value of the `A` button
  38348. */
  38349. buttonA: number;
  38350. /**
  38351. * Gets the value of the `B` button
  38352. */
  38353. /**
  38354. * Sets the value of the `B` button
  38355. */
  38356. buttonB: number;
  38357. /**
  38358. * Gets the value of the `X` button
  38359. */
  38360. /**
  38361. * Sets the value of the `X` button
  38362. */
  38363. buttonX: number;
  38364. /**
  38365. * Gets the value of the `Y` button
  38366. */
  38367. /**
  38368. * Sets the value of the `Y` button
  38369. */
  38370. buttonY: number;
  38371. /**
  38372. * Gets the value of the `Start` button
  38373. */
  38374. /**
  38375. * Sets the value of the `Start` button
  38376. */
  38377. buttonStart: number;
  38378. /**
  38379. * Gets the value of the `Back` button
  38380. */
  38381. /**
  38382. * Sets the value of the `Back` button
  38383. */
  38384. buttonBack: number;
  38385. /**
  38386. * Gets the value of the `Left` button
  38387. */
  38388. /**
  38389. * Sets the value of the `Left` button
  38390. */
  38391. buttonLB: number;
  38392. /**
  38393. * Gets the value of the `Right` button
  38394. */
  38395. /**
  38396. * Sets the value of the `Right` button
  38397. */
  38398. buttonRB: number;
  38399. /**
  38400. * Gets the value of the Left joystick
  38401. */
  38402. /**
  38403. * Sets the value of the Left joystick
  38404. */
  38405. buttonLeftStick: number;
  38406. /**
  38407. * Gets the value of the Right joystick
  38408. */
  38409. /**
  38410. * Sets the value of the Right joystick
  38411. */
  38412. buttonRightStick: number;
  38413. /**
  38414. * Gets the value of D-pad up
  38415. */
  38416. /**
  38417. * Sets the value of D-pad up
  38418. */
  38419. dPadUp: number;
  38420. /**
  38421. * Gets the value of D-pad down
  38422. */
  38423. /**
  38424. * Sets the value of D-pad down
  38425. */
  38426. dPadDown: number;
  38427. /**
  38428. * Gets the value of D-pad left
  38429. */
  38430. /**
  38431. * Sets the value of D-pad left
  38432. */
  38433. dPadLeft: number;
  38434. /**
  38435. * Gets the value of D-pad right
  38436. */
  38437. /**
  38438. * Sets the value of D-pad right
  38439. */
  38440. dPadRight: number;
  38441. /**
  38442. * Force the gamepad to synchronize with device values
  38443. */
  38444. update(): void;
  38445. /**
  38446. * Disposes the gamepad
  38447. */
  38448. dispose(): void;
  38449. }
  38450. }
  38451. declare module "babylonjs/Materials/pushMaterial" {
  38452. import { Nullable } from "babylonjs/types";
  38453. import { Scene } from "babylonjs/scene";
  38454. import { Matrix } from "babylonjs/Maths/math";
  38455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38456. import { Mesh } from "babylonjs/Meshes/mesh";
  38457. import { Material } from "babylonjs/Materials/material";
  38458. import { Effect } from "babylonjs/Materials/effect";
  38459. /**
  38460. * Base class of materials working in push mode in babylon JS
  38461. * @hidden
  38462. */
  38463. export class PushMaterial extends Material {
  38464. protected _activeEffect: Effect;
  38465. protected _normalMatrix: Matrix;
  38466. /**
  38467. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38468. * This means that the material can keep using a previous shader while a new one is being compiled.
  38469. * This is mostly used when shader parallel compilation is supported (true by default)
  38470. */
  38471. allowShaderHotSwapping: boolean;
  38472. constructor(name: string, scene: Scene);
  38473. getEffect(): Effect;
  38474. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38475. /**
  38476. * Binds the given world matrix to the active effect
  38477. *
  38478. * @param world the matrix to bind
  38479. */
  38480. bindOnlyWorldMatrix(world: Matrix): void;
  38481. /**
  38482. * Binds the given normal matrix to the active effect
  38483. *
  38484. * @param normalMatrix the matrix to bind
  38485. */
  38486. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38487. bind(world: Matrix, mesh?: Mesh): void;
  38488. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38489. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38490. }
  38491. }
  38492. declare module "babylonjs/Materials/materialFlags" {
  38493. /**
  38494. * This groups all the flags used to control the materials channel.
  38495. */
  38496. export class MaterialFlags {
  38497. private static _DiffuseTextureEnabled;
  38498. /**
  38499. * Are diffuse textures enabled in the application.
  38500. */
  38501. static DiffuseTextureEnabled: boolean;
  38502. private static _AmbientTextureEnabled;
  38503. /**
  38504. * Are ambient textures enabled in the application.
  38505. */
  38506. static AmbientTextureEnabled: boolean;
  38507. private static _OpacityTextureEnabled;
  38508. /**
  38509. * Are opacity textures enabled in the application.
  38510. */
  38511. static OpacityTextureEnabled: boolean;
  38512. private static _ReflectionTextureEnabled;
  38513. /**
  38514. * Are reflection textures enabled in the application.
  38515. */
  38516. static ReflectionTextureEnabled: boolean;
  38517. private static _EmissiveTextureEnabled;
  38518. /**
  38519. * Are emissive textures enabled in the application.
  38520. */
  38521. static EmissiveTextureEnabled: boolean;
  38522. private static _SpecularTextureEnabled;
  38523. /**
  38524. * Are specular textures enabled in the application.
  38525. */
  38526. static SpecularTextureEnabled: boolean;
  38527. private static _BumpTextureEnabled;
  38528. /**
  38529. * Are bump textures enabled in the application.
  38530. */
  38531. static BumpTextureEnabled: boolean;
  38532. private static _LightmapTextureEnabled;
  38533. /**
  38534. * Are lightmap textures enabled in the application.
  38535. */
  38536. static LightmapTextureEnabled: boolean;
  38537. private static _RefractionTextureEnabled;
  38538. /**
  38539. * Are refraction textures enabled in the application.
  38540. */
  38541. static RefractionTextureEnabled: boolean;
  38542. private static _ColorGradingTextureEnabled;
  38543. /**
  38544. * Are color grading textures enabled in the application.
  38545. */
  38546. static ColorGradingTextureEnabled: boolean;
  38547. private static _FresnelEnabled;
  38548. /**
  38549. * Are fresnels enabled in the application.
  38550. */
  38551. static FresnelEnabled: boolean;
  38552. private static _ClearCoatTextureEnabled;
  38553. /**
  38554. * Are clear coat textures enabled in the application.
  38555. */
  38556. static ClearCoatTextureEnabled: boolean;
  38557. private static _ClearCoatBumpTextureEnabled;
  38558. /**
  38559. * Are clear coat bump textures enabled in the application.
  38560. */
  38561. static ClearCoatBumpTextureEnabled: boolean;
  38562. private static _ClearCoatTintTextureEnabled;
  38563. /**
  38564. * Are clear coat tint textures enabled in the application.
  38565. */
  38566. static ClearCoatTintTextureEnabled: boolean;
  38567. private static _SheenTextureEnabled;
  38568. /**
  38569. * Are sheen textures enabled in the application.
  38570. */
  38571. static SheenTextureEnabled: boolean;
  38572. private static _AnisotropicTextureEnabled;
  38573. /**
  38574. * Are anisotropic textures enabled in the application.
  38575. */
  38576. static AnisotropicTextureEnabled: boolean;
  38577. }
  38578. }
  38579. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38580. /** @hidden */
  38581. export var defaultFragmentDeclaration: {
  38582. name: string;
  38583. shader: string;
  38584. };
  38585. }
  38586. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38587. /** @hidden */
  38588. export var defaultUboDeclaration: {
  38589. name: string;
  38590. shader: string;
  38591. };
  38592. }
  38593. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38594. /** @hidden */
  38595. export var lightFragmentDeclaration: {
  38596. name: string;
  38597. shader: string;
  38598. };
  38599. }
  38600. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38601. /** @hidden */
  38602. export var lightUboDeclaration: {
  38603. name: string;
  38604. shader: string;
  38605. };
  38606. }
  38607. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38608. /** @hidden */
  38609. export var lightsFragmentFunctions: {
  38610. name: string;
  38611. shader: string;
  38612. };
  38613. }
  38614. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38615. /** @hidden */
  38616. export var shadowsFragmentFunctions: {
  38617. name: string;
  38618. shader: string;
  38619. };
  38620. }
  38621. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38622. /** @hidden */
  38623. export var fresnelFunction: {
  38624. name: string;
  38625. shader: string;
  38626. };
  38627. }
  38628. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38629. /** @hidden */
  38630. export var reflectionFunction: {
  38631. name: string;
  38632. shader: string;
  38633. };
  38634. }
  38635. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38636. /** @hidden */
  38637. export var bumpFragmentFunctions: {
  38638. name: string;
  38639. shader: string;
  38640. };
  38641. }
  38642. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38643. /** @hidden */
  38644. export var logDepthDeclaration: {
  38645. name: string;
  38646. shader: string;
  38647. };
  38648. }
  38649. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38650. /** @hidden */
  38651. export var bumpFragment: {
  38652. name: string;
  38653. shader: string;
  38654. };
  38655. }
  38656. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38657. /** @hidden */
  38658. export var depthPrePass: {
  38659. name: string;
  38660. shader: string;
  38661. };
  38662. }
  38663. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38664. /** @hidden */
  38665. export var lightFragment: {
  38666. name: string;
  38667. shader: string;
  38668. };
  38669. }
  38670. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38671. /** @hidden */
  38672. export var logDepthFragment: {
  38673. name: string;
  38674. shader: string;
  38675. };
  38676. }
  38677. declare module "babylonjs/Shaders/default.fragment" {
  38678. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38679. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38680. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38681. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38682. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38683. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38684. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38685. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38686. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38687. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38688. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38689. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38690. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38691. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38692. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38693. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38694. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38695. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38696. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38697. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38698. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38699. /** @hidden */
  38700. export var defaultPixelShader: {
  38701. name: string;
  38702. shader: string;
  38703. };
  38704. }
  38705. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38706. /** @hidden */
  38707. export var defaultVertexDeclaration: {
  38708. name: string;
  38709. shader: string;
  38710. };
  38711. }
  38712. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38713. /** @hidden */
  38714. export var bumpVertexDeclaration: {
  38715. name: string;
  38716. shader: string;
  38717. };
  38718. }
  38719. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38720. /** @hidden */
  38721. export var bumpVertex: {
  38722. name: string;
  38723. shader: string;
  38724. };
  38725. }
  38726. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38727. /** @hidden */
  38728. export var fogVertex: {
  38729. name: string;
  38730. shader: string;
  38731. };
  38732. }
  38733. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38734. /** @hidden */
  38735. export var shadowsVertex: {
  38736. name: string;
  38737. shader: string;
  38738. };
  38739. }
  38740. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38741. /** @hidden */
  38742. export var pointCloudVertex: {
  38743. name: string;
  38744. shader: string;
  38745. };
  38746. }
  38747. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38748. /** @hidden */
  38749. export var logDepthVertex: {
  38750. name: string;
  38751. shader: string;
  38752. };
  38753. }
  38754. declare module "babylonjs/Shaders/default.vertex" {
  38755. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38756. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38757. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38758. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38759. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38760. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38761. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38762. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38763. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38764. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38765. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38766. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38767. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38768. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38769. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38770. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38771. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38772. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38773. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38774. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38775. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38776. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38777. /** @hidden */
  38778. export var defaultVertexShader: {
  38779. name: string;
  38780. shader: string;
  38781. };
  38782. }
  38783. declare module "babylonjs/Materials/standardMaterial" {
  38784. import { SmartArray } from "babylonjs/Misc/smartArray";
  38785. import { IAnimatable } from "babylonjs/Misc/tools";
  38786. import { Nullable } from "babylonjs/types";
  38787. import { Scene } from "babylonjs/scene";
  38788. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38789. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38791. import { Mesh } from "babylonjs/Meshes/mesh";
  38792. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38793. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38794. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38795. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38796. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38799. import "babylonjs/Shaders/default.fragment";
  38800. import "babylonjs/Shaders/default.vertex";
  38801. /** @hidden */
  38802. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38803. MAINUV1: boolean;
  38804. MAINUV2: boolean;
  38805. DIFFUSE: boolean;
  38806. DIFFUSEDIRECTUV: number;
  38807. AMBIENT: boolean;
  38808. AMBIENTDIRECTUV: number;
  38809. OPACITY: boolean;
  38810. OPACITYDIRECTUV: number;
  38811. OPACITYRGB: boolean;
  38812. REFLECTION: boolean;
  38813. EMISSIVE: boolean;
  38814. EMISSIVEDIRECTUV: number;
  38815. SPECULAR: boolean;
  38816. SPECULARDIRECTUV: number;
  38817. BUMP: boolean;
  38818. BUMPDIRECTUV: number;
  38819. PARALLAX: boolean;
  38820. PARALLAXOCCLUSION: boolean;
  38821. SPECULAROVERALPHA: boolean;
  38822. CLIPPLANE: boolean;
  38823. CLIPPLANE2: boolean;
  38824. CLIPPLANE3: boolean;
  38825. CLIPPLANE4: boolean;
  38826. ALPHATEST: boolean;
  38827. DEPTHPREPASS: boolean;
  38828. ALPHAFROMDIFFUSE: boolean;
  38829. POINTSIZE: boolean;
  38830. FOG: boolean;
  38831. SPECULARTERM: boolean;
  38832. DIFFUSEFRESNEL: boolean;
  38833. OPACITYFRESNEL: boolean;
  38834. REFLECTIONFRESNEL: boolean;
  38835. REFRACTIONFRESNEL: boolean;
  38836. EMISSIVEFRESNEL: boolean;
  38837. FRESNEL: boolean;
  38838. NORMAL: boolean;
  38839. UV1: boolean;
  38840. UV2: boolean;
  38841. VERTEXCOLOR: boolean;
  38842. VERTEXALPHA: boolean;
  38843. NUM_BONE_INFLUENCERS: number;
  38844. BonesPerMesh: number;
  38845. BONETEXTURE: boolean;
  38846. INSTANCES: boolean;
  38847. GLOSSINESS: boolean;
  38848. ROUGHNESS: boolean;
  38849. EMISSIVEASILLUMINATION: boolean;
  38850. LINKEMISSIVEWITHDIFFUSE: boolean;
  38851. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38852. LIGHTMAP: boolean;
  38853. LIGHTMAPDIRECTUV: number;
  38854. OBJECTSPACE_NORMALMAP: boolean;
  38855. USELIGHTMAPASSHADOWMAP: boolean;
  38856. REFLECTIONMAP_3D: boolean;
  38857. REFLECTIONMAP_SPHERICAL: boolean;
  38858. REFLECTIONMAP_PLANAR: boolean;
  38859. REFLECTIONMAP_CUBIC: boolean;
  38860. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38861. REFLECTIONMAP_PROJECTION: boolean;
  38862. REFLECTIONMAP_SKYBOX: boolean;
  38863. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38864. REFLECTIONMAP_EXPLICIT: boolean;
  38865. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38866. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38867. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38868. INVERTCUBICMAP: boolean;
  38869. LOGARITHMICDEPTH: boolean;
  38870. REFRACTION: boolean;
  38871. REFRACTIONMAP_3D: boolean;
  38872. REFLECTIONOVERALPHA: boolean;
  38873. TWOSIDEDLIGHTING: boolean;
  38874. SHADOWFLOAT: boolean;
  38875. MORPHTARGETS: boolean;
  38876. MORPHTARGETS_NORMAL: boolean;
  38877. MORPHTARGETS_TANGENT: boolean;
  38878. NUM_MORPH_INFLUENCERS: number;
  38879. NONUNIFORMSCALING: boolean;
  38880. PREMULTIPLYALPHA: boolean;
  38881. IMAGEPROCESSING: boolean;
  38882. VIGNETTE: boolean;
  38883. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38884. VIGNETTEBLENDMODEOPAQUE: boolean;
  38885. TONEMAPPING: boolean;
  38886. TONEMAPPING_ACES: boolean;
  38887. CONTRAST: boolean;
  38888. COLORCURVES: boolean;
  38889. COLORGRADING: boolean;
  38890. COLORGRADING3D: boolean;
  38891. SAMPLER3DGREENDEPTH: boolean;
  38892. SAMPLER3DBGRMAP: boolean;
  38893. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38894. /**
  38895. * If the reflection texture on this material is in linear color space
  38896. * @hidden
  38897. */
  38898. IS_REFLECTION_LINEAR: boolean;
  38899. /**
  38900. * If the refraction texture on this material is in linear color space
  38901. * @hidden
  38902. */
  38903. IS_REFRACTION_LINEAR: boolean;
  38904. EXPOSURE: boolean;
  38905. constructor();
  38906. setReflectionMode(modeToEnable: string): void;
  38907. }
  38908. /**
  38909. * This is the default material used in Babylon. It is the best trade off between quality
  38910. * and performances.
  38911. * @see http://doc.babylonjs.com/babylon101/materials
  38912. */
  38913. export class StandardMaterial extends PushMaterial {
  38914. private _diffuseTexture;
  38915. /**
  38916. * The basic texture of the material as viewed under a light.
  38917. */
  38918. diffuseTexture: Nullable<BaseTexture>;
  38919. private _ambientTexture;
  38920. /**
  38921. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38922. */
  38923. ambientTexture: Nullable<BaseTexture>;
  38924. private _opacityTexture;
  38925. /**
  38926. * Define the transparency of the material from a texture.
  38927. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38928. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38929. */
  38930. opacityTexture: Nullable<BaseTexture>;
  38931. private _reflectionTexture;
  38932. /**
  38933. * Define the texture used to display the reflection.
  38934. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38935. */
  38936. reflectionTexture: Nullable<BaseTexture>;
  38937. private _emissiveTexture;
  38938. /**
  38939. * Define texture of the material as if self lit.
  38940. * This will be mixed in the final result even in the absence of light.
  38941. */
  38942. emissiveTexture: Nullable<BaseTexture>;
  38943. private _specularTexture;
  38944. /**
  38945. * Define how the color and intensity of the highlight given by the light in the material.
  38946. */
  38947. specularTexture: Nullable<BaseTexture>;
  38948. private _bumpTexture;
  38949. /**
  38950. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38951. * 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.
  38952. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38953. */
  38954. bumpTexture: Nullable<BaseTexture>;
  38955. private _lightmapTexture;
  38956. /**
  38957. * Complex lighting can be computationally expensive to compute at runtime.
  38958. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38959. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38960. */
  38961. lightmapTexture: Nullable<BaseTexture>;
  38962. private _refractionTexture;
  38963. /**
  38964. * Define the texture used to display the refraction.
  38965. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38966. */
  38967. refractionTexture: Nullable<BaseTexture>;
  38968. /**
  38969. * The color of the material lit by the environmental background lighting.
  38970. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38971. */
  38972. ambientColor: Color3;
  38973. /**
  38974. * The basic color of the material as viewed under a light.
  38975. */
  38976. diffuseColor: Color3;
  38977. /**
  38978. * Define how the color and intensity of the highlight given by the light in the material.
  38979. */
  38980. specularColor: Color3;
  38981. /**
  38982. * Define the color of the material as if self lit.
  38983. * This will be mixed in the final result even in the absence of light.
  38984. */
  38985. emissiveColor: Color3;
  38986. /**
  38987. * Defines how sharp are the highlights in the material.
  38988. * The bigger the value the sharper giving a more glossy feeling to the result.
  38989. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38990. */
  38991. specularPower: number;
  38992. private _useAlphaFromDiffuseTexture;
  38993. /**
  38994. * Does the transparency come from the diffuse texture alpha channel.
  38995. */
  38996. useAlphaFromDiffuseTexture: boolean;
  38997. private _useEmissiveAsIllumination;
  38998. /**
  38999. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39000. */
  39001. useEmissiveAsIllumination: boolean;
  39002. private _linkEmissiveWithDiffuse;
  39003. /**
  39004. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39005. * the emissive level when the final color is close to one.
  39006. */
  39007. linkEmissiveWithDiffuse: boolean;
  39008. private _useSpecularOverAlpha;
  39009. /**
  39010. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39011. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39012. */
  39013. useSpecularOverAlpha: boolean;
  39014. private _useReflectionOverAlpha;
  39015. /**
  39016. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39017. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39018. */
  39019. useReflectionOverAlpha: boolean;
  39020. private _disableLighting;
  39021. /**
  39022. * Does lights from the scene impacts this material.
  39023. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39024. */
  39025. disableLighting: boolean;
  39026. private _useObjectSpaceNormalMap;
  39027. /**
  39028. * Allows using an object space normal map (instead of tangent space).
  39029. */
  39030. useObjectSpaceNormalMap: boolean;
  39031. private _useParallax;
  39032. /**
  39033. * Is parallax enabled or not.
  39034. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39035. */
  39036. useParallax: boolean;
  39037. private _useParallaxOcclusion;
  39038. /**
  39039. * Is parallax occlusion enabled or not.
  39040. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39041. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39042. */
  39043. useParallaxOcclusion: boolean;
  39044. /**
  39045. * 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.
  39046. */
  39047. parallaxScaleBias: number;
  39048. private _roughness;
  39049. /**
  39050. * Helps to define how blurry the reflections should appears in the material.
  39051. */
  39052. roughness: number;
  39053. /**
  39054. * In case of refraction, define the value of the indice of refraction.
  39055. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39056. */
  39057. indexOfRefraction: number;
  39058. /**
  39059. * Invert the refraction texture alongside the y axis.
  39060. * It can be useful with procedural textures or probe for instance.
  39061. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39062. */
  39063. invertRefractionY: boolean;
  39064. /**
  39065. * Defines the alpha limits in alpha test mode.
  39066. */
  39067. alphaCutOff: number;
  39068. private _useLightmapAsShadowmap;
  39069. /**
  39070. * In case of light mapping, define whether the map contains light or shadow informations.
  39071. */
  39072. useLightmapAsShadowmap: boolean;
  39073. private _diffuseFresnelParameters;
  39074. /**
  39075. * Define the diffuse fresnel parameters of the material.
  39076. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39077. */
  39078. diffuseFresnelParameters: FresnelParameters;
  39079. private _opacityFresnelParameters;
  39080. /**
  39081. * Define the opacity fresnel parameters of the material.
  39082. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39083. */
  39084. opacityFresnelParameters: FresnelParameters;
  39085. private _reflectionFresnelParameters;
  39086. /**
  39087. * Define the reflection fresnel parameters of the material.
  39088. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39089. */
  39090. reflectionFresnelParameters: FresnelParameters;
  39091. private _refractionFresnelParameters;
  39092. /**
  39093. * Define the refraction fresnel parameters of the material.
  39094. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39095. */
  39096. refractionFresnelParameters: FresnelParameters;
  39097. private _emissiveFresnelParameters;
  39098. /**
  39099. * Define the emissive fresnel parameters of the material.
  39100. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39101. */
  39102. emissiveFresnelParameters: FresnelParameters;
  39103. private _useReflectionFresnelFromSpecular;
  39104. /**
  39105. * If true automatically deducts the fresnels values from the material specularity.
  39106. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39107. */
  39108. useReflectionFresnelFromSpecular: boolean;
  39109. private _useGlossinessFromSpecularMapAlpha;
  39110. /**
  39111. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39112. */
  39113. useGlossinessFromSpecularMapAlpha: boolean;
  39114. private _maxSimultaneousLights;
  39115. /**
  39116. * Defines the maximum number of lights that can be used in the material
  39117. */
  39118. maxSimultaneousLights: number;
  39119. private _invertNormalMapX;
  39120. /**
  39121. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39122. */
  39123. invertNormalMapX: boolean;
  39124. private _invertNormalMapY;
  39125. /**
  39126. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39127. */
  39128. invertNormalMapY: boolean;
  39129. private _twoSidedLighting;
  39130. /**
  39131. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39132. */
  39133. twoSidedLighting: boolean;
  39134. /**
  39135. * Default configuration related to image processing available in the standard Material.
  39136. */
  39137. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39138. /**
  39139. * Gets the image processing configuration used either in this material.
  39140. */
  39141. /**
  39142. * Sets the Default image processing configuration used either in the this material.
  39143. *
  39144. * If sets to null, the scene one is in use.
  39145. */
  39146. imageProcessingConfiguration: ImageProcessingConfiguration;
  39147. /**
  39148. * Keep track of the image processing observer to allow dispose and replace.
  39149. */
  39150. private _imageProcessingObserver;
  39151. /**
  39152. * Attaches a new image processing configuration to the Standard Material.
  39153. * @param configuration
  39154. */
  39155. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39156. /**
  39157. * Gets wether the color curves effect is enabled.
  39158. */
  39159. /**
  39160. * Sets wether the color curves effect is enabled.
  39161. */
  39162. cameraColorCurvesEnabled: boolean;
  39163. /**
  39164. * Gets wether the color grading effect is enabled.
  39165. */
  39166. /**
  39167. * Gets wether the color grading effect is enabled.
  39168. */
  39169. cameraColorGradingEnabled: boolean;
  39170. /**
  39171. * Gets wether tonemapping is enabled or not.
  39172. */
  39173. /**
  39174. * Sets wether tonemapping is enabled or not
  39175. */
  39176. cameraToneMappingEnabled: boolean;
  39177. /**
  39178. * The camera exposure used on this material.
  39179. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39180. * This corresponds to a photographic exposure.
  39181. */
  39182. /**
  39183. * The camera exposure used on this material.
  39184. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39185. * This corresponds to a photographic exposure.
  39186. */
  39187. cameraExposure: number;
  39188. /**
  39189. * Gets The camera contrast used on this material.
  39190. */
  39191. /**
  39192. * Sets The camera contrast used on this material.
  39193. */
  39194. cameraContrast: number;
  39195. /**
  39196. * Gets the Color Grading 2D Lookup Texture.
  39197. */
  39198. /**
  39199. * Sets the Color Grading 2D Lookup Texture.
  39200. */
  39201. cameraColorGradingTexture: Nullable<BaseTexture>;
  39202. /**
  39203. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39204. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39205. * 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;
  39206. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39207. */
  39208. /**
  39209. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39210. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39211. * 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;
  39212. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39213. */
  39214. cameraColorCurves: Nullable<ColorCurves>;
  39215. /**
  39216. * Custom callback helping to override the default shader used in the material.
  39217. */
  39218. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39219. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39220. protected _worldViewProjectionMatrix: Matrix;
  39221. protected _globalAmbientColor: Color3;
  39222. protected _useLogarithmicDepth: boolean;
  39223. /**
  39224. * Instantiates a new standard material.
  39225. * This is the default material used in Babylon. It is the best trade off between quality
  39226. * and performances.
  39227. * @see http://doc.babylonjs.com/babylon101/materials
  39228. * @param name Define the name of the material in the scene
  39229. * @param scene Define the scene the material belong to
  39230. */
  39231. constructor(name: string, scene: Scene);
  39232. /**
  39233. * Gets a boolean indicating that current material needs to register RTT
  39234. */
  39235. readonly hasRenderTargetTextures: boolean;
  39236. /**
  39237. * Gets the current class name of the material e.g. "StandardMaterial"
  39238. * Mainly use in serialization.
  39239. * @returns the class name
  39240. */
  39241. getClassName(): string;
  39242. /**
  39243. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39244. * You can try switching to logarithmic depth.
  39245. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39246. */
  39247. useLogarithmicDepth: boolean;
  39248. /**
  39249. * Specifies if the material will require alpha blending
  39250. * @returns a boolean specifying if alpha blending is needed
  39251. */
  39252. needAlphaBlending(): boolean;
  39253. /**
  39254. * Specifies if this material should be rendered in alpha test mode
  39255. * @returns a boolean specifying if an alpha test is needed.
  39256. */
  39257. needAlphaTesting(): boolean;
  39258. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39259. /**
  39260. * Get the texture used for alpha test purpose.
  39261. * @returns the diffuse texture in case of the standard material.
  39262. */
  39263. getAlphaTestTexture(): Nullable<BaseTexture>;
  39264. /**
  39265. * Get if the submesh is ready to be used and all its information available.
  39266. * Child classes can use it to update shaders
  39267. * @param mesh defines the mesh to check
  39268. * @param subMesh defines which submesh to check
  39269. * @param useInstances specifies that instances should be used
  39270. * @returns a boolean indicating that the submesh is ready or not
  39271. */
  39272. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39273. /**
  39274. * Builds the material UBO layouts.
  39275. * Used internally during the effect preparation.
  39276. */
  39277. buildUniformLayout(): void;
  39278. /**
  39279. * Unbinds the material from the mesh
  39280. */
  39281. unbind(): void;
  39282. /**
  39283. * Binds the submesh to this material by preparing the effect and shader to draw
  39284. * @param world defines the world transformation matrix
  39285. * @param mesh defines the mesh containing the submesh
  39286. * @param subMesh defines the submesh to bind the material to
  39287. */
  39288. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39289. /**
  39290. * Get the list of animatables in the material.
  39291. * @returns the list of animatables object used in the material
  39292. */
  39293. getAnimatables(): IAnimatable[];
  39294. /**
  39295. * Gets the active textures from the material
  39296. * @returns an array of textures
  39297. */
  39298. getActiveTextures(): BaseTexture[];
  39299. /**
  39300. * Specifies if the material uses a texture
  39301. * @param texture defines the texture to check against the material
  39302. * @returns a boolean specifying if the material uses the texture
  39303. */
  39304. hasTexture(texture: BaseTexture): boolean;
  39305. /**
  39306. * Disposes the material
  39307. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39308. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39309. */
  39310. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39311. /**
  39312. * Makes a duplicate of the material, and gives it a new name
  39313. * @param name defines the new name for the duplicated material
  39314. * @returns the cloned material
  39315. */
  39316. clone(name: string): StandardMaterial;
  39317. /**
  39318. * Serializes this material in a JSON representation
  39319. * @returns the serialized material object
  39320. */
  39321. serialize(): any;
  39322. /**
  39323. * Creates a standard material from parsed material data
  39324. * @param source defines the JSON representation of the material
  39325. * @param scene defines the hosting scene
  39326. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39327. * @returns a new standard material
  39328. */
  39329. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39330. /**
  39331. * Are diffuse textures enabled in the application.
  39332. */
  39333. static DiffuseTextureEnabled: boolean;
  39334. /**
  39335. * Are ambient textures enabled in the application.
  39336. */
  39337. static AmbientTextureEnabled: boolean;
  39338. /**
  39339. * Are opacity textures enabled in the application.
  39340. */
  39341. static OpacityTextureEnabled: boolean;
  39342. /**
  39343. * Are reflection textures enabled in the application.
  39344. */
  39345. static ReflectionTextureEnabled: boolean;
  39346. /**
  39347. * Are emissive textures enabled in the application.
  39348. */
  39349. static EmissiveTextureEnabled: boolean;
  39350. /**
  39351. * Are specular textures enabled in the application.
  39352. */
  39353. static SpecularTextureEnabled: boolean;
  39354. /**
  39355. * Are bump textures enabled in the application.
  39356. */
  39357. static BumpTextureEnabled: boolean;
  39358. /**
  39359. * Are lightmap textures enabled in the application.
  39360. */
  39361. static LightmapTextureEnabled: boolean;
  39362. /**
  39363. * Are refraction textures enabled in the application.
  39364. */
  39365. static RefractionTextureEnabled: boolean;
  39366. /**
  39367. * Are color grading textures enabled in the application.
  39368. */
  39369. static ColorGradingTextureEnabled: boolean;
  39370. /**
  39371. * Are fresnels enabled in the application.
  39372. */
  39373. static FresnelEnabled: boolean;
  39374. }
  39375. }
  39376. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39377. import { Scene } from "babylonjs/scene";
  39378. import { Texture } from "babylonjs/Materials/Textures/texture";
  39379. /**
  39380. * A class extending Texture allowing drawing on a texture
  39381. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39382. */
  39383. export class DynamicTexture extends Texture {
  39384. private _generateMipMaps;
  39385. private _canvas;
  39386. private _context;
  39387. private _engine;
  39388. /**
  39389. * Creates a DynamicTexture
  39390. * @param name defines the name of the texture
  39391. * @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
  39392. * @param scene defines the scene where you want the texture
  39393. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39394. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39395. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39396. */
  39397. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39398. /**
  39399. * Get the current class name of the texture useful for serialization or dynamic coding.
  39400. * @returns "DynamicTexture"
  39401. */
  39402. getClassName(): string;
  39403. /**
  39404. * Gets the current state of canRescale
  39405. */
  39406. readonly canRescale: boolean;
  39407. private _recreate;
  39408. /**
  39409. * Scales the texture
  39410. * @param ratio the scale factor to apply to both width and height
  39411. */
  39412. scale(ratio: number): void;
  39413. /**
  39414. * Resizes the texture
  39415. * @param width the new width
  39416. * @param height the new height
  39417. */
  39418. scaleTo(width: number, height: number): void;
  39419. /**
  39420. * Gets the context of the canvas used by the texture
  39421. * @returns the canvas context of the dynamic texture
  39422. */
  39423. getContext(): CanvasRenderingContext2D;
  39424. /**
  39425. * Clears the texture
  39426. */
  39427. clear(): void;
  39428. /**
  39429. * Updates the texture
  39430. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39431. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39432. */
  39433. update(invertY?: boolean, premulAlpha?: boolean): void;
  39434. /**
  39435. * Draws text onto the texture
  39436. * @param text defines the text to be drawn
  39437. * @param x defines the placement of the text from the left
  39438. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39439. * @param font defines the font to be used with font-style, font-size, font-name
  39440. * @param color defines the color used for the text
  39441. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39442. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39443. * @param update defines whether texture is immediately update (default is true)
  39444. */
  39445. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39446. /**
  39447. * Clones the texture
  39448. * @returns the clone of the texture.
  39449. */
  39450. clone(): DynamicTexture;
  39451. /**
  39452. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39453. * @returns a serialized dynamic texture object
  39454. */
  39455. serialize(): any;
  39456. /** @hidden */
  39457. _rebuild(): void;
  39458. }
  39459. }
  39460. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39461. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39463. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39464. /** @hidden */
  39465. export var imageProcessingPixelShader: {
  39466. name: string;
  39467. shader: string;
  39468. };
  39469. }
  39470. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39471. import { Nullable } from "babylonjs/types";
  39472. import { Color4 } from "babylonjs/Maths/math";
  39473. import { Camera } from "babylonjs/Cameras/camera";
  39474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39475. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39476. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39478. import { Engine } from "babylonjs/Engines/engine";
  39479. import "babylonjs/Shaders/imageProcessing.fragment";
  39480. import "babylonjs/Shaders/postprocess.vertex";
  39481. /**
  39482. * ImageProcessingPostProcess
  39483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39484. */
  39485. export class ImageProcessingPostProcess extends PostProcess {
  39486. /**
  39487. * Default configuration related to image processing available in the PBR Material.
  39488. */
  39489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39490. /**
  39491. * Gets the image processing configuration used either in this material.
  39492. */
  39493. /**
  39494. * Sets the Default image processing configuration used either in the this material.
  39495. *
  39496. * If sets to null, the scene one is in use.
  39497. */
  39498. imageProcessingConfiguration: ImageProcessingConfiguration;
  39499. /**
  39500. * Keep track of the image processing observer to allow dispose and replace.
  39501. */
  39502. private _imageProcessingObserver;
  39503. /**
  39504. * Attaches a new image processing configuration to the PBR Material.
  39505. * @param configuration
  39506. */
  39507. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39508. /**
  39509. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39510. */
  39511. /**
  39512. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39513. */
  39514. colorCurves: Nullable<ColorCurves>;
  39515. /**
  39516. * Gets wether the color curves effect is enabled.
  39517. */
  39518. /**
  39519. * Sets wether the color curves effect is enabled.
  39520. */
  39521. colorCurvesEnabled: boolean;
  39522. /**
  39523. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39524. */
  39525. /**
  39526. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39527. */
  39528. colorGradingTexture: Nullable<BaseTexture>;
  39529. /**
  39530. * Gets wether the color grading effect is enabled.
  39531. */
  39532. /**
  39533. * Gets wether the color grading effect is enabled.
  39534. */
  39535. colorGradingEnabled: boolean;
  39536. /**
  39537. * Gets exposure used in the effect.
  39538. */
  39539. /**
  39540. * Sets exposure used in the effect.
  39541. */
  39542. exposure: number;
  39543. /**
  39544. * Gets wether tonemapping is enabled or not.
  39545. */
  39546. /**
  39547. * Sets wether tonemapping is enabled or not
  39548. */
  39549. toneMappingEnabled: boolean;
  39550. /**
  39551. * Gets the type of tone mapping effect.
  39552. */
  39553. /**
  39554. * Sets the type of tone mapping effect.
  39555. */
  39556. toneMappingType: number;
  39557. /**
  39558. * Gets contrast used in the effect.
  39559. */
  39560. /**
  39561. * Sets contrast used in the effect.
  39562. */
  39563. contrast: number;
  39564. /**
  39565. * Gets Vignette stretch size.
  39566. */
  39567. /**
  39568. * Sets Vignette stretch size.
  39569. */
  39570. vignetteStretch: number;
  39571. /**
  39572. * Gets Vignette centre X Offset.
  39573. */
  39574. /**
  39575. * Sets Vignette centre X Offset.
  39576. */
  39577. vignetteCentreX: number;
  39578. /**
  39579. * Gets Vignette centre Y Offset.
  39580. */
  39581. /**
  39582. * Sets Vignette centre Y Offset.
  39583. */
  39584. vignetteCentreY: number;
  39585. /**
  39586. * Gets Vignette weight or intensity of the vignette effect.
  39587. */
  39588. /**
  39589. * Sets Vignette weight or intensity of the vignette effect.
  39590. */
  39591. vignetteWeight: number;
  39592. /**
  39593. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39594. * if vignetteEnabled is set to true.
  39595. */
  39596. /**
  39597. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39598. * if vignetteEnabled is set to true.
  39599. */
  39600. vignetteColor: Color4;
  39601. /**
  39602. * Gets Camera field of view used by the Vignette effect.
  39603. */
  39604. /**
  39605. * Sets Camera field of view used by the Vignette effect.
  39606. */
  39607. vignetteCameraFov: number;
  39608. /**
  39609. * Gets the vignette blend mode allowing different kind of effect.
  39610. */
  39611. /**
  39612. * Sets the vignette blend mode allowing different kind of effect.
  39613. */
  39614. vignetteBlendMode: number;
  39615. /**
  39616. * Gets wether the vignette effect is enabled.
  39617. */
  39618. /**
  39619. * Sets wether the vignette effect is enabled.
  39620. */
  39621. vignetteEnabled: boolean;
  39622. private _fromLinearSpace;
  39623. /**
  39624. * Gets wether the input of the processing is in Gamma or Linear Space.
  39625. */
  39626. /**
  39627. * Sets wether the input of the processing is in Gamma or Linear Space.
  39628. */
  39629. fromLinearSpace: boolean;
  39630. /**
  39631. * Defines cache preventing GC.
  39632. */
  39633. private _defines;
  39634. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39635. /**
  39636. * "ImageProcessingPostProcess"
  39637. * @returns "ImageProcessingPostProcess"
  39638. */
  39639. getClassName(): string;
  39640. protected _updateParameters(): void;
  39641. dispose(camera?: Camera): void;
  39642. }
  39643. }
  39644. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39645. import { Scene } from "babylonjs/scene";
  39646. import { Color3 } from "babylonjs/Maths/math";
  39647. import { Mesh } from "babylonjs/Meshes/mesh";
  39648. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39649. /**
  39650. * Class containing static functions to help procedurally build meshes
  39651. */
  39652. export class GroundBuilder {
  39653. /**
  39654. * Creates a ground mesh
  39655. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39656. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39658. * @param name defines the name of the mesh
  39659. * @param options defines the options used to create the mesh
  39660. * @param scene defines the hosting scene
  39661. * @returns the ground mesh
  39662. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39663. */
  39664. static CreateGround(name: string, options: {
  39665. width?: number;
  39666. height?: number;
  39667. subdivisions?: number;
  39668. subdivisionsX?: number;
  39669. subdivisionsY?: number;
  39670. updatable?: boolean;
  39671. }, scene: any): Mesh;
  39672. /**
  39673. * Creates a tiled ground mesh
  39674. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39675. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39676. * * 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
  39677. * * 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
  39678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39679. * @param name defines the name of the mesh
  39680. * @param options defines the options used to create the mesh
  39681. * @param scene defines the hosting scene
  39682. * @returns the tiled ground mesh
  39683. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39684. */
  39685. static CreateTiledGround(name: string, options: {
  39686. xmin: number;
  39687. zmin: number;
  39688. xmax: number;
  39689. zmax: number;
  39690. subdivisions?: {
  39691. w: number;
  39692. h: number;
  39693. };
  39694. precision?: {
  39695. w: number;
  39696. h: number;
  39697. };
  39698. updatable?: boolean;
  39699. }, scene: Scene): Mesh;
  39700. /**
  39701. * Creates a ground mesh from a height map
  39702. * * The parameter `url` sets the URL of the height map image resource.
  39703. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39704. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39705. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39706. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39707. * * 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.
  39708. * * 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).
  39709. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39711. * @param name defines the name of the mesh
  39712. * @param url defines the url to the height map
  39713. * @param options defines the options used to create the mesh
  39714. * @param scene defines the hosting scene
  39715. * @returns the ground mesh
  39716. * @see https://doc.babylonjs.com/babylon101/height_map
  39717. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39718. */
  39719. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39720. width?: number;
  39721. height?: number;
  39722. subdivisions?: number;
  39723. minHeight?: number;
  39724. maxHeight?: number;
  39725. colorFilter?: Color3;
  39726. alphaFilter?: number;
  39727. updatable?: boolean;
  39728. onReady?: (mesh: GroundMesh) => void;
  39729. }, scene: Scene): GroundMesh;
  39730. }
  39731. }
  39732. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39733. import { Vector4 } from "babylonjs/Maths/math";
  39734. import { Mesh } from "babylonjs/Meshes/mesh";
  39735. /**
  39736. * Class containing static functions to help procedurally build meshes
  39737. */
  39738. export class TorusBuilder {
  39739. /**
  39740. * Creates a torus mesh
  39741. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39742. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39743. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39747. * @param name defines the name of the mesh
  39748. * @param options defines the options used to create the mesh
  39749. * @param scene defines the hosting scene
  39750. * @returns the torus mesh
  39751. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39752. */
  39753. static CreateTorus(name: string, options: {
  39754. diameter?: number;
  39755. thickness?: number;
  39756. tessellation?: number;
  39757. updatable?: boolean;
  39758. sideOrientation?: number;
  39759. frontUVs?: Vector4;
  39760. backUVs?: Vector4;
  39761. }, scene: any): Mesh;
  39762. }
  39763. }
  39764. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39765. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39766. import { Mesh } from "babylonjs/Meshes/mesh";
  39767. /**
  39768. * Class containing static functions to help procedurally build meshes
  39769. */
  39770. export class CylinderBuilder {
  39771. /**
  39772. * Creates a cylinder or a cone mesh
  39773. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39774. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39775. * * 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.
  39776. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39777. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39778. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39779. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39780. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39781. * * 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).
  39782. * * 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
  39783. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39784. * * 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
  39785. * * 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.
  39786. * * If `enclose` is false, a ring surface is one element.
  39787. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39788. * * 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
  39789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39792. * @param name defines the name of the mesh
  39793. * @param options defines the options used to create the mesh
  39794. * @param scene defines the hosting scene
  39795. * @returns the cylinder mesh
  39796. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39797. */
  39798. static CreateCylinder(name: string, options: {
  39799. height?: number;
  39800. diameterTop?: number;
  39801. diameterBottom?: number;
  39802. diameter?: number;
  39803. tessellation?: number;
  39804. subdivisions?: number;
  39805. arc?: number;
  39806. faceColors?: Color4[];
  39807. faceUV?: Vector4[];
  39808. updatable?: boolean;
  39809. hasRings?: boolean;
  39810. enclose?: boolean;
  39811. sideOrientation?: number;
  39812. frontUVs?: Vector4;
  39813. backUVs?: Vector4;
  39814. }, scene: any): Mesh;
  39815. }
  39816. }
  39817. declare module "babylonjs/Gamepads/gamepadManager" {
  39818. import { Observable } from "babylonjs/Misc/observable";
  39819. import { Nullable } from "babylonjs/types";
  39820. import { Scene } from "babylonjs/scene";
  39821. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39822. /**
  39823. * Manager for handling gamepads
  39824. */
  39825. export class GamepadManager {
  39826. private _scene?;
  39827. private _babylonGamepads;
  39828. private _oneGamepadConnected;
  39829. /** @hidden */
  39830. _isMonitoring: boolean;
  39831. private _gamepadEventSupported;
  39832. private _gamepadSupport;
  39833. /**
  39834. * observable to be triggered when the gamepad controller has been connected
  39835. */
  39836. onGamepadConnectedObservable: Observable<Gamepad>;
  39837. /**
  39838. * observable to be triggered when the gamepad controller has been disconnected
  39839. */
  39840. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39841. private _onGamepadConnectedEvent;
  39842. private _onGamepadDisconnectedEvent;
  39843. /**
  39844. * Initializes the gamepad manager
  39845. * @param _scene BabylonJS scene
  39846. */
  39847. constructor(_scene?: Scene | undefined);
  39848. /**
  39849. * The gamepads in the game pad manager
  39850. */
  39851. readonly gamepads: Gamepad[];
  39852. /**
  39853. * Get the gamepad controllers based on type
  39854. * @param type The type of gamepad controller
  39855. * @returns Nullable gamepad
  39856. */
  39857. getGamepadByType(type?: number): Nullable<Gamepad>;
  39858. /**
  39859. * Disposes the gamepad manager
  39860. */
  39861. dispose(): void;
  39862. private _addNewGamepad;
  39863. private _startMonitoringGamepads;
  39864. private _stopMonitoringGamepads;
  39865. /** @hidden */
  39866. _checkGamepadsStatus(): void;
  39867. private _updateGamepadObjects;
  39868. }
  39869. }
  39870. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39871. import { Nullable } from "babylonjs/types";
  39872. import { Scene } from "babylonjs/scene";
  39873. import { ISceneComponent } from "babylonjs/sceneComponent";
  39874. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39875. module "babylonjs/scene" {
  39876. interface Scene {
  39877. /** @hidden */
  39878. _gamepadManager: Nullable<GamepadManager>;
  39879. /**
  39880. * Gets the gamepad manager associated with the scene
  39881. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39882. */
  39883. gamepadManager: GamepadManager;
  39884. }
  39885. }
  39886. module "babylonjs/Cameras/freeCameraInputsManager" {
  39887. /**
  39888. * Interface representing a free camera inputs manager
  39889. */
  39890. interface FreeCameraInputsManager {
  39891. /**
  39892. * Adds gamepad input support to the FreeCameraInputsManager.
  39893. * @returns the FreeCameraInputsManager
  39894. */
  39895. addGamepad(): FreeCameraInputsManager;
  39896. }
  39897. }
  39898. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39899. /**
  39900. * Interface representing an arc rotate camera inputs manager
  39901. */
  39902. interface ArcRotateCameraInputsManager {
  39903. /**
  39904. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39905. * @returns the camera inputs manager
  39906. */
  39907. addGamepad(): ArcRotateCameraInputsManager;
  39908. }
  39909. }
  39910. /**
  39911. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39912. */
  39913. export class GamepadSystemSceneComponent implements ISceneComponent {
  39914. /**
  39915. * The component name helpfull to identify the component in the list of scene components.
  39916. */
  39917. readonly name: string;
  39918. /**
  39919. * The scene the component belongs to.
  39920. */
  39921. scene: Scene;
  39922. /**
  39923. * Creates a new instance of the component for the given scene
  39924. * @param scene Defines the scene to register the component in
  39925. */
  39926. constructor(scene: Scene);
  39927. /**
  39928. * Registers the component in a given scene
  39929. */
  39930. register(): void;
  39931. /**
  39932. * Rebuilds the elements related to this component in case of
  39933. * context lost for instance.
  39934. */
  39935. rebuild(): void;
  39936. /**
  39937. * Disposes the component and the associated ressources
  39938. */
  39939. dispose(): void;
  39940. private _beforeCameraUpdate;
  39941. }
  39942. }
  39943. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39944. import { Observable } from "babylonjs/Misc/observable";
  39945. import { Nullable } from "babylonjs/types";
  39946. import { Camera } from "babylonjs/Cameras/camera";
  39947. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39948. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39949. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39950. import { Scene } from "babylonjs/scene";
  39951. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39952. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39954. import { Mesh } from "babylonjs/Meshes/mesh";
  39955. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39956. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39957. import "babylonjs/Meshes/Builders/groundBuilder";
  39958. import "babylonjs/Meshes/Builders/torusBuilder";
  39959. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39960. import "babylonjs/Gamepads/gamepadSceneComponent";
  39961. import "babylonjs/Animations/animatable";
  39962. /**
  39963. * Options to modify the vr teleportation behavior.
  39964. */
  39965. export interface VRTeleportationOptions {
  39966. /**
  39967. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39968. */
  39969. floorMeshName?: string;
  39970. /**
  39971. * A list of meshes to be used as the teleportation floor. (default: empty)
  39972. */
  39973. floorMeshes?: Mesh[];
  39974. }
  39975. /**
  39976. * Options to modify the vr experience helper's behavior.
  39977. */
  39978. export interface VRExperienceHelperOptions extends WebVROptions {
  39979. /**
  39980. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39981. */
  39982. createDeviceOrientationCamera?: boolean;
  39983. /**
  39984. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39985. */
  39986. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39987. /**
  39988. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39989. */
  39990. laserToggle?: boolean;
  39991. /**
  39992. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39993. */
  39994. floorMeshes?: Mesh[];
  39995. /**
  39996. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39997. */
  39998. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39999. }
  40000. /**
  40001. * Event containing information after VR has been entered
  40002. */
  40003. export class OnAfterEnteringVRObservableEvent {
  40004. /**
  40005. * If entering vr was successful
  40006. */
  40007. success: boolean;
  40008. }
  40009. /**
  40010. * Helps to quickly add VR support to an existing scene.
  40011. * See http://doc.babylonjs.com/how_to/webvr_helper
  40012. */
  40013. export class VRExperienceHelper {
  40014. /** Options to modify the vr experience helper's behavior. */
  40015. webVROptions: VRExperienceHelperOptions;
  40016. private _scene;
  40017. private _position;
  40018. private _btnVR;
  40019. private _btnVRDisplayed;
  40020. private _webVRsupported;
  40021. private _webVRready;
  40022. private _webVRrequesting;
  40023. private _webVRpresenting;
  40024. private _hasEnteredVR;
  40025. private _fullscreenVRpresenting;
  40026. private _canvas;
  40027. private _webVRCamera;
  40028. private _vrDeviceOrientationCamera;
  40029. private _deviceOrientationCamera;
  40030. private _existingCamera;
  40031. private _onKeyDown;
  40032. private _onVrDisplayPresentChange;
  40033. private _onVRDisplayChanged;
  40034. private _onVRRequestPresentStart;
  40035. private _onVRRequestPresentComplete;
  40036. /**
  40037. * Observable raised right before entering VR.
  40038. */
  40039. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40040. /**
  40041. * Observable raised when entering VR has completed.
  40042. */
  40043. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40044. /**
  40045. * Observable raised when exiting VR.
  40046. */
  40047. onExitingVRObservable: Observable<VRExperienceHelper>;
  40048. /**
  40049. * Observable raised when controller mesh is loaded.
  40050. */
  40051. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40052. /** Return this.onEnteringVRObservable
  40053. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40054. */
  40055. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40056. /** Return this.onExitingVRObservable
  40057. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40058. */
  40059. readonly onExitingVR: Observable<VRExperienceHelper>;
  40060. /** Return this.onControllerMeshLoadedObservable
  40061. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40062. */
  40063. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40064. private _rayLength;
  40065. private _useCustomVRButton;
  40066. private _teleportationRequested;
  40067. private _teleportActive;
  40068. private _floorMeshName;
  40069. private _floorMeshesCollection;
  40070. private _rotationAllowed;
  40071. private _teleportBackwardsVector;
  40072. private _teleportationTarget;
  40073. private _isDefaultTeleportationTarget;
  40074. private _postProcessMove;
  40075. private _teleportationFillColor;
  40076. private _teleportationBorderColor;
  40077. private _rotationAngle;
  40078. private _haloCenter;
  40079. private _cameraGazer;
  40080. private _padSensibilityUp;
  40081. private _padSensibilityDown;
  40082. private _leftController;
  40083. private _rightController;
  40084. /**
  40085. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40086. */
  40087. onNewMeshSelected: Observable<AbstractMesh>;
  40088. /**
  40089. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40090. */
  40091. onNewMeshPicked: Observable<PickingInfo>;
  40092. private _circleEase;
  40093. /**
  40094. * Observable raised before camera teleportation
  40095. */
  40096. onBeforeCameraTeleport: Observable<Vector3>;
  40097. /**
  40098. * Observable raised after camera teleportation
  40099. */
  40100. onAfterCameraTeleport: Observable<Vector3>;
  40101. /**
  40102. * Observable raised when current selected mesh gets unselected
  40103. */
  40104. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40105. private _raySelectionPredicate;
  40106. /**
  40107. * To be optionaly changed by user to define custom ray selection
  40108. */
  40109. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40110. /**
  40111. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40112. */
  40113. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40114. /**
  40115. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40116. */
  40117. teleportationEnabled: boolean;
  40118. private _defaultHeight;
  40119. private _teleportationInitialized;
  40120. private _interactionsEnabled;
  40121. private _interactionsRequested;
  40122. private _displayGaze;
  40123. private _displayLaserPointer;
  40124. /**
  40125. * The mesh used to display where the user is going to teleport.
  40126. */
  40127. /**
  40128. * Sets the mesh to be used to display where the user is going to teleport.
  40129. */
  40130. teleportationTarget: Mesh;
  40131. /**
  40132. * 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
  40133. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40134. * See http://doc.babylonjs.com/resources/baking_transformations
  40135. */
  40136. gazeTrackerMesh: Mesh;
  40137. /**
  40138. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40139. */
  40140. updateGazeTrackerScale: boolean;
  40141. /**
  40142. * If the gaze trackers color should be updated when selecting meshes
  40143. */
  40144. updateGazeTrackerColor: boolean;
  40145. /**
  40146. * The gaze tracking mesh corresponding to the left controller
  40147. */
  40148. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40149. /**
  40150. * The gaze tracking mesh corresponding to the right controller
  40151. */
  40152. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40153. /**
  40154. * If the ray of the gaze should be displayed.
  40155. */
  40156. /**
  40157. * Sets if the ray of the gaze should be displayed.
  40158. */
  40159. displayGaze: boolean;
  40160. /**
  40161. * If the ray of the LaserPointer should be displayed.
  40162. */
  40163. /**
  40164. * Sets if the ray of the LaserPointer should be displayed.
  40165. */
  40166. displayLaserPointer: boolean;
  40167. /**
  40168. * The deviceOrientationCamera used as the camera when not in VR.
  40169. */
  40170. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40171. /**
  40172. * Based on the current WebVR support, returns the current VR camera used.
  40173. */
  40174. readonly currentVRCamera: Nullable<Camera>;
  40175. /**
  40176. * The webVRCamera which is used when in VR.
  40177. */
  40178. readonly webVRCamera: WebVRFreeCamera;
  40179. /**
  40180. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40181. */
  40182. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40183. private readonly _teleportationRequestInitiated;
  40184. /**
  40185. * Defines wether or not Pointer lock should be requested when switching to
  40186. * full screen.
  40187. */
  40188. requestPointerLockOnFullScreen: boolean;
  40189. /**
  40190. * Instantiates a VRExperienceHelper.
  40191. * Helps to quickly add VR support to an existing scene.
  40192. * @param scene The scene the VRExperienceHelper belongs to.
  40193. * @param webVROptions Options to modify the vr experience helper's behavior.
  40194. */
  40195. constructor(scene: Scene,
  40196. /** Options to modify the vr experience helper's behavior. */
  40197. webVROptions?: VRExperienceHelperOptions);
  40198. private _onDefaultMeshLoaded;
  40199. private _onResize;
  40200. private _onFullscreenChange;
  40201. /**
  40202. * Gets a value indicating if we are currently in VR mode.
  40203. */
  40204. readonly isInVRMode: boolean;
  40205. private onVrDisplayPresentChange;
  40206. private onVRDisplayChanged;
  40207. private moveButtonToBottomRight;
  40208. private displayVRButton;
  40209. private updateButtonVisibility;
  40210. private _cachedAngularSensibility;
  40211. /**
  40212. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40213. * Otherwise, will use the fullscreen API.
  40214. */
  40215. enterVR(): void;
  40216. /**
  40217. * Attempt to exit VR, or fullscreen.
  40218. */
  40219. exitVR(): void;
  40220. /**
  40221. * The position of the vr experience helper.
  40222. */
  40223. /**
  40224. * Sets the position of the vr experience helper.
  40225. */
  40226. position: Vector3;
  40227. /**
  40228. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40229. */
  40230. enableInteractions(): void;
  40231. private readonly _noControllerIsActive;
  40232. private beforeRender;
  40233. private _isTeleportationFloor;
  40234. /**
  40235. * Adds a floor mesh to be used for teleportation.
  40236. * @param floorMesh the mesh to be used for teleportation.
  40237. */
  40238. addFloorMesh(floorMesh: Mesh): void;
  40239. /**
  40240. * Removes a floor mesh from being used for teleportation.
  40241. * @param floorMesh the mesh to be removed.
  40242. */
  40243. removeFloorMesh(floorMesh: Mesh): void;
  40244. /**
  40245. * Enables interactions and teleportation using the VR controllers and gaze.
  40246. * @param vrTeleportationOptions options to modify teleportation behavior.
  40247. */
  40248. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40249. private _onNewGamepadConnected;
  40250. private _tryEnableInteractionOnController;
  40251. private _onNewGamepadDisconnected;
  40252. private _enableInteractionOnController;
  40253. private _checkTeleportWithRay;
  40254. private _checkRotate;
  40255. private _checkTeleportBackwards;
  40256. private _enableTeleportationOnController;
  40257. private _createTeleportationCircles;
  40258. private _displayTeleportationTarget;
  40259. private _hideTeleportationTarget;
  40260. private _rotateCamera;
  40261. private _moveTeleportationSelectorTo;
  40262. private _workingVector;
  40263. private _workingQuaternion;
  40264. private _workingMatrix;
  40265. /**
  40266. * Teleports the users feet to the desired location
  40267. * @param location The location where the user's feet should be placed
  40268. */
  40269. teleportCamera(location: Vector3): void;
  40270. private _convertNormalToDirectionOfRay;
  40271. private _castRayAndSelectObject;
  40272. private _notifySelectedMeshUnselected;
  40273. /**
  40274. * Sets the color of the laser ray from the vr controllers.
  40275. * @param color new color for the ray.
  40276. */
  40277. changeLaserColor(color: Color3): void;
  40278. /**
  40279. * Sets the color of the ray from the vr headsets gaze.
  40280. * @param color new color for the ray.
  40281. */
  40282. changeGazeColor(color: Color3): void;
  40283. /**
  40284. * Exits VR and disposes of the vr experience helper
  40285. */
  40286. dispose(): void;
  40287. /**
  40288. * Gets the name of the VRExperienceHelper class
  40289. * @returns "VRExperienceHelper"
  40290. */
  40291. getClassName(): string;
  40292. }
  40293. }
  40294. declare module "babylonjs/Cameras/VR/index" {
  40295. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40296. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40297. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40298. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40299. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40300. export * from "babylonjs/Cameras/VR/webVRCamera";
  40301. }
  40302. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40303. import { Observable } from "babylonjs/Misc/observable";
  40304. import { Nullable } from "babylonjs/types";
  40305. import { IDisposable, Scene } from "babylonjs/scene";
  40306. import { Vector3 } from "babylonjs/Maths/math";
  40307. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40308. import { Ray } from "babylonjs/Culling/ray";
  40309. /**
  40310. * Manages an XRSession
  40311. * @see https://doc.babylonjs.com/how_to/webxr
  40312. */
  40313. export class WebXRSessionManager implements IDisposable {
  40314. private scene;
  40315. /**
  40316. * Fires every time a new xrFrame arrives which can be used to update the camera
  40317. */
  40318. onXRFrameObservable: Observable<any>;
  40319. /**
  40320. * Fires when the xr session is ended either by the device or manually done
  40321. */
  40322. onXRSessionEnded: Observable<any>;
  40323. /** @hidden */
  40324. _xrSession: XRSession;
  40325. /** @hidden */
  40326. _frameOfReference: XRFrameOfReference;
  40327. /** @hidden */
  40328. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40329. /** @hidden */
  40330. _currentXRFrame: Nullable<XRFrame>;
  40331. private _xrNavigator;
  40332. private _xrDevice;
  40333. private _tmpMatrix;
  40334. /**
  40335. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40336. * @param scene The scene which the session should be created for
  40337. */
  40338. constructor(scene: Scene);
  40339. /**
  40340. * Initializes the manager
  40341. * After initialization enterXR can be called to start an XR session
  40342. * @returns Promise which resolves after it is initialized
  40343. */
  40344. initializeAsync(): Promise<void>;
  40345. /**
  40346. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40347. * @param sessionCreationOptions xr options to create the session with
  40348. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40349. * @returns Promise which resolves after it enters XR
  40350. */
  40351. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40352. /**
  40353. * Stops the xrSession and restores the renderloop
  40354. * @returns Promise which resolves after it exits XR
  40355. */
  40356. exitXRAsync(): Promise<void>;
  40357. /**
  40358. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40359. * @param ray ray to cast into the environment
  40360. * @returns Promise which resolves with a collision point in the environment if it exists
  40361. */
  40362. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40363. /**
  40364. * Checks if a session would be supported for the creation options specified
  40365. * @param options creation options to check if they are supported
  40366. * @returns true if supported
  40367. */
  40368. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40369. /**
  40370. * @hidden
  40371. * Converts the render layer of xrSession to a render target
  40372. * @param session session to create render target for
  40373. * @param scene scene the new render target should be created for
  40374. */
  40375. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40376. /**
  40377. * Disposes of the session manager
  40378. */
  40379. dispose(): void;
  40380. }
  40381. }
  40382. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40383. import { Scene } from "babylonjs/scene";
  40384. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40385. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40386. /**
  40387. * WebXR Camera which holds the views for the xrSession
  40388. * @see https://doc.babylonjs.com/how_to/webxr
  40389. */
  40390. export class WebXRCamera extends FreeCamera {
  40391. private static _TmpMatrix;
  40392. /**
  40393. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40394. * @param name the name of the camera
  40395. * @param scene the scene to add the camera to
  40396. */
  40397. constructor(name: string, scene: Scene);
  40398. private _updateNumberOfRigCameras;
  40399. /** @hidden */
  40400. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40401. /**
  40402. * Updates the cameras position from the current pose information of the XR session
  40403. * @param xrSessionManager the session containing pose information
  40404. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40405. */
  40406. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40407. }
  40408. }
  40409. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40410. import { Nullable } from "babylonjs/types";
  40411. import { Observable } from "babylonjs/Misc/observable";
  40412. import { IDisposable, Scene } from "babylonjs/scene";
  40413. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40415. import { Ray } from "babylonjs/Culling/ray";
  40416. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40417. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40418. /**
  40419. * States of the webXR experience
  40420. */
  40421. export enum WebXRState {
  40422. /**
  40423. * Transitioning to being in XR mode
  40424. */
  40425. ENTERING_XR = 0,
  40426. /**
  40427. * Transitioning to non XR mode
  40428. */
  40429. EXITING_XR = 1,
  40430. /**
  40431. * In XR mode and presenting
  40432. */
  40433. IN_XR = 2,
  40434. /**
  40435. * Not entered XR mode
  40436. */
  40437. NOT_IN_XR = 3
  40438. }
  40439. /**
  40440. * Helper class used to enable XR
  40441. * @see https://doc.babylonjs.com/how_to/webxr
  40442. */
  40443. export class WebXRExperienceHelper implements IDisposable {
  40444. private scene;
  40445. /**
  40446. * 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
  40447. */
  40448. container: AbstractMesh;
  40449. /**
  40450. * Camera used to render xr content
  40451. */
  40452. camera: WebXRCamera;
  40453. /**
  40454. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40455. */
  40456. state: WebXRState;
  40457. private _setState;
  40458. private static _TmpVector;
  40459. /**
  40460. * Fires when the state of the experience helper has changed
  40461. */
  40462. onStateChangedObservable: Observable<WebXRState>;
  40463. /** @hidden */
  40464. _sessionManager: WebXRSessionManager;
  40465. private _nonVRCamera;
  40466. private _originalSceneAutoClear;
  40467. private _supported;
  40468. /**
  40469. * Creates the experience helper
  40470. * @param scene the scene to attach the experience helper to
  40471. * @returns a promise for the experience helper
  40472. */
  40473. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40474. /**
  40475. * Creates a WebXRExperienceHelper
  40476. * @param scene The scene the helper should be created in
  40477. */
  40478. private constructor();
  40479. /**
  40480. * Exits XR mode and returns the scene to its original state
  40481. * @returns promise that resolves after xr mode has exited
  40482. */
  40483. exitXRAsync(): Promise<void>;
  40484. /**
  40485. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40486. * @param sessionCreationOptions options for the XR session
  40487. * @param frameOfReference frame of reference of the XR session
  40488. * @returns promise that resolves after xr mode has entered
  40489. */
  40490. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40491. /**
  40492. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40493. * @param ray ray to cast into the environment
  40494. * @returns Promise which resolves with a collision point in the environment if it exists
  40495. */
  40496. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40497. /**
  40498. * Updates the global position of the camera by moving the camera's container
  40499. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40500. * @param position The desired global position of the camera
  40501. */
  40502. setPositionOfCameraUsingContainer(position: Vector3): void;
  40503. /**
  40504. * Rotates the xr camera by rotating the camera's container around the camera's position
  40505. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40506. * @param rotation the desired quaternion rotation to apply to the camera
  40507. */
  40508. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40509. /**
  40510. * Checks if the creation options are supported by the xr session
  40511. * @param options creation options
  40512. * @returns true if supported
  40513. */
  40514. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40515. /**
  40516. * Disposes of the experience helper
  40517. */
  40518. dispose(): void;
  40519. }
  40520. }
  40521. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40522. import { Nullable } from "babylonjs/types";
  40523. import { Observable } from "babylonjs/Misc/observable";
  40524. import { IDisposable, Scene } from "babylonjs/scene";
  40525. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40526. /**
  40527. * Button which can be used to enter a different mode of XR
  40528. */
  40529. export class WebXREnterExitUIButton {
  40530. /** button element */
  40531. element: HTMLElement;
  40532. /** XR initialization options for the button */
  40533. initializationOptions: XRSessionCreationOptions;
  40534. /**
  40535. * Creates a WebXREnterExitUIButton
  40536. * @param element button element
  40537. * @param initializationOptions XR initialization options for the button
  40538. */
  40539. constructor(
  40540. /** button element */
  40541. element: HTMLElement,
  40542. /** XR initialization options for the button */
  40543. initializationOptions: XRSessionCreationOptions);
  40544. /**
  40545. * Overwritable function which can be used to update the button's visuals when the state changes
  40546. * @param activeButton the current active button in the UI
  40547. */
  40548. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40549. }
  40550. /**
  40551. * Options to create the webXR UI
  40552. */
  40553. export class WebXREnterExitUIOptions {
  40554. /**
  40555. * Context to enter xr with
  40556. */
  40557. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40558. /**
  40559. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40560. */
  40561. customButtons?: Array<WebXREnterExitUIButton>;
  40562. }
  40563. /**
  40564. * UI to allow the user to enter/exit XR mode
  40565. */
  40566. export class WebXREnterExitUI implements IDisposable {
  40567. private scene;
  40568. private _overlay;
  40569. private _buttons;
  40570. private _activeButton;
  40571. /**
  40572. * Fired every time the active button is changed.
  40573. *
  40574. * When xr is entered via a button that launches xr that button will be the callback parameter
  40575. *
  40576. * When exiting xr the callback parameter will be null)
  40577. */
  40578. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40579. /**
  40580. * Creates UI to allow the user to enter/exit XR mode
  40581. * @param scene the scene to add the ui to
  40582. * @param helper the xr experience helper to enter/exit xr with
  40583. * @param options options to configure the UI
  40584. * @returns the created ui
  40585. */
  40586. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40587. private constructor();
  40588. private _updateButtons;
  40589. /**
  40590. * Disposes of the object
  40591. */
  40592. dispose(): void;
  40593. }
  40594. }
  40595. declare module "babylonjs/Cameras/XR/webXRInput" {
  40596. import { IDisposable, Scene } from "babylonjs/scene";
  40597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40598. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40599. /**
  40600. * Represents an XR input
  40601. */
  40602. export class WebXRController {
  40603. /**
  40604. * 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
  40605. */
  40606. grip?: AbstractMesh;
  40607. /**
  40608. * Pointer which can be used to select objects or attach a visible laser to
  40609. */
  40610. pointer: AbstractMesh;
  40611. /**
  40612. * Creates the controller
  40613. * @see https://doc.babylonjs.com/how_to/webxr
  40614. * @param scene the scene which the controller should be associated to
  40615. */
  40616. constructor(scene: Scene);
  40617. /**
  40618. * Disposes of the object
  40619. */
  40620. dispose(): void;
  40621. }
  40622. /**
  40623. * XR input used to track XR inputs such as controllers/rays
  40624. */
  40625. export class WebXRInput implements IDisposable {
  40626. private helper;
  40627. /**
  40628. * XR controllers being tracked
  40629. */
  40630. controllers: Array<WebXRController>;
  40631. private _tmpMatrix;
  40632. private _frameObserver;
  40633. /**
  40634. * Initializes the WebXRInput
  40635. * @param helper experience helper which the input should be created for
  40636. */
  40637. constructor(helper: WebXRExperienceHelper);
  40638. /**
  40639. * Disposes of the object
  40640. */
  40641. dispose(): void;
  40642. }
  40643. }
  40644. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40645. import { Nullable } from "babylonjs/types";
  40646. import { IDisposable } from "babylonjs/scene";
  40647. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40648. /**
  40649. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40650. */
  40651. export class WebXRManagedOutputCanvas implements IDisposable {
  40652. private _canvas;
  40653. /**
  40654. * xrpresent context of the canvas which can be used to display/mirror xr content
  40655. */
  40656. canvasContext: Nullable<WebGLRenderingContext>;
  40657. /**
  40658. * Initializes the canvas to be added/removed upon entering/exiting xr
  40659. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40660. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40661. */
  40662. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40663. /**
  40664. * Disposes of the object
  40665. */
  40666. dispose(): void;
  40667. private _setManagedOutputCanvas;
  40668. private _addCanvas;
  40669. private _removeCanvas;
  40670. }
  40671. }
  40672. declare module "babylonjs/Cameras/XR/index" {
  40673. export * from "babylonjs/Cameras/XR/webXRCamera";
  40674. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40675. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40676. export * from "babylonjs/Cameras/XR/webXRInput";
  40677. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40678. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40679. }
  40680. declare module "babylonjs/Cameras/RigModes/index" {
  40681. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40682. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40683. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40684. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40685. }
  40686. declare module "babylonjs/Cameras/index" {
  40687. export * from "babylonjs/Cameras/Inputs/index";
  40688. export * from "babylonjs/Cameras/cameraInputsManager";
  40689. export * from "babylonjs/Cameras/camera";
  40690. export * from "babylonjs/Cameras/targetCamera";
  40691. export * from "babylonjs/Cameras/freeCamera";
  40692. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40693. export * from "babylonjs/Cameras/touchCamera";
  40694. export * from "babylonjs/Cameras/arcRotateCamera";
  40695. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40696. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40697. export * from "babylonjs/Cameras/flyCamera";
  40698. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40699. export * from "babylonjs/Cameras/followCamera";
  40700. export * from "babylonjs/Cameras/gamepadCamera";
  40701. export * from "babylonjs/Cameras/Stereoscopic/index";
  40702. export * from "babylonjs/Cameras/universalCamera";
  40703. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40704. export * from "babylonjs/Cameras/VR/index";
  40705. export * from "babylonjs/Cameras/XR/index";
  40706. export * from "babylonjs/Cameras/RigModes/index";
  40707. }
  40708. declare module "babylonjs/Collisions/index" {
  40709. export * from "babylonjs/Collisions/collider";
  40710. export * from "babylonjs/Collisions/collisionCoordinator";
  40711. export * from "babylonjs/Collisions/pickingInfo";
  40712. export * from "babylonjs/Collisions/intersectionInfo";
  40713. }
  40714. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40715. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40716. import { Vector3, Plane } from "babylonjs/Maths/math";
  40717. import { Ray } from "babylonjs/Culling/ray";
  40718. /**
  40719. * Contains an array of blocks representing the octree
  40720. */
  40721. export interface IOctreeContainer<T> {
  40722. /**
  40723. * Blocks within the octree
  40724. */
  40725. blocks: Array<OctreeBlock<T>>;
  40726. }
  40727. /**
  40728. * Class used to store a cell in an octree
  40729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40730. */
  40731. export class OctreeBlock<T> {
  40732. /**
  40733. * Gets the content of the current block
  40734. */
  40735. entries: T[];
  40736. /**
  40737. * Gets the list of block children
  40738. */
  40739. blocks: Array<OctreeBlock<T>>;
  40740. private _depth;
  40741. private _maxDepth;
  40742. private _capacity;
  40743. private _minPoint;
  40744. private _maxPoint;
  40745. private _boundingVectors;
  40746. private _creationFunc;
  40747. /**
  40748. * Creates a new block
  40749. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40750. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40751. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40752. * @param depth defines the current depth of this block in the octree
  40753. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40754. * @param creationFunc defines a callback to call when an element is added to the block
  40755. */
  40756. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40757. /**
  40758. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40759. */
  40760. readonly capacity: number;
  40761. /**
  40762. * Gets the minimum vector (in world space) of the block's bounding box
  40763. */
  40764. readonly minPoint: Vector3;
  40765. /**
  40766. * Gets the maximum vector (in world space) of the block's bounding box
  40767. */
  40768. readonly maxPoint: Vector3;
  40769. /**
  40770. * Add a new element to this block
  40771. * @param entry defines the element to add
  40772. */
  40773. addEntry(entry: T): void;
  40774. /**
  40775. * Remove an element from this block
  40776. * @param entry defines the element to remove
  40777. */
  40778. removeEntry(entry: T): void;
  40779. /**
  40780. * Add an array of elements to this block
  40781. * @param entries defines the array of elements to add
  40782. */
  40783. addEntries(entries: T[]): void;
  40784. /**
  40785. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40786. * @param frustumPlanes defines the frustum planes to test
  40787. * @param selection defines the array to store current content if selection is positive
  40788. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40789. */
  40790. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40791. /**
  40792. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40793. * @param sphereCenter defines the bounding sphere center
  40794. * @param sphereRadius defines the bounding sphere radius
  40795. * @param selection defines the array to store current content if selection is positive
  40796. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40797. */
  40798. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40799. /**
  40800. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40801. * @param ray defines the ray to test with
  40802. * @param selection defines the array to store current content if selection is positive
  40803. */
  40804. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40805. /**
  40806. * Subdivide the content into child blocks (this block will then be empty)
  40807. */
  40808. createInnerBlocks(): void;
  40809. /**
  40810. * @hidden
  40811. */
  40812. 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;
  40813. }
  40814. }
  40815. declare module "babylonjs/Culling/Octrees/octree" {
  40816. import { SmartArray } from "babylonjs/Misc/smartArray";
  40817. import { Vector3, Plane } from "babylonjs/Maths/math";
  40818. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40820. import { Ray } from "babylonjs/Culling/ray";
  40821. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40822. /**
  40823. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40824. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40825. */
  40826. export class Octree<T> {
  40827. /** 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.) */
  40828. maxDepth: number;
  40829. /**
  40830. * Blocks within the octree containing objects
  40831. */
  40832. blocks: Array<OctreeBlock<T>>;
  40833. /**
  40834. * Content stored in the octree
  40835. */
  40836. dynamicContent: T[];
  40837. private _maxBlockCapacity;
  40838. private _selectionContent;
  40839. private _creationFunc;
  40840. /**
  40841. * Creates a octree
  40842. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40843. * @param creationFunc function to be used to instatiate the octree
  40844. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40845. * @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.)
  40846. */
  40847. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40848. /** 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.) */
  40849. maxDepth?: number);
  40850. /**
  40851. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40852. * @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);
  40853. * @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);
  40854. * @param entries meshes to be added to the octree blocks
  40855. */
  40856. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40857. /**
  40858. * Adds a mesh to the octree
  40859. * @param entry Mesh to add to the octree
  40860. */
  40861. addMesh(entry: T): void;
  40862. /**
  40863. * Remove an element from the octree
  40864. * @param entry defines the element to remove
  40865. */
  40866. removeMesh(entry: T): void;
  40867. /**
  40868. * Selects an array of meshes within the frustum
  40869. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40870. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40871. * @returns array of meshes within the frustum
  40872. */
  40873. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40874. /**
  40875. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40876. * @param sphereCenter defines the bounding sphere center
  40877. * @param sphereRadius defines the bounding sphere radius
  40878. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40879. * @returns an array of objects that intersect the sphere
  40880. */
  40881. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40882. /**
  40883. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40884. * @param ray defines the ray to test with
  40885. * @returns array of intersected objects
  40886. */
  40887. intersectsRay(ray: Ray): SmartArray<T>;
  40888. /**
  40889. * Adds a mesh into the octree block if it intersects the block
  40890. */
  40891. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40892. /**
  40893. * Adds a submesh into the octree block if it intersects the block
  40894. */
  40895. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40896. }
  40897. }
  40898. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40899. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40900. import { Scene } from "babylonjs/scene";
  40901. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40903. import { Ray } from "babylonjs/Culling/ray";
  40904. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40905. import { Collider } from "babylonjs/Collisions/collider";
  40906. module "babylonjs/scene" {
  40907. interface Scene {
  40908. /**
  40909. * @hidden
  40910. * Backing Filed
  40911. */
  40912. _selectionOctree: Octree<AbstractMesh>;
  40913. /**
  40914. * Gets the octree used to boost mesh selection (picking)
  40915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40916. */
  40917. selectionOctree: Octree<AbstractMesh>;
  40918. /**
  40919. * Creates or updates the octree used to boost selection (picking)
  40920. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40921. * @param maxCapacity defines the maximum capacity per leaf
  40922. * @param maxDepth defines the maximum depth of the octree
  40923. * @returns an octree of AbstractMesh
  40924. */
  40925. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40926. }
  40927. }
  40928. module "babylonjs/Meshes/abstractMesh" {
  40929. interface AbstractMesh {
  40930. /**
  40931. * @hidden
  40932. * Backing Field
  40933. */
  40934. _submeshesOctree: Octree<SubMesh>;
  40935. /**
  40936. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40937. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40938. * @param maxCapacity defines the maximum size of each block (64 by default)
  40939. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40940. * @returns the new octree
  40941. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40943. */
  40944. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40945. }
  40946. }
  40947. /**
  40948. * Defines the octree scene component responsible to manage any octrees
  40949. * in a given scene.
  40950. */
  40951. export class OctreeSceneComponent {
  40952. /**
  40953. * The component name helpfull to identify the component in the list of scene components.
  40954. */
  40955. readonly name: string;
  40956. /**
  40957. * The scene the component belongs to.
  40958. */
  40959. scene: Scene;
  40960. /**
  40961. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40962. */
  40963. readonly checksIsEnabled: boolean;
  40964. /**
  40965. * Creates a new instance of the component for the given scene
  40966. * @param scene Defines the scene to register the component in
  40967. */
  40968. constructor(scene: Scene);
  40969. /**
  40970. * Registers the component in a given scene
  40971. */
  40972. register(): void;
  40973. /**
  40974. * Return the list of active meshes
  40975. * @returns the list of active meshes
  40976. */
  40977. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40978. /**
  40979. * Return the list of active sub meshes
  40980. * @param mesh The mesh to get the candidates sub meshes from
  40981. * @returns the list of active sub meshes
  40982. */
  40983. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40984. private _tempRay;
  40985. /**
  40986. * Return the list of sub meshes intersecting with a given local ray
  40987. * @param mesh defines the mesh to find the submesh for
  40988. * @param localRay defines the ray in local space
  40989. * @returns the list of intersecting sub meshes
  40990. */
  40991. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40992. /**
  40993. * Return the list of sub meshes colliding with a collider
  40994. * @param mesh defines the mesh to find the submesh for
  40995. * @param collider defines the collider to evaluate the collision against
  40996. * @returns the list of colliding sub meshes
  40997. */
  40998. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40999. /**
  41000. * Rebuilds the elements related to this component in case of
  41001. * context lost for instance.
  41002. */
  41003. rebuild(): void;
  41004. /**
  41005. * Disposes the component and the associated ressources.
  41006. */
  41007. dispose(): void;
  41008. }
  41009. }
  41010. declare module "babylonjs/Culling/Octrees/index" {
  41011. export * from "babylonjs/Culling/Octrees/octree";
  41012. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41013. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41014. }
  41015. declare module "babylonjs/Culling/index" {
  41016. export * from "babylonjs/Culling/boundingBox";
  41017. export * from "babylonjs/Culling/boundingInfo";
  41018. export * from "babylonjs/Culling/boundingSphere";
  41019. export * from "babylonjs/Culling/Octrees/index";
  41020. export * from "babylonjs/Culling/ray";
  41021. }
  41022. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41023. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41024. import { Nullable } from "babylonjs/types";
  41025. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41026. import { Scene } from "babylonjs/scene";
  41027. /**
  41028. * Class containing static functions to help procedurally build meshes
  41029. */
  41030. export class LinesBuilder {
  41031. /**
  41032. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41033. * * 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
  41034. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41035. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41036. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41037. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41038. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41039. * * 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
  41040. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41043. * @param name defines the name of the new line system
  41044. * @param options defines the options used to create the line system
  41045. * @param scene defines the hosting scene
  41046. * @returns a new line system mesh
  41047. */
  41048. static CreateLineSystem(name: string, options: {
  41049. lines: Vector3[][];
  41050. updatable?: boolean;
  41051. instance?: Nullable<LinesMesh>;
  41052. colors?: Nullable<Color4[][]>;
  41053. useVertexAlpha?: boolean;
  41054. }, scene: Nullable<Scene>): LinesMesh;
  41055. /**
  41056. * Creates a line mesh
  41057. * 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
  41058. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41059. * * The parameter `points` is an array successive Vector3
  41060. * * 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
  41061. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41062. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41063. * * When updating an instance, remember that only point positions can change, not the number of points
  41064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41065. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41066. * @param name defines the name of the new line system
  41067. * @param options defines the options used to create the line system
  41068. * @param scene defines the hosting scene
  41069. * @returns a new line mesh
  41070. */
  41071. static CreateLines(name: string, options: {
  41072. points: Vector3[];
  41073. updatable?: boolean;
  41074. instance?: Nullable<LinesMesh>;
  41075. colors?: Color4[];
  41076. useVertexAlpha?: boolean;
  41077. }, scene?: Nullable<Scene>): LinesMesh;
  41078. /**
  41079. * Creates a dashed line mesh
  41080. * * 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
  41081. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41082. * * The parameter `points` is an array successive Vector3
  41083. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41084. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41085. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41086. * * 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
  41087. * * When updating an instance, remember that only point positions can change, not the number of points
  41088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41089. * @param name defines the name of the mesh
  41090. * @param options defines the options used to create the mesh
  41091. * @param scene defines the hosting scene
  41092. * @returns the dashed line mesh
  41093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41094. */
  41095. static CreateDashedLines(name: string, options: {
  41096. points: Vector3[];
  41097. dashSize?: number;
  41098. gapSize?: number;
  41099. dashNb?: number;
  41100. updatable?: boolean;
  41101. instance?: LinesMesh;
  41102. }, scene?: Nullable<Scene>): LinesMesh;
  41103. }
  41104. }
  41105. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41106. import { IDisposable, Scene } from "babylonjs/scene";
  41107. import { Nullable } from "babylonjs/types";
  41108. import { Observable } from "babylonjs/Misc/observable";
  41109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41110. /**
  41111. * Renders a layer on top of an existing scene
  41112. */
  41113. export class UtilityLayerRenderer implements IDisposable {
  41114. /** the original scene that will be rendered on top of */
  41115. originalScene: Scene;
  41116. private _pointerCaptures;
  41117. private _lastPointerEvents;
  41118. private static _DefaultUtilityLayer;
  41119. private static _DefaultKeepDepthUtilityLayer;
  41120. /**
  41121. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41122. */
  41123. pickUtilitySceneFirst: boolean;
  41124. /**
  41125. * 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)
  41126. */
  41127. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41128. /**
  41129. * 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)
  41130. */
  41131. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41132. /**
  41133. * The scene that is rendered on top of the original scene
  41134. */
  41135. utilityLayerScene: Scene;
  41136. /**
  41137. * If the utility layer should automatically be rendered on top of existing scene
  41138. */
  41139. shouldRender: boolean;
  41140. /**
  41141. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41142. */
  41143. onlyCheckPointerDownEvents: boolean;
  41144. /**
  41145. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41146. */
  41147. processAllEvents: boolean;
  41148. /**
  41149. * Observable raised when the pointer move from the utility layer scene to the main scene
  41150. */
  41151. onPointerOutObservable: Observable<number>;
  41152. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41153. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41154. private _afterRenderObserver;
  41155. private _sceneDisposeObserver;
  41156. private _originalPointerObserver;
  41157. /**
  41158. * Instantiates a UtilityLayerRenderer
  41159. * @param originalScene the original scene that will be rendered on top of
  41160. * @param handleEvents boolean indicating if the utility layer should handle events
  41161. */
  41162. constructor(
  41163. /** the original scene that will be rendered on top of */
  41164. originalScene: Scene, handleEvents?: boolean);
  41165. private _notifyObservers;
  41166. /**
  41167. * Renders the utility layers scene on top of the original scene
  41168. */
  41169. render(): void;
  41170. /**
  41171. * Disposes of the renderer
  41172. */
  41173. dispose(): void;
  41174. private _updateCamera;
  41175. }
  41176. }
  41177. declare module "babylonjs/Gizmos/gizmo" {
  41178. import { Nullable } from "babylonjs/types";
  41179. import { IDisposable } from "babylonjs/scene";
  41180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41181. import { Mesh } from "babylonjs/Meshes/mesh";
  41182. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41183. /**
  41184. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41185. */
  41186. export class Gizmo implements IDisposable {
  41187. /** The utility layer the gizmo will be added to */
  41188. gizmoLayer: UtilityLayerRenderer;
  41189. /**
  41190. * The root mesh of the gizmo
  41191. */
  41192. _rootMesh: Mesh;
  41193. private _attachedMesh;
  41194. /**
  41195. * Ratio for the scale of the gizmo (Default: 1)
  41196. */
  41197. scaleRatio: number;
  41198. private _tmpMatrix;
  41199. /**
  41200. * If a custom mesh has been set (Default: false)
  41201. */
  41202. protected _customMeshSet: boolean;
  41203. /**
  41204. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41205. * * When set, interactions will be enabled
  41206. */
  41207. attachedMesh: Nullable<AbstractMesh>;
  41208. /**
  41209. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41210. * @param mesh The mesh to replace the default mesh of the gizmo
  41211. */
  41212. setCustomMesh(mesh: Mesh): void;
  41213. /**
  41214. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41215. */
  41216. updateGizmoRotationToMatchAttachedMesh: boolean;
  41217. /**
  41218. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41219. */
  41220. updateGizmoPositionToMatchAttachedMesh: boolean;
  41221. /**
  41222. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41223. */
  41224. protected _updateScale: boolean;
  41225. protected _interactionsEnabled: boolean;
  41226. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41227. private _beforeRenderObserver;
  41228. /**
  41229. * Creates a gizmo
  41230. * @param gizmoLayer The utility layer the gizmo will be added to
  41231. */
  41232. constructor(
  41233. /** The utility layer the gizmo will be added to */
  41234. gizmoLayer?: UtilityLayerRenderer);
  41235. private _tempVector;
  41236. /**
  41237. * @hidden
  41238. * Updates the gizmo to match the attached mesh's position/rotation
  41239. */
  41240. protected _update(): void;
  41241. /**
  41242. * Disposes of the gizmo
  41243. */
  41244. dispose(): void;
  41245. }
  41246. }
  41247. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41248. import { Observable } from "babylonjs/Misc/observable";
  41249. import { Nullable } from "babylonjs/types";
  41250. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41251. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41253. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41254. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41255. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41256. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41257. import { Scene } from "babylonjs/scene";
  41258. /**
  41259. * Single axis drag gizmo
  41260. */
  41261. export class AxisDragGizmo extends Gizmo {
  41262. /**
  41263. * Drag behavior responsible for the gizmos dragging interactions
  41264. */
  41265. dragBehavior: PointerDragBehavior;
  41266. private _pointerObserver;
  41267. /**
  41268. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41269. */
  41270. snapDistance: number;
  41271. /**
  41272. * Event that fires each time the gizmo snaps to a new location.
  41273. * * snapDistance is the the change in distance
  41274. */
  41275. onSnapObservable: Observable<{
  41276. snapDistance: number;
  41277. }>;
  41278. /** @hidden */
  41279. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41280. /** @hidden */
  41281. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41282. /**
  41283. * Creates an AxisDragGizmo
  41284. * @param gizmoLayer The utility layer the gizmo will be added to
  41285. * @param dragAxis The axis which the gizmo will be able to drag on
  41286. * @param color The color of the gizmo
  41287. */
  41288. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41289. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41290. /**
  41291. * Disposes of the gizmo
  41292. */
  41293. dispose(): void;
  41294. }
  41295. }
  41296. declare module "babylonjs/Debug/axesViewer" {
  41297. import { Vector3 } from "babylonjs/Maths/math";
  41298. import { Nullable } from "babylonjs/types";
  41299. import { Scene } from "babylonjs/scene";
  41300. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41301. /**
  41302. * The Axes viewer will show 3 axes in a specific point in space
  41303. */
  41304. export class AxesViewer {
  41305. private _xAxis;
  41306. private _yAxis;
  41307. private _zAxis;
  41308. private _scaleLinesFactor;
  41309. private _instanced;
  41310. /**
  41311. * Gets the hosting scene
  41312. */
  41313. scene: Scene;
  41314. /**
  41315. * Gets or sets a number used to scale line length
  41316. */
  41317. scaleLines: number;
  41318. /** Gets the node hierarchy used to render x-axis */
  41319. readonly xAxis: TransformNode;
  41320. /** Gets the node hierarchy used to render y-axis */
  41321. readonly yAxis: TransformNode;
  41322. /** Gets the node hierarchy used to render z-axis */
  41323. readonly zAxis: TransformNode;
  41324. /**
  41325. * Creates a new AxesViewer
  41326. * @param scene defines the hosting scene
  41327. * @param scaleLines defines a number used to scale line length (1 by default)
  41328. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41329. * @param xAxis defines the node hierarchy used to render the x-axis
  41330. * @param yAxis defines the node hierarchy used to render the y-axis
  41331. * @param zAxis defines the node hierarchy used to render the z-axis
  41332. */
  41333. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41334. /**
  41335. * Force the viewer to update
  41336. * @param position defines the position of the viewer
  41337. * @param xaxis defines the x axis of the viewer
  41338. * @param yaxis defines the y axis of the viewer
  41339. * @param zaxis defines the z axis of the viewer
  41340. */
  41341. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41342. /**
  41343. * Creates an instance of this axes viewer.
  41344. * @returns a new axes viewer with instanced meshes
  41345. */
  41346. createInstance(): AxesViewer;
  41347. /** Releases resources */
  41348. dispose(): void;
  41349. private static _SetRenderingGroupId;
  41350. }
  41351. }
  41352. declare module "babylonjs/Debug/boneAxesViewer" {
  41353. import { Nullable } from "babylonjs/types";
  41354. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41355. import { Vector3 } from "babylonjs/Maths/math";
  41356. import { Mesh } from "babylonjs/Meshes/mesh";
  41357. import { Bone } from "babylonjs/Bones/bone";
  41358. import { Scene } from "babylonjs/scene";
  41359. /**
  41360. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41361. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41362. */
  41363. export class BoneAxesViewer extends AxesViewer {
  41364. /**
  41365. * Gets or sets the target mesh where to display the axes viewer
  41366. */
  41367. mesh: Nullable<Mesh>;
  41368. /**
  41369. * Gets or sets the target bone where to display the axes viewer
  41370. */
  41371. bone: Nullable<Bone>;
  41372. /** Gets current position */
  41373. pos: Vector3;
  41374. /** Gets direction of X axis */
  41375. xaxis: Vector3;
  41376. /** Gets direction of Y axis */
  41377. yaxis: Vector3;
  41378. /** Gets direction of Z axis */
  41379. zaxis: Vector3;
  41380. /**
  41381. * Creates a new BoneAxesViewer
  41382. * @param scene defines the hosting scene
  41383. * @param bone defines the target bone
  41384. * @param mesh defines the target mesh
  41385. * @param scaleLines defines a scaling factor for line length (1 by default)
  41386. */
  41387. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41388. /**
  41389. * Force the viewer to update
  41390. */
  41391. update(): void;
  41392. /** Releases resources */
  41393. dispose(): void;
  41394. }
  41395. }
  41396. declare module "babylonjs/Debug/debugLayer" {
  41397. import { Observable } from "babylonjs/Misc/observable";
  41398. import { Scene } from "babylonjs/scene";
  41399. /**
  41400. * Interface used to define scene explorer extensibility option
  41401. */
  41402. export interface IExplorerExtensibilityOption {
  41403. /**
  41404. * Define the option label
  41405. */
  41406. label: string;
  41407. /**
  41408. * Defines the action to execute on click
  41409. */
  41410. action: (entity: any) => void;
  41411. }
  41412. /**
  41413. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41414. */
  41415. export interface IExplorerExtensibilityGroup {
  41416. /**
  41417. * Defines a predicate to test if a given type mut be extended
  41418. */
  41419. predicate: (entity: any) => boolean;
  41420. /**
  41421. * Gets the list of options added to a type
  41422. */
  41423. entries: IExplorerExtensibilityOption[];
  41424. }
  41425. /**
  41426. * Interface used to define the options to use to create the Inspector
  41427. */
  41428. export interface IInspectorOptions {
  41429. /**
  41430. * Display in overlay mode (default: false)
  41431. */
  41432. overlay?: boolean;
  41433. /**
  41434. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41435. */
  41436. globalRoot?: HTMLElement;
  41437. /**
  41438. * Display the Scene explorer
  41439. */
  41440. showExplorer?: boolean;
  41441. /**
  41442. * Display the property inspector
  41443. */
  41444. showInspector?: boolean;
  41445. /**
  41446. * Display in embed mode (both panes on the right)
  41447. */
  41448. embedMode?: boolean;
  41449. /**
  41450. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41451. */
  41452. handleResize?: boolean;
  41453. /**
  41454. * Allow the panes to popup (default: true)
  41455. */
  41456. enablePopup?: boolean;
  41457. /**
  41458. * Allow the panes to be closed by users (default: true)
  41459. */
  41460. enableClose?: boolean;
  41461. /**
  41462. * Optional list of extensibility entries
  41463. */
  41464. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41465. /**
  41466. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41467. */
  41468. inspectorURL?: string;
  41469. }
  41470. module "babylonjs/scene" {
  41471. interface Scene {
  41472. /**
  41473. * @hidden
  41474. * Backing field
  41475. */
  41476. _debugLayer: DebugLayer;
  41477. /**
  41478. * Gets the debug layer (aka Inspector) associated with the scene
  41479. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41480. */
  41481. debugLayer: DebugLayer;
  41482. }
  41483. }
  41484. /**
  41485. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41486. * what is happening in your scene
  41487. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41488. */
  41489. export class DebugLayer {
  41490. /**
  41491. * Define the url to get the inspector script from.
  41492. * By default it uses the babylonjs CDN.
  41493. * @ignoreNaming
  41494. */
  41495. static InspectorURL: string;
  41496. private _scene;
  41497. private BJSINSPECTOR;
  41498. /**
  41499. * Observable triggered when a property is changed through the inspector.
  41500. */
  41501. onPropertyChangedObservable: Observable<{
  41502. object: any;
  41503. property: string;
  41504. value: any;
  41505. initialValue: any;
  41506. }>;
  41507. /**
  41508. * Instantiates a new debug layer.
  41509. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41510. * what is happening in your scene
  41511. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41512. * @param scene Defines the scene to inspect
  41513. */
  41514. constructor(scene: Scene);
  41515. /** Creates the inspector window. */
  41516. private _createInspector;
  41517. /**
  41518. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41519. * @param entity defines the entity to select
  41520. * @param lineContainerTitle defines the specific block to highlight
  41521. */
  41522. select(entity: any, lineContainerTitle?: string): void;
  41523. /** Get the inspector from bundle or global */
  41524. private _getGlobalInspector;
  41525. /**
  41526. * Get if the inspector is visible or not.
  41527. * @returns true if visible otherwise, false
  41528. */
  41529. isVisible(): boolean;
  41530. /**
  41531. * Hide the inspector and close its window.
  41532. */
  41533. hide(): void;
  41534. /**
  41535. * Launch the debugLayer.
  41536. * @param config Define the configuration of the inspector
  41537. * @return a promise fulfilled when the debug layer is visible
  41538. */
  41539. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41540. }
  41541. }
  41542. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41543. import { Nullable } from "babylonjs/types";
  41544. import { Scene } from "babylonjs/scene";
  41545. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41546. import { Mesh } from "babylonjs/Meshes/mesh";
  41547. /**
  41548. * Class containing static functions to help procedurally build meshes
  41549. */
  41550. export class BoxBuilder {
  41551. /**
  41552. * Creates a box mesh
  41553. * * The parameter `size` sets the size (float) of each box side (default 1)
  41554. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41555. * * 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)
  41556. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41560. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41561. * @param name defines the name of the mesh
  41562. * @param options defines the options used to create the mesh
  41563. * @param scene defines the hosting scene
  41564. * @returns the box mesh
  41565. */
  41566. static CreateBox(name: string, options: {
  41567. size?: number;
  41568. width?: number;
  41569. height?: number;
  41570. depth?: number;
  41571. faceUV?: Vector4[];
  41572. faceColors?: Color4[];
  41573. sideOrientation?: number;
  41574. frontUVs?: Vector4;
  41575. backUVs?: Vector4;
  41576. updatable?: boolean;
  41577. }, scene?: Nullable<Scene>): Mesh;
  41578. }
  41579. }
  41580. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41581. import { Vector4 } from "babylonjs/Maths/math";
  41582. import { Mesh } from "babylonjs/Meshes/mesh";
  41583. /**
  41584. * Class containing static functions to help procedurally build meshes
  41585. */
  41586. export class SphereBuilder {
  41587. /**
  41588. * Creates a sphere mesh
  41589. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41590. * * 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`)
  41591. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41592. * * 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
  41593. * * 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)
  41594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41597. * @param name defines the name of the mesh
  41598. * @param options defines the options used to create the mesh
  41599. * @param scene defines the hosting scene
  41600. * @returns the sphere mesh
  41601. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41602. */
  41603. static CreateSphere(name: string, options: {
  41604. segments?: number;
  41605. diameter?: number;
  41606. diameterX?: number;
  41607. diameterY?: number;
  41608. diameterZ?: number;
  41609. arc?: number;
  41610. slice?: number;
  41611. sideOrientation?: number;
  41612. frontUVs?: Vector4;
  41613. backUVs?: Vector4;
  41614. updatable?: boolean;
  41615. }, scene: any): Mesh;
  41616. }
  41617. }
  41618. declare module "babylonjs/Debug/physicsViewer" {
  41619. import { Nullable } from "babylonjs/types";
  41620. import { Scene } from "babylonjs/scene";
  41621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41622. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41623. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41624. /**
  41625. * Used to show the physics impostor around the specific mesh
  41626. */
  41627. export class PhysicsViewer {
  41628. /** @hidden */
  41629. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41630. /** @hidden */
  41631. protected _meshes: Array<Nullable<AbstractMesh>>;
  41632. /** @hidden */
  41633. protected _scene: Nullable<Scene>;
  41634. /** @hidden */
  41635. protected _numMeshes: number;
  41636. /** @hidden */
  41637. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41638. private _renderFunction;
  41639. private _utilityLayer;
  41640. private _debugBoxMesh;
  41641. private _debugSphereMesh;
  41642. private _debugMaterial;
  41643. /**
  41644. * Creates a new PhysicsViewer
  41645. * @param scene defines the hosting scene
  41646. */
  41647. constructor(scene: Scene);
  41648. /** @hidden */
  41649. protected _updateDebugMeshes(): void;
  41650. /**
  41651. * Renders a specified physic impostor
  41652. * @param impostor defines the impostor to render
  41653. * @returns the new debug mesh used to render the impostor
  41654. */
  41655. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41656. /**
  41657. * Hides a specified physic impostor
  41658. * @param impostor defines the impostor to hide
  41659. */
  41660. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41661. private _getDebugMaterial;
  41662. private _getDebugBoxMesh;
  41663. private _getDebugSphereMesh;
  41664. private _getDebugMesh;
  41665. /** Releases all resources */
  41666. dispose(): void;
  41667. }
  41668. }
  41669. declare module "babylonjs/Debug/rayHelper" {
  41670. import { Nullable } from "babylonjs/types";
  41671. import { Ray } from "babylonjs/Culling/ray";
  41672. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41673. import { Scene } from "babylonjs/scene";
  41674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41675. import "babylonjs/Meshes/Builders/linesBuilder";
  41676. /**
  41677. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41678. * in order to better appreciate the issue one might have.
  41679. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41680. */
  41681. export class RayHelper {
  41682. /**
  41683. * Defines the ray we are currently tryin to visualize.
  41684. */
  41685. ray: Nullable<Ray>;
  41686. private _renderPoints;
  41687. private _renderLine;
  41688. private _renderFunction;
  41689. private _scene;
  41690. private _updateToMeshFunction;
  41691. private _attachedToMesh;
  41692. private _meshSpaceDirection;
  41693. private _meshSpaceOrigin;
  41694. /**
  41695. * Helper function to create a colored helper in a scene in one line.
  41696. * @param ray Defines the ray we are currently tryin to visualize
  41697. * @param scene Defines the scene the ray is used in
  41698. * @param color Defines the color we want to see the ray in
  41699. * @returns The newly created ray helper.
  41700. */
  41701. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41702. /**
  41703. * Instantiate a new ray helper.
  41704. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41705. * in order to better appreciate the issue one might have.
  41706. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41707. * @param ray Defines the ray we are currently tryin to visualize
  41708. */
  41709. constructor(ray: Ray);
  41710. /**
  41711. * Shows the ray we are willing to debug.
  41712. * @param scene Defines the scene the ray needs to be rendered in
  41713. * @param color Defines the color the ray needs to be rendered in
  41714. */
  41715. show(scene: Scene, color?: Color3): void;
  41716. /**
  41717. * Hides the ray we are debugging.
  41718. */
  41719. hide(): void;
  41720. private _render;
  41721. /**
  41722. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41723. * @param mesh Defines the mesh we want the helper attached to
  41724. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41725. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41726. * @param length Defines the length of the ray
  41727. */
  41728. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41729. /**
  41730. * Detach the ray helper from the mesh it has previously been attached to.
  41731. */
  41732. detachFromMesh(): void;
  41733. private _updateToMesh;
  41734. /**
  41735. * Dispose the helper and release its associated resources.
  41736. */
  41737. dispose(): void;
  41738. }
  41739. }
  41740. declare module "babylonjs/Debug/skeletonViewer" {
  41741. import { Color3 } from "babylonjs/Maths/math";
  41742. import { Scene } from "babylonjs/scene";
  41743. import { Nullable } from "babylonjs/types";
  41744. import { Skeleton } from "babylonjs/Bones/skeleton";
  41745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41746. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41747. /**
  41748. * Class used to render a debug view of a given skeleton
  41749. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41750. */
  41751. export class SkeletonViewer {
  41752. /** defines the skeleton to render */
  41753. skeleton: Skeleton;
  41754. /** defines the mesh attached to the skeleton */
  41755. mesh: AbstractMesh;
  41756. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41757. autoUpdateBonesMatrices: boolean;
  41758. /** defines the rendering group id to use with the viewer */
  41759. renderingGroupId: number;
  41760. /** Gets or sets the color used to render the skeleton */
  41761. color: Color3;
  41762. private _scene;
  41763. private _debugLines;
  41764. private _debugMesh;
  41765. private _isEnabled;
  41766. private _renderFunction;
  41767. private _utilityLayer;
  41768. /**
  41769. * Returns the mesh used to render the bones
  41770. */
  41771. readonly debugMesh: Nullable<LinesMesh>;
  41772. /**
  41773. * Creates a new SkeletonViewer
  41774. * @param skeleton defines the skeleton to render
  41775. * @param mesh defines the mesh attached to the skeleton
  41776. * @param scene defines the hosting scene
  41777. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41778. * @param renderingGroupId defines the rendering group id to use with the viewer
  41779. */
  41780. constructor(
  41781. /** defines the skeleton to render */
  41782. skeleton: Skeleton,
  41783. /** defines the mesh attached to the skeleton */
  41784. mesh: AbstractMesh, scene: Scene,
  41785. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41786. autoUpdateBonesMatrices?: boolean,
  41787. /** defines the rendering group id to use with the viewer */
  41788. renderingGroupId?: number);
  41789. /** Gets or sets a boolean indicating if the viewer is enabled */
  41790. isEnabled: boolean;
  41791. private _getBonePosition;
  41792. private _getLinesForBonesWithLength;
  41793. private _getLinesForBonesNoLength;
  41794. /** Update the viewer to sync with current skeleton state */
  41795. update(): void;
  41796. /** Release associated resources */
  41797. dispose(): void;
  41798. }
  41799. }
  41800. declare module "babylonjs/Debug/index" {
  41801. export * from "babylonjs/Debug/axesViewer";
  41802. export * from "babylonjs/Debug/boneAxesViewer";
  41803. export * from "babylonjs/Debug/debugLayer";
  41804. export * from "babylonjs/Debug/physicsViewer";
  41805. export * from "babylonjs/Debug/rayHelper";
  41806. export * from "babylonjs/Debug/skeletonViewer";
  41807. }
  41808. declare module "babylonjs/Engines/nullEngine" {
  41809. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41810. import { Scene } from "babylonjs/scene";
  41811. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41812. import { Engine } from "babylonjs/Engines/engine";
  41813. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41814. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41815. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41816. import { Effect } from "babylonjs/Materials/effect";
  41817. /**
  41818. * Options to create the null engine
  41819. */
  41820. export class NullEngineOptions {
  41821. /**
  41822. * Render width (Default: 512)
  41823. */
  41824. renderWidth: number;
  41825. /**
  41826. * Render height (Default: 256)
  41827. */
  41828. renderHeight: number;
  41829. /**
  41830. * Texture size (Default: 512)
  41831. */
  41832. textureSize: number;
  41833. /**
  41834. * If delta time between frames should be constant
  41835. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41836. */
  41837. deterministicLockstep: boolean;
  41838. /**
  41839. * Maximum about of steps between frames (Default: 4)
  41840. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41841. */
  41842. lockstepMaxSteps: number;
  41843. }
  41844. /**
  41845. * The null engine class provides support for headless version of babylon.js.
  41846. * This can be used in server side scenario or for testing purposes
  41847. */
  41848. export class NullEngine extends Engine {
  41849. private _options;
  41850. /**
  41851. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41852. */
  41853. isDeterministicLockStep(): boolean;
  41854. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41855. getLockstepMaxSteps(): number;
  41856. /**
  41857. * Sets hardware scaling, used to save performance if needed
  41858. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41859. */
  41860. getHardwareScalingLevel(): number;
  41861. constructor(options?: NullEngineOptions);
  41862. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41863. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41864. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41865. getRenderWidth(useScreen?: boolean): number;
  41866. getRenderHeight(useScreen?: boolean): number;
  41867. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41868. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41869. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41870. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41871. bindSamplers(effect: Effect): void;
  41872. enableEffect(effect: Effect): void;
  41873. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41874. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41875. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41876. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41877. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41878. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41879. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41880. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41881. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41882. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41883. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41884. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41885. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41886. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41887. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41888. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41889. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41890. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41891. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41892. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41893. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41894. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41895. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41896. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41897. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41898. bindBuffers(vertexBuffers: {
  41899. [key: string]: VertexBuffer;
  41900. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41901. wipeCaches(bruteForce?: boolean): void;
  41902. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41903. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41904. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41905. /** @hidden */
  41906. _createTexture(): WebGLTexture;
  41907. /** @hidden */
  41908. _releaseTexture(texture: InternalTexture): void;
  41909. 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;
  41910. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41911. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41912. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41913. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41914. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41915. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41916. areAllEffectsReady(): boolean;
  41917. /**
  41918. * @hidden
  41919. * Get the current error code of the webGL context
  41920. * @returns the error code
  41921. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41922. */
  41923. getError(): number;
  41924. /** @hidden */
  41925. _getUnpackAlignement(): number;
  41926. /** @hidden */
  41927. _unpackFlipY(value: boolean): void;
  41928. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41929. /**
  41930. * Updates a dynamic vertex buffer.
  41931. * @param vertexBuffer the vertex buffer to update
  41932. * @param data the data used to update the vertex buffer
  41933. * @param byteOffset the byte offset of the data (optional)
  41934. * @param byteLength the byte length of the data (optional)
  41935. */
  41936. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41937. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41938. /** @hidden */
  41939. _bindTexture(channel: number, texture: InternalTexture): void;
  41940. /** @hidden */
  41941. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41942. releaseEffects(): void;
  41943. displayLoadingUI(): void;
  41944. hideLoadingUI(): void;
  41945. /** @hidden */
  41946. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41947. /** @hidden */
  41948. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41949. /** @hidden */
  41950. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41951. /** @hidden */
  41952. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41953. }
  41954. }
  41955. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41956. import { Nullable, int } from "babylonjs/types";
  41957. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41958. /** @hidden */
  41959. export class _OcclusionDataStorage {
  41960. /** @hidden */
  41961. occlusionInternalRetryCounter: number;
  41962. /** @hidden */
  41963. isOcclusionQueryInProgress: boolean;
  41964. /** @hidden */
  41965. isOccluded: boolean;
  41966. /** @hidden */
  41967. occlusionRetryCount: number;
  41968. /** @hidden */
  41969. occlusionType: number;
  41970. /** @hidden */
  41971. occlusionQueryAlgorithmType: number;
  41972. }
  41973. module "babylonjs/Engines/engine" {
  41974. interface Engine {
  41975. /**
  41976. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41977. * @return the new query
  41978. */
  41979. createQuery(): WebGLQuery;
  41980. /**
  41981. * Delete and release a webGL query
  41982. * @param query defines the query to delete
  41983. * @return the current engine
  41984. */
  41985. deleteQuery(query: WebGLQuery): Engine;
  41986. /**
  41987. * Check if a given query has resolved and got its value
  41988. * @param query defines the query to check
  41989. * @returns true if the query got its value
  41990. */
  41991. isQueryResultAvailable(query: WebGLQuery): boolean;
  41992. /**
  41993. * Gets the value of a given query
  41994. * @param query defines the query to check
  41995. * @returns the value of the query
  41996. */
  41997. getQueryResult(query: WebGLQuery): number;
  41998. /**
  41999. * Initiates an occlusion query
  42000. * @param algorithmType defines the algorithm to use
  42001. * @param query defines the query to use
  42002. * @returns the current engine
  42003. * @see http://doc.babylonjs.com/features/occlusionquery
  42004. */
  42005. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42006. /**
  42007. * Ends an occlusion query
  42008. * @see http://doc.babylonjs.com/features/occlusionquery
  42009. * @param algorithmType defines the algorithm to use
  42010. * @returns the current engine
  42011. */
  42012. endOcclusionQuery(algorithmType: number): Engine;
  42013. /**
  42014. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42015. * Please note that only one query can be issued at a time
  42016. * @returns a time token used to track the time span
  42017. */
  42018. startTimeQuery(): Nullable<_TimeToken>;
  42019. /**
  42020. * Ends a time query
  42021. * @param token defines the token used to measure the time span
  42022. * @returns the time spent (in ns)
  42023. */
  42024. endTimeQuery(token: _TimeToken): int;
  42025. /** @hidden */
  42026. _currentNonTimestampToken: Nullable<_TimeToken>;
  42027. /** @hidden */
  42028. _createTimeQuery(): WebGLQuery;
  42029. /** @hidden */
  42030. _deleteTimeQuery(query: WebGLQuery): void;
  42031. /** @hidden */
  42032. _getGlAlgorithmType(algorithmType: number): number;
  42033. /** @hidden */
  42034. _getTimeQueryResult(query: WebGLQuery): any;
  42035. /** @hidden */
  42036. _getTimeQueryAvailability(query: WebGLQuery): any;
  42037. }
  42038. }
  42039. module "babylonjs/Meshes/abstractMesh" {
  42040. interface AbstractMesh {
  42041. /**
  42042. * Backing filed
  42043. * @hidden
  42044. */
  42045. __occlusionDataStorage: _OcclusionDataStorage;
  42046. /**
  42047. * Access property
  42048. * @hidden
  42049. */
  42050. _occlusionDataStorage: _OcclusionDataStorage;
  42051. /**
  42052. * 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.
  42053. * The default value is -1 which means don't break the query and wait till the result
  42054. * @see http://doc.babylonjs.com/features/occlusionquery
  42055. */
  42056. occlusionRetryCount: number;
  42057. /**
  42058. * 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:
  42059. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42060. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42061. * * 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.
  42062. * @see http://doc.babylonjs.com/features/occlusionquery
  42063. */
  42064. occlusionType: number;
  42065. /**
  42066. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42067. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42068. * * 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.
  42069. * @see http://doc.babylonjs.com/features/occlusionquery
  42070. */
  42071. occlusionQueryAlgorithmType: number;
  42072. /**
  42073. * 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
  42074. * @see http://doc.babylonjs.com/features/occlusionquery
  42075. */
  42076. isOccluded: boolean;
  42077. /**
  42078. * Flag to check the progress status of the query
  42079. * @see http://doc.babylonjs.com/features/occlusionquery
  42080. */
  42081. isOcclusionQueryInProgress: boolean;
  42082. }
  42083. }
  42084. }
  42085. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42086. import { Nullable } from "babylonjs/types";
  42087. /** @hidden */
  42088. export var _forceTransformFeedbackToBundle: boolean;
  42089. module "babylonjs/Engines/engine" {
  42090. interface Engine {
  42091. /**
  42092. * Creates a webGL transform feedback object
  42093. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42094. * @returns the webGL transform feedback object
  42095. */
  42096. createTransformFeedback(): WebGLTransformFeedback;
  42097. /**
  42098. * Delete a webGL transform feedback object
  42099. * @param value defines the webGL transform feedback object to delete
  42100. */
  42101. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42102. /**
  42103. * Bind a webGL transform feedback object to the webgl context
  42104. * @param value defines the webGL transform feedback object to bind
  42105. */
  42106. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42107. /**
  42108. * Begins a transform feedback operation
  42109. * @param usePoints defines if points or triangles must be used
  42110. */
  42111. beginTransformFeedback(usePoints: boolean): void;
  42112. /**
  42113. * Ends a transform feedback operation
  42114. */
  42115. endTransformFeedback(): void;
  42116. /**
  42117. * Specify the varyings to use with transform feedback
  42118. * @param program defines the associated webGL program
  42119. * @param value defines the list of strings representing the varying names
  42120. */
  42121. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42122. /**
  42123. * Bind a webGL buffer for a transform feedback operation
  42124. * @param value defines the webGL buffer to bind
  42125. */
  42126. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42127. }
  42128. }
  42129. }
  42130. declare module "babylonjs/Engines/Extensions/index" {
  42131. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42132. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42133. }
  42134. declare module "babylonjs/Engines/index" {
  42135. export * from "babylonjs/Engines/constants";
  42136. export * from "babylonjs/Engines/engine";
  42137. export * from "babylonjs/Engines/engineStore";
  42138. export * from "babylonjs/Engines/nullEngine";
  42139. export * from "babylonjs/Engines/Extensions/index";
  42140. }
  42141. declare module "babylonjs/Events/clipboardEvents" {
  42142. /**
  42143. * Gather the list of clipboard event types as constants.
  42144. */
  42145. export class ClipboardEventTypes {
  42146. /**
  42147. * The clipboard event is fired when a copy command is active (pressed).
  42148. */
  42149. static readonly COPY: number;
  42150. /**
  42151. * The clipboard event is fired when a cut command is active (pressed).
  42152. */
  42153. static readonly CUT: number;
  42154. /**
  42155. * The clipboard event is fired when a paste command is active (pressed).
  42156. */
  42157. static readonly PASTE: number;
  42158. }
  42159. /**
  42160. * This class is used to store clipboard related info for the onClipboardObservable event.
  42161. */
  42162. export class ClipboardInfo {
  42163. /**
  42164. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42165. */
  42166. type: number;
  42167. /**
  42168. * Defines the related dom event
  42169. */
  42170. event: ClipboardEvent;
  42171. /**
  42172. *Creates an instance of ClipboardInfo.
  42173. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42174. * @param event Defines the related dom event
  42175. */
  42176. constructor(
  42177. /**
  42178. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42179. */
  42180. type: number,
  42181. /**
  42182. * Defines the related dom event
  42183. */
  42184. event: ClipboardEvent);
  42185. /**
  42186. * Get the clipboard event's type from the keycode.
  42187. * @param keyCode Defines the keyCode for the current keyboard event.
  42188. * @return {number}
  42189. */
  42190. static GetTypeFromCharacter(keyCode: number): number;
  42191. }
  42192. }
  42193. declare module "babylonjs/Events/index" {
  42194. export * from "babylonjs/Events/keyboardEvents";
  42195. export * from "babylonjs/Events/pointerEvents";
  42196. export * from "babylonjs/Events/clipboardEvents";
  42197. }
  42198. declare module "babylonjs/Loading/sceneLoader" {
  42199. import { Observable } from "babylonjs/Misc/observable";
  42200. import { Nullable } from "babylonjs/types";
  42201. import { Scene } from "babylonjs/scene";
  42202. import { Engine } from "babylonjs/Engines/engine";
  42203. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42204. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42205. import { AssetContainer } from "babylonjs/assetContainer";
  42206. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42207. import { Skeleton } from "babylonjs/Bones/skeleton";
  42208. /**
  42209. * Class used to represent data loading progression
  42210. */
  42211. export class SceneLoaderProgressEvent {
  42212. /** defines if data length to load can be evaluated */
  42213. readonly lengthComputable: boolean;
  42214. /** defines the loaded data length */
  42215. readonly loaded: number;
  42216. /** defines the data length to load */
  42217. readonly total: number;
  42218. /**
  42219. * Create a new progress event
  42220. * @param lengthComputable defines if data length to load can be evaluated
  42221. * @param loaded defines the loaded data length
  42222. * @param total defines the data length to load
  42223. */
  42224. constructor(
  42225. /** defines if data length to load can be evaluated */
  42226. lengthComputable: boolean,
  42227. /** defines the loaded data length */
  42228. loaded: number,
  42229. /** defines the data length to load */
  42230. total: number);
  42231. /**
  42232. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42233. * @param event defines the source event
  42234. * @returns a new SceneLoaderProgressEvent
  42235. */
  42236. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42237. }
  42238. /**
  42239. * Interface used by SceneLoader plugins to define supported file extensions
  42240. */
  42241. export interface ISceneLoaderPluginExtensions {
  42242. /**
  42243. * Defines the list of supported extensions
  42244. */
  42245. [extension: string]: {
  42246. isBinary: boolean;
  42247. };
  42248. }
  42249. /**
  42250. * Interface used by SceneLoader plugin factory
  42251. */
  42252. export interface ISceneLoaderPluginFactory {
  42253. /**
  42254. * Defines the name of the factory
  42255. */
  42256. name: string;
  42257. /**
  42258. * Function called to create a new plugin
  42259. * @return the new plugin
  42260. */
  42261. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42262. /**
  42263. * Boolean indicating if the plugin can direct load specific data
  42264. */
  42265. canDirectLoad?: (data: string) => boolean;
  42266. }
  42267. /**
  42268. * Interface used to define a SceneLoader plugin
  42269. */
  42270. export interface ISceneLoaderPlugin {
  42271. /**
  42272. * The friendly name of this plugin.
  42273. */
  42274. name: string;
  42275. /**
  42276. * The file extensions supported by this plugin.
  42277. */
  42278. extensions: string | ISceneLoaderPluginExtensions;
  42279. /**
  42280. * Import meshes into a scene.
  42281. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42282. * @param scene The scene to import into
  42283. * @param data The data to import
  42284. * @param rootUrl The root url for scene and resources
  42285. * @param meshes The meshes array to import into
  42286. * @param particleSystems The particle systems array to import into
  42287. * @param skeletons The skeletons array to import into
  42288. * @param onError The callback when import fails
  42289. * @returns True if successful or false otherwise
  42290. */
  42291. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42292. /**
  42293. * Load into a scene.
  42294. * @param scene The scene to load into
  42295. * @param data The data to import
  42296. * @param rootUrl The root url for scene and resources
  42297. * @param onError The callback when import fails
  42298. * @returns true if successful or false otherwise
  42299. */
  42300. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42301. /**
  42302. * The callback that returns true if the data can be directly loaded.
  42303. */
  42304. canDirectLoad?: (data: string) => boolean;
  42305. /**
  42306. * The callback that allows custom handling of the root url based on the response url.
  42307. */
  42308. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42309. /**
  42310. * Load into an asset container.
  42311. * @param scene The scene to load into
  42312. * @param data The data to import
  42313. * @param rootUrl The root url for scene and resources
  42314. * @param onError The callback when import fails
  42315. * @returns The loaded asset container
  42316. */
  42317. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42318. }
  42319. /**
  42320. * Interface used to define an async SceneLoader plugin
  42321. */
  42322. export interface ISceneLoaderPluginAsync {
  42323. /**
  42324. * The friendly name of this plugin.
  42325. */
  42326. name: string;
  42327. /**
  42328. * The file extensions supported by this plugin.
  42329. */
  42330. extensions: string | ISceneLoaderPluginExtensions;
  42331. /**
  42332. * Import meshes into a scene.
  42333. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42334. * @param scene The scene to import into
  42335. * @param data The data to import
  42336. * @param rootUrl The root url for scene and resources
  42337. * @param onProgress The callback when the load progresses
  42338. * @param fileName Defines the name of the file to load
  42339. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42340. */
  42341. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42342. meshes: AbstractMesh[];
  42343. particleSystems: IParticleSystem[];
  42344. skeletons: Skeleton[];
  42345. animationGroups: AnimationGroup[];
  42346. }>;
  42347. /**
  42348. * Load into a scene.
  42349. * @param scene The scene to load into
  42350. * @param data The data to import
  42351. * @param rootUrl The root url for scene and resources
  42352. * @param onProgress The callback when the load progresses
  42353. * @param fileName Defines the name of the file to load
  42354. * @returns Nothing
  42355. */
  42356. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42357. /**
  42358. * The callback that returns true if the data can be directly loaded.
  42359. */
  42360. canDirectLoad?: (data: string) => boolean;
  42361. /**
  42362. * The callback that allows custom handling of the root url based on the response url.
  42363. */
  42364. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42365. /**
  42366. * Load into an asset container.
  42367. * @param scene The scene to load into
  42368. * @param data The data to import
  42369. * @param rootUrl The root url for scene and resources
  42370. * @param onProgress The callback when the load progresses
  42371. * @param fileName Defines the name of the file to load
  42372. * @returns The loaded asset container
  42373. */
  42374. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42375. }
  42376. /**
  42377. * Class used to load scene from various file formats using registered plugins
  42378. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42379. */
  42380. export class SceneLoader {
  42381. /**
  42382. * No logging while loading
  42383. */
  42384. static readonly NO_LOGGING: number;
  42385. /**
  42386. * Minimal logging while loading
  42387. */
  42388. static readonly MINIMAL_LOGGING: number;
  42389. /**
  42390. * Summary logging while loading
  42391. */
  42392. static readonly SUMMARY_LOGGING: number;
  42393. /**
  42394. * Detailled logging while loading
  42395. */
  42396. static readonly DETAILED_LOGGING: number;
  42397. /**
  42398. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42399. */
  42400. static ForceFullSceneLoadingForIncremental: boolean;
  42401. /**
  42402. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42403. */
  42404. static ShowLoadingScreen: boolean;
  42405. /**
  42406. * Defines the current logging level (while loading the scene)
  42407. * @ignorenaming
  42408. */
  42409. static loggingLevel: number;
  42410. /**
  42411. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42412. */
  42413. static CleanBoneMatrixWeights: boolean;
  42414. /**
  42415. * Event raised when a plugin is used to load a scene
  42416. */
  42417. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42418. private static _registeredPlugins;
  42419. private static _getDefaultPlugin;
  42420. private static _getPluginForExtension;
  42421. private static _getPluginForDirectLoad;
  42422. private static _getPluginForFilename;
  42423. private static _getDirectLoad;
  42424. private static _loadData;
  42425. private static _getFileInfo;
  42426. /**
  42427. * Gets a plugin that can load the given extension
  42428. * @param extension defines the extension to load
  42429. * @returns a plugin or null if none works
  42430. */
  42431. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42432. /**
  42433. * Gets a boolean indicating that the given extension can be loaded
  42434. * @param extension defines the extension to load
  42435. * @returns true if the extension is supported
  42436. */
  42437. static IsPluginForExtensionAvailable(extension: string): boolean;
  42438. /**
  42439. * Adds a new plugin to the list of registered plugins
  42440. * @param plugin defines the plugin to add
  42441. */
  42442. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42443. /**
  42444. * Import meshes into a scene
  42445. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42446. * @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)
  42447. * @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)
  42448. * @param scene the instance of BABYLON.Scene to append to
  42449. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42450. * @param onProgress a callback with a progress event for each file being loaded
  42451. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42452. * @param pluginExtension the extension used to determine the plugin
  42453. * @returns The loaded plugin
  42454. */
  42455. 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>;
  42456. /**
  42457. * Import meshes into a scene
  42458. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42459. * @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)
  42460. * @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)
  42461. * @param scene the instance of BABYLON.Scene to append to
  42462. * @param onProgress a callback with a progress event for each file being loaded
  42463. * @param pluginExtension the extension used to determine the plugin
  42464. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42465. */
  42466. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42467. meshes: AbstractMesh[];
  42468. particleSystems: IParticleSystem[];
  42469. skeletons: Skeleton[];
  42470. animationGroups: AnimationGroup[];
  42471. }>;
  42472. /**
  42473. * Load a scene
  42474. * @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)
  42475. * @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)
  42476. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42477. * @param onSuccess a callback with the scene when import succeeds
  42478. * @param onProgress a callback with a progress event for each file being loaded
  42479. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42480. * @param pluginExtension the extension used to determine the plugin
  42481. * @returns The loaded plugin
  42482. */
  42483. 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>;
  42484. /**
  42485. * Load a scene
  42486. * @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)
  42487. * @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)
  42488. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42489. * @param onProgress a callback with a progress event for each file being loaded
  42490. * @param pluginExtension the extension used to determine the plugin
  42491. * @returns The loaded scene
  42492. */
  42493. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42494. /**
  42495. * Append a scene
  42496. * @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)
  42497. * @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)
  42498. * @param scene is the instance of BABYLON.Scene to append to
  42499. * @param onSuccess a callback with the scene when import succeeds
  42500. * @param onProgress a callback with a progress event for each file being loaded
  42501. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42502. * @param pluginExtension the extension used to determine the plugin
  42503. * @returns The loaded plugin
  42504. */
  42505. 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>;
  42506. /**
  42507. * Append a scene
  42508. * @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)
  42509. * @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)
  42510. * @param scene is the instance of BABYLON.Scene to append to
  42511. * @param onProgress a callback with a progress event for each file being loaded
  42512. * @param pluginExtension the extension used to determine the plugin
  42513. * @returns The given scene
  42514. */
  42515. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42516. /**
  42517. * Load a scene into an asset container
  42518. * @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)
  42519. * @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)
  42520. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42521. * @param onSuccess a callback with the scene when import succeeds
  42522. * @param onProgress a callback with a progress event for each file being loaded
  42523. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42524. * @param pluginExtension the extension used to determine the plugin
  42525. * @returns The loaded plugin
  42526. */
  42527. 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>;
  42528. /**
  42529. * Load a scene into an asset container
  42530. * @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)
  42531. * @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)
  42532. * @param scene is the instance of Scene to append to
  42533. * @param onProgress a callback with a progress event for each file being loaded
  42534. * @param pluginExtension the extension used to determine the plugin
  42535. * @returns The loaded asset container
  42536. */
  42537. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42538. }
  42539. }
  42540. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42541. import { Scene } from "babylonjs/scene";
  42542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42543. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42544. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42545. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42546. /**
  42547. * Google Daydream controller
  42548. */
  42549. export class DaydreamController extends WebVRController {
  42550. /**
  42551. * Base Url for the controller model.
  42552. */
  42553. static MODEL_BASE_URL: string;
  42554. /**
  42555. * File name for the controller model.
  42556. */
  42557. static MODEL_FILENAME: string;
  42558. /**
  42559. * Gamepad Id prefix used to identify Daydream Controller.
  42560. */
  42561. static readonly GAMEPAD_ID_PREFIX: string;
  42562. /**
  42563. * Creates a new DaydreamController from a gamepad
  42564. * @param vrGamepad the gamepad that the controller should be created from
  42565. */
  42566. constructor(vrGamepad: any);
  42567. /**
  42568. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42569. * @param scene scene in which to add meshes
  42570. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42571. */
  42572. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42573. /**
  42574. * Called once for each button that changed state since the last frame
  42575. * @param buttonIdx Which button index changed
  42576. * @param state New state of the button
  42577. * @param changes Which properties on the state changed since last frame
  42578. */
  42579. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42580. }
  42581. }
  42582. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42583. import { Scene } from "babylonjs/scene";
  42584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42585. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42586. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42587. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42588. /**
  42589. * Gear VR Controller
  42590. */
  42591. export class GearVRController extends WebVRController {
  42592. /**
  42593. * Base Url for the controller model.
  42594. */
  42595. static MODEL_BASE_URL: string;
  42596. /**
  42597. * File name for the controller model.
  42598. */
  42599. static MODEL_FILENAME: string;
  42600. /**
  42601. * Gamepad Id prefix used to identify this controller.
  42602. */
  42603. static readonly GAMEPAD_ID_PREFIX: string;
  42604. private readonly _buttonIndexToObservableNameMap;
  42605. /**
  42606. * Creates a new GearVRController from a gamepad
  42607. * @param vrGamepad the gamepad that the controller should be created from
  42608. */
  42609. constructor(vrGamepad: any);
  42610. /**
  42611. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42612. * @param scene scene in which to add meshes
  42613. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42614. */
  42615. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42616. /**
  42617. * Called once for each button that changed state since the last frame
  42618. * @param buttonIdx Which button index changed
  42619. * @param state New state of the button
  42620. * @param changes Which properties on the state changed since last frame
  42621. */
  42622. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42623. }
  42624. }
  42625. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42626. import { Scene } from "babylonjs/scene";
  42627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42628. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42629. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42630. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42631. /**
  42632. * Generic Controller
  42633. */
  42634. export class GenericController extends WebVRController {
  42635. /**
  42636. * Base Url for the controller model.
  42637. */
  42638. static readonly MODEL_BASE_URL: string;
  42639. /**
  42640. * File name for the controller model.
  42641. */
  42642. static readonly MODEL_FILENAME: string;
  42643. /**
  42644. * Creates a new GenericController from a gamepad
  42645. * @param vrGamepad the gamepad that the controller should be created from
  42646. */
  42647. constructor(vrGamepad: any);
  42648. /**
  42649. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42650. * @param scene scene in which to add meshes
  42651. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42652. */
  42653. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42654. /**
  42655. * Called once for each button that changed state since the last frame
  42656. * @param buttonIdx Which button index changed
  42657. * @param state New state of the button
  42658. * @param changes Which properties on the state changed since last frame
  42659. */
  42660. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42661. }
  42662. }
  42663. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42664. import { Observable } from "babylonjs/Misc/observable";
  42665. import { Scene } from "babylonjs/scene";
  42666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42667. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42668. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42669. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42670. /**
  42671. * Oculus Touch Controller
  42672. */
  42673. export class OculusTouchController extends WebVRController {
  42674. /**
  42675. * Base Url for the controller model.
  42676. */
  42677. static MODEL_BASE_URL: string;
  42678. /**
  42679. * File name for the left controller model.
  42680. */
  42681. static MODEL_LEFT_FILENAME: string;
  42682. /**
  42683. * File name for the right controller model.
  42684. */
  42685. static MODEL_RIGHT_FILENAME: string;
  42686. /**
  42687. * Fired when the secondary trigger on this controller is modified
  42688. */
  42689. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42690. /**
  42691. * Fired when the thumb rest on this controller is modified
  42692. */
  42693. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42694. /**
  42695. * Creates a new OculusTouchController from a gamepad
  42696. * @param vrGamepad the gamepad that the controller should be created from
  42697. */
  42698. constructor(vrGamepad: any);
  42699. /**
  42700. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42701. * @param scene scene in which to add meshes
  42702. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42703. */
  42704. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42705. /**
  42706. * Fired when the A button on this controller is modified
  42707. */
  42708. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42709. /**
  42710. * Fired when the B button on this controller is modified
  42711. */
  42712. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42713. /**
  42714. * Fired when the X button on this controller is modified
  42715. */
  42716. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42717. /**
  42718. * Fired when the Y button on this controller is modified
  42719. */
  42720. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42721. /**
  42722. * Called once for each button that changed state since the last frame
  42723. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42724. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42725. * 2) secondary trigger (same)
  42726. * 3) A (right) X (left), touch, pressed = value
  42727. * 4) B / Y
  42728. * 5) thumb rest
  42729. * @param buttonIdx Which button index changed
  42730. * @param state New state of the button
  42731. * @param changes Which properties on the state changed since last frame
  42732. */
  42733. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42734. }
  42735. }
  42736. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42737. import { Scene } from "babylonjs/scene";
  42738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42739. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42740. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42741. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42742. import { Observable } from "babylonjs/Misc/observable";
  42743. /**
  42744. * Vive Controller
  42745. */
  42746. export class ViveController extends WebVRController {
  42747. /**
  42748. * Base Url for the controller model.
  42749. */
  42750. static MODEL_BASE_URL: string;
  42751. /**
  42752. * File name for the controller model.
  42753. */
  42754. static MODEL_FILENAME: string;
  42755. /**
  42756. * Creates a new ViveController from a gamepad
  42757. * @param vrGamepad the gamepad that the controller should be created from
  42758. */
  42759. constructor(vrGamepad: any);
  42760. /**
  42761. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42762. * @param scene scene in which to add meshes
  42763. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42764. */
  42765. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42766. /**
  42767. * Fired when the left button on this controller is modified
  42768. */
  42769. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42770. /**
  42771. * Fired when the right button on this controller is modified
  42772. */
  42773. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42774. /**
  42775. * Fired when the menu button on this controller is modified
  42776. */
  42777. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42778. /**
  42779. * Called once for each button that changed state since the last frame
  42780. * Vive mapping:
  42781. * 0: touchpad
  42782. * 1: trigger
  42783. * 2: left AND right buttons
  42784. * 3: menu button
  42785. * @param buttonIdx Which button index changed
  42786. * @param state New state of the button
  42787. * @param changes Which properties on the state changed since last frame
  42788. */
  42789. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42790. }
  42791. }
  42792. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42793. import { Observable } from "babylonjs/Misc/observable";
  42794. import { Scene } from "babylonjs/scene";
  42795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42796. import { Ray } from "babylonjs/Culling/ray";
  42797. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42798. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42799. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42800. /**
  42801. * Defines the WindowsMotionController object that the state of the windows motion controller
  42802. */
  42803. export class WindowsMotionController extends WebVRController {
  42804. /**
  42805. * The base url used to load the left and right controller models
  42806. */
  42807. static MODEL_BASE_URL: string;
  42808. /**
  42809. * The name of the left controller model file
  42810. */
  42811. static MODEL_LEFT_FILENAME: string;
  42812. /**
  42813. * The name of the right controller model file
  42814. */
  42815. static MODEL_RIGHT_FILENAME: string;
  42816. /**
  42817. * The controller name prefix for this controller type
  42818. */
  42819. static readonly GAMEPAD_ID_PREFIX: string;
  42820. /**
  42821. * The controller id pattern for this controller type
  42822. */
  42823. private static readonly GAMEPAD_ID_PATTERN;
  42824. private _loadedMeshInfo;
  42825. private readonly _mapping;
  42826. /**
  42827. * Fired when the trackpad on this controller is clicked
  42828. */
  42829. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42830. /**
  42831. * Fired when the trackpad on this controller is modified
  42832. */
  42833. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42834. /**
  42835. * The current x and y values of this controller's trackpad
  42836. */
  42837. trackpad: StickValues;
  42838. /**
  42839. * Creates a new WindowsMotionController from a gamepad
  42840. * @param vrGamepad the gamepad that the controller should be created from
  42841. */
  42842. constructor(vrGamepad: any);
  42843. /**
  42844. * Fired when the trigger on this controller is modified
  42845. */
  42846. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42847. /**
  42848. * Fired when the menu button on this controller is modified
  42849. */
  42850. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42851. /**
  42852. * Fired when the grip button on this controller is modified
  42853. */
  42854. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42855. /**
  42856. * Fired when the thumbstick button on this controller is modified
  42857. */
  42858. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42859. /**
  42860. * Fired when the touchpad button on this controller is modified
  42861. */
  42862. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42863. /**
  42864. * Fired when the touchpad values on this controller are modified
  42865. */
  42866. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42867. private _updateTrackpad;
  42868. /**
  42869. * Called once per frame by the engine.
  42870. */
  42871. update(): void;
  42872. /**
  42873. * Called once for each button that changed state since the last frame
  42874. * @param buttonIdx Which button index changed
  42875. * @param state New state of the button
  42876. * @param changes Which properties on the state changed since last frame
  42877. */
  42878. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42879. /**
  42880. * Moves the buttons on the controller mesh based on their current state
  42881. * @param buttonName the name of the button to move
  42882. * @param buttonValue the value of the button which determines the buttons new position
  42883. */
  42884. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42885. /**
  42886. * Moves the axis on the controller mesh based on its current state
  42887. * @param axis the index of the axis
  42888. * @param axisValue the value of the axis which determines the meshes new position
  42889. * @hidden
  42890. */
  42891. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42892. /**
  42893. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42894. * @param scene scene in which to add meshes
  42895. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42896. */
  42897. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42898. /**
  42899. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42900. * can be transformed by button presses and axes values, based on this._mapping.
  42901. *
  42902. * @param scene scene in which the meshes exist
  42903. * @param meshes list of meshes that make up the controller model to process
  42904. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42905. */
  42906. private processModel;
  42907. private createMeshInfo;
  42908. /**
  42909. * Gets the ray of the controller in the direction the controller is pointing
  42910. * @param length the length the resulting ray should be
  42911. * @returns a ray in the direction the controller is pointing
  42912. */
  42913. getForwardRay(length?: number): Ray;
  42914. /**
  42915. * Disposes of the controller
  42916. */
  42917. dispose(): void;
  42918. }
  42919. }
  42920. declare module "babylonjs/Gamepads/Controllers/index" {
  42921. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42922. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42923. export * from "babylonjs/Gamepads/Controllers/genericController";
  42924. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42925. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42926. export * from "babylonjs/Gamepads/Controllers/viveController";
  42927. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42928. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42929. }
  42930. declare module "babylonjs/Gamepads/index" {
  42931. export * from "babylonjs/Gamepads/Controllers/index";
  42932. export * from "babylonjs/Gamepads/gamepad";
  42933. export * from "babylonjs/Gamepads/gamepadManager";
  42934. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42935. export * from "babylonjs/Gamepads/xboxGamepad";
  42936. }
  42937. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42938. import { Observable } from "babylonjs/Misc/observable";
  42939. import { Nullable } from "babylonjs/types";
  42940. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42942. import { Mesh } from "babylonjs/Meshes/mesh";
  42943. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42944. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42945. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42946. /**
  42947. * Single axis scale gizmo
  42948. */
  42949. export class AxisScaleGizmo extends Gizmo {
  42950. private _coloredMaterial;
  42951. /**
  42952. * Drag behavior responsible for the gizmos dragging interactions
  42953. */
  42954. dragBehavior: PointerDragBehavior;
  42955. private _pointerObserver;
  42956. /**
  42957. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42958. */
  42959. snapDistance: number;
  42960. /**
  42961. * Event that fires each time the gizmo snaps to a new location.
  42962. * * snapDistance is the the change in distance
  42963. */
  42964. onSnapObservable: Observable<{
  42965. snapDistance: number;
  42966. }>;
  42967. /**
  42968. * If the scaling operation should be done on all axis (default: false)
  42969. */
  42970. uniformScaling: boolean;
  42971. /**
  42972. * Creates an AxisScaleGizmo
  42973. * @param gizmoLayer The utility layer the gizmo will be added to
  42974. * @param dragAxis The axis which the gizmo will be able to scale on
  42975. * @param color The color of the gizmo
  42976. */
  42977. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42978. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42979. /**
  42980. * Disposes of the gizmo
  42981. */
  42982. dispose(): void;
  42983. /**
  42984. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42985. * @param mesh The mesh to replace the default mesh of the gizmo
  42986. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42987. */
  42988. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42989. }
  42990. }
  42991. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42992. import { Observable } from "babylonjs/Misc/observable";
  42993. import { Nullable } from "babylonjs/types";
  42994. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42996. import { Mesh } from "babylonjs/Meshes/mesh";
  42997. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42998. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42999. import "babylonjs/Meshes/Builders/boxBuilder";
  43000. /**
  43001. * Bounding box gizmo
  43002. */
  43003. export class BoundingBoxGizmo extends Gizmo {
  43004. private _lineBoundingBox;
  43005. private _rotateSpheresParent;
  43006. private _scaleBoxesParent;
  43007. private _boundingDimensions;
  43008. private _renderObserver;
  43009. private _pointerObserver;
  43010. private _scaleDragSpeed;
  43011. private _tmpQuaternion;
  43012. private _tmpVector;
  43013. private _tmpRotationMatrix;
  43014. /**
  43015. * 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)
  43016. */
  43017. ignoreChildren: boolean;
  43018. /**
  43019. * 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)
  43020. */
  43021. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43022. /**
  43023. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43024. */
  43025. rotationSphereSize: number;
  43026. /**
  43027. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43028. */
  43029. scaleBoxSize: number;
  43030. /**
  43031. * 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)
  43032. */
  43033. fixedDragMeshScreenSize: boolean;
  43034. /**
  43035. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43036. */
  43037. fixedDragMeshScreenSizeDistanceFactor: number;
  43038. /**
  43039. * Fired when a rotation sphere or scale box is dragged
  43040. */
  43041. onDragStartObservable: Observable<{}>;
  43042. /**
  43043. * Fired when a scale box is dragged
  43044. */
  43045. onScaleBoxDragObservable: Observable<{}>;
  43046. /**
  43047. * Fired when a scale box drag is ended
  43048. */
  43049. onScaleBoxDragEndObservable: Observable<{}>;
  43050. /**
  43051. * Fired when a rotation sphere is dragged
  43052. */
  43053. onRotationSphereDragObservable: Observable<{}>;
  43054. /**
  43055. * Fired when a rotation sphere drag is ended
  43056. */
  43057. onRotationSphereDragEndObservable: Observable<{}>;
  43058. /**
  43059. * 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)
  43060. */
  43061. scalePivot: Nullable<Vector3>;
  43062. private _anchorMesh;
  43063. private _existingMeshScale;
  43064. private _dragMesh;
  43065. private pointerDragBehavior;
  43066. private coloredMaterial;
  43067. private hoverColoredMaterial;
  43068. /**
  43069. * Sets the color of the bounding box gizmo
  43070. * @param color the color to set
  43071. */
  43072. setColor(color: Color3): void;
  43073. /**
  43074. * Creates an BoundingBoxGizmo
  43075. * @param gizmoLayer The utility layer the gizmo will be added to
  43076. * @param color The color of the gizmo
  43077. */
  43078. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43079. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43080. private _selectNode;
  43081. /**
  43082. * Updates the bounding box information for the Gizmo
  43083. */
  43084. updateBoundingBox(): void;
  43085. private _updateRotationSpheres;
  43086. private _updateScaleBoxes;
  43087. /**
  43088. * Enables rotation on the specified axis and disables rotation on the others
  43089. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43090. */
  43091. setEnabledRotationAxis(axis: string): void;
  43092. /**
  43093. * Enables/disables scaling
  43094. * @param enable if scaling should be enabled
  43095. */
  43096. setEnabledScaling(enable: boolean): void;
  43097. private _updateDummy;
  43098. /**
  43099. * Enables a pointer drag behavior on the bounding box of the gizmo
  43100. */
  43101. enableDragBehavior(): void;
  43102. /**
  43103. * Disposes of the gizmo
  43104. */
  43105. dispose(): void;
  43106. /**
  43107. * 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)
  43108. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43109. * @returns the bounding box mesh with the passed in mesh as a child
  43110. */
  43111. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43112. /**
  43113. * CustomMeshes are not supported by this gizmo
  43114. * @param mesh The mesh to replace the default mesh of the gizmo
  43115. */
  43116. setCustomMesh(mesh: Mesh): void;
  43117. }
  43118. }
  43119. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43120. import { Observable } from "babylonjs/Misc/observable";
  43121. import { Nullable } from "babylonjs/types";
  43122. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43124. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43125. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43126. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43127. import "babylonjs/Meshes/Builders/linesBuilder";
  43128. /**
  43129. * Single plane rotation gizmo
  43130. */
  43131. export class PlaneRotationGizmo extends Gizmo {
  43132. /**
  43133. * Drag behavior responsible for the gizmos dragging interactions
  43134. */
  43135. dragBehavior: PointerDragBehavior;
  43136. private _pointerObserver;
  43137. /**
  43138. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43139. */
  43140. snapDistance: number;
  43141. /**
  43142. * Event that fires each time the gizmo snaps to a new location.
  43143. * * snapDistance is the the change in distance
  43144. */
  43145. onSnapObservable: Observable<{
  43146. snapDistance: number;
  43147. }>;
  43148. /**
  43149. * Creates a PlaneRotationGizmo
  43150. * @param gizmoLayer The utility layer the gizmo will be added to
  43151. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43152. * @param color The color of the gizmo
  43153. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43154. */
  43155. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43156. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43157. /**
  43158. * Disposes of the gizmo
  43159. */
  43160. dispose(): void;
  43161. }
  43162. }
  43163. declare module "babylonjs/Gizmos/rotationGizmo" {
  43164. import { Observable } from "babylonjs/Misc/observable";
  43165. import { Nullable } from "babylonjs/types";
  43166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43167. import { Mesh } from "babylonjs/Meshes/mesh";
  43168. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43169. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43170. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43171. /**
  43172. * Gizmo that enables rotating a mesh along 3 axis
  43173. */
  43174. export class RotationGizmo extends Gizmo {
  43175. /**
  43176. * Internal gizmo used for interactions on the x axis
  43177. */
  43178. xGizmo: PlaneRotationGizmo;
  43179. /**
  43180. * Internal gizmo used for interactions on the y axis
  43181. */
  43182. yGizmo: PlaneRotationGizmo;
  43183. /**
  43184. * Internal gizmo used for interactions on the z axis
  43185. */
  43186. zGizmo: PlaneRotationGizmo;
  43187. /** Fires an event when any of it's sub gizmos are dragged */
  43188. onDragStartObservable: Observable<{}>;
  43189. /** Fires an event when any of it's sub gizmos are released from dragging */
  43190. onDragEndObservable: Observable<{}>;
  43191. attachedMesh: Nullable<AbstractMesh>;
  43192. /**
  43193. * Creates a RotationGizmo
  43194. * @param gizmoLayer The utility layer the gizmo will be added to
  43195. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43196. */
  43197. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43198. updateGizmoRotationToMatchAttachedMesh: boolean;
  43199. /**
  43200. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43201. */
  43202. snapDistance: number;
  43203. /**
  43204. * Ratio for the scale of the gizmo (Default: 1)
  43205. */
  43206. scaleRatio: number;
  43207. /**
  43208. * Disposes of the gizmo
  43209. */
  43210. dispose(): void;
  43211. /**
  43212. * CustomMeshes are not supported by this gizmo
  43213. * @param mesh The mesh to replace the default mesh of the gizmo
  43214. */
  43215. setCustomMesh(mesh: Mesh): void;
  43216. }
  43217. }
  43218. declare module "babylonjs/Gizmos/positionGizmo" {
  43219. import { Observable } from "babylonjs/Misc/observable";
  43220. import { Nullable } from "babylonjs/types";
  43221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43222. import { Mesh } from "babylonjs/Meshes/mesh";
  43223. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43224. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43225. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43226. /**
  43227. * Gizmo that enables dragging a mesh along 3 axis
  43228. */
  43229. export class PositionGizmo extends Gizmo {
  43230. /**
  43231. * Internal gizmo used for interactions on the x axis
  43232. */
  43233. xGizmo: AxisDragGizmo;
  43234. /**
  43235. * Internal gizmo used for interactions on the y axis
  43236. */
  43237. yGizmo: AxisDragGizmo;
  43238. /**
  43239. * Internal gizmo used for interactions on the z axis
  43240. */
  43241. zGizmo: AxisDragGizmo;
  43242. /** Fires an event when any of it's sub gizmos are dragged */
  43243. onDragStartObservable: Observable<{}>;
  43244. /** Fires an event when any of it's sub gizmos are released from dragging */
  43245. onDragEndObservable: Observable<{}>;
  43246. attachedMesh: Nullable<AbstractMesh>;
  43247. /**
  43248. * Creates a PositionGizmo
  43249. * @param gizmoLayer The utility layer the gizmo will be added to
  43250. */
  43251. constructor(gizmoLayer?: UtilityLayerRenderer);
  43252. updateGizmoRotationToMatchAttachedMesh: boolean;
  43253. /**
  43254. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43255. */
  43256. snapDistance: number;
  43257. /**
  43258. * Ratio for the scale of the gizmo (Default: 1)
  43259. */
  43260. scaleRatio: number;
  43261. /**
  43262. * Disposes of the gizmo
  43263. */
  43264. dispose(): void;
  43265. /**
  43266. * CustomMeshes are not supported by this gizmo
  43267. * @param mesh The mesh to replace the default mesh of the gizmo
  43268. */
  43269. setCustomMesh(mesh: Mesh): void;
  43270. }
  43271. }
  43272. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43273. import { Scene } from "babylonjs/scene";
  43274. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43275. import { Mesh } from "babylonjs/Meshes/mesh";
  43276. /**
  43277. * Class containing static functions to help procedurally build meshes
  43278. */
  43279. export class PolyhedronBuilder {
  43280. /**
  43281. * Creates a polyhedron mesh
  43282. * * 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
  43283. * * The parameter `size` (positive float, default 1) sets the polygon size
  43284. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43285. * * 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`
  43286. * * 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
  43287. * * 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)`)
  43288. * * 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
  43289. * * 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
  43290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43293. * @param name defines the name of the mesh
  43294. * @param options defines the options used to create the mesh
  43295. * @param scene defines the hosting scene
  43296. * @returns the polyhedron mesh
  43297. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43298. */
  43299. static CreatePolyhedron(name: string, options: {
  43300. type?: number;
  43301. size?: number;
  43302. sizeX?: number;
  43303. sizeY?: number;
  43304. sizeZ?: number;
  43305. custom?: any;
  43306. faceUV?: Vector4[];
  43307. faceColors?: Color4[];
  43308. flat?: boolean;
  43309. updatable?: boolean;
  43310. sideOrientation?: number;
  43311. frontUVs?: Vector4;
  43312. backUVs?: Vector4;
  43313. }, scene: Scene): Mesh;
  43314. }
  43315. }
  43316. declare module "babylonjs/Gizmos/scaleGizmo" {
  43317. import { Observable } from "babylonjs/Misc/observable";
  43318. import { Nullable } from "babylonjs/types";
  43319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43320. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43321. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43322. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43323. /**
  43324. * Gizmo that enables scaling a mesh along 3 axis
  43325. */
  43326. export class ScaleGizmo extends Gizmo {
  43327. /**
  43328. * Internal gizmo used for interactions on the x axis
  43329. */
  43330. xGizmo: AxisScaleGizmo;
  43331. /**
  43332. * Internal gizmo used for interactions on the y axis
  43333. */
  43334. yGizmo: AxisScaleGizmo;
  43335. /**
  43336. * Internal gizmo used for interactions on the z axis
  43337. */
  43338. zGizmo: AxisScaleGizmo;
  43339. /**
  43340. * Internal gizmo used to scale all axis equally
  43341. */
  43342. uniformScaleGizmo: AxisScaleGizmo;
  43343. /** Fires an event when any of it's sub gizmos are dragged */
  43344. onDragStartObservable: Observable<{}>;
  43345. /** Fires an event when any of it's sub gizmos are released from dragging */
  43346. onDragEndObservable: Observable<{}>;
  43347. attachedMesh: Nullable<AbstractMesh>;
  43348. /**
  43349. * Creates a ScaleGizmo
  43350. * @param gizmoLayer The utility layer the gizmo will be added to
  43351. */
  43352. constructor(gizmoLayer?: UtilityLayerRenderer);
  43353. updateGizmoRotationToMatchAttachedMesh: boolean;
  43354. /**
  43355. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43356. */
  43357. snapDistance: number;
  43358. /**
  43359. * Ratio for the scale of the gizmo (Default: 1)
  43360. */
  43361. scaleRatio: number;
  43362. /**
  43363. * Disposes of the gizmo
  43364. */
  43365. dispose(): void;
  43366. }
  43367. }
  43368. declare module "babylonjs/Gizmos/gizmoManager" {
  43369. import { Observable } from "babylonjs/Misc/observable";
  43370. import { Nullable } from "babylonjs/types";
  43371. import { Scene, IDisposable } from "babylonjs/scene";
  43372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43373. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43374. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43375. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43376. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43377. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43378. /**
  43379. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43380. */
  43381. export class GizmoManager implements IDisposable {
  43382. private scene;
  43383. /**
  43384. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43385. */
  43386. gizmos: {
  43387. positionGizmo: Nullable<PositionGizmo>;
  43388. rotationGizmo: Nullable<RotationGizmo>;
  43389. scaleGizmo: Nullable<ScaleGizmo>;
  43390. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43391. };
  43392. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43393. clearGizmoOnEmptyPointerEvent: boolean;
  43394. /** Fires an event when the manager is attached to a mesh */
  43395. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43396. private _gizmosEnabled;
  43397. private _pointerObserver;
  43398. private _attachedMesh;
  43399. private _boundingBoxColor;
  43400. private _defaultUtilityLayer;
  43401. private _defaultKeepDepthUtilityLayer;
  43402. /**
  43403. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43404. */
  43405. boundingBoxDragBehavior: SixDofDragBehavior;
  43406. /**
  43407. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43408. */
  43409. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43410. /**
  43411. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43412. */
  43413. usePointerToAttachGizmos: boolean;
  43414. /**
  43415. * Instatiates a gizmo manager
  43416. * @param scene the scene to overlay the gizmos on top of
  43417. */
  43418. constructor(scene: Scene);
  43419. /**
  43420. * Attaches a set of gizmos to the specified mesh
  43421. * @param mesh The mesh the gizmo's should be attached to
  43422. */
  43423. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43424. /**
  43425. * If the position gizmo is enabled
  43426. */
  43427. positionGizmoEnabled: boolean;
  43428. /**
  43429. * If the rotation gizmo is enabled
  43430. */
  43431. rotationGizmoEnabled: boolean;
  43432. /**
  43433. * If the scale gizmo is enabled
  43434. */
  43435. scaleGizmoEnabled: boolean;
  43436. /**
  43437. * If the boundingBox gizmo is enabled
  43438. */
  43439. boundingBoxGizmoEnabled: boolean;
  43440. /**
  43441. * Disposes of the gizmo manager
  43442. */
  43443. dispose(): void;
  43444. }
  43445. }
  43446. declare module "babylonjs/Gizmos/lightGizmo" {
  43447. import { Nullable } from "babylonjs/types";
  43448. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43449. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43450. import { Light } from "babylonjs/Lights/light";
  43451. /**
  43452. * Gizmo that enables viewing a light
  43453. */
  43454. export class LightGizmo extends Gizmo {
  43455. private _box;
  43456. /**
  43457. * Creates a LightGizmo
  43458. * @param gizmoLayer The utility layer the gizmo will be added to
  43459. */
  43460. constructor(gizmoLayer?: UtilityLayerRenderer);
  43461. private _light;
  43462. /**
  43463. * The light that the gizmo is attached to
  43464. */
  43465. light: Nullable<Light>;
  43466. /**
  43467. * @hidden
  43468. * Updates the gizmo to match the attached mesh's position/rotation
  43469. */
  43470. protected _update(): void;
  43471. }
  43472. }
  43473. declare module "babylonjs/Gizmos/index" {
  43474. export * from "babylonjs/Gizmos/axisDragGizmo";
  43475. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43476. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43477. export * from "babylonjs/Gizmos/gizmo";
  43478. export * from "babylonjs/Gizmos/gizmoManager";
  43479. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43480. export * from "babylonjs/Gizmos/positionGizmo";
  43481. export * from "babylonjs/Gizmos/rotationGizmo";
  43482. export * from "babylonjs/Gizmos/scaleGizmo";
  43483. export * from "babylonjs/Gizmos/lightGizmo";
  43484. }
  43485. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43486. /** @hidden */
  43487. export var backgroundFragmentDeclaration: {
  43488. name: string;
  43489. shader: string;
  43490. };
  43491. }
  43492. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43493. /** @hidden */
  43494. export var backgroundUboDeclaration: {
  43495. name: string;
  43496. shader: string;
  43497. };
  43498. }
  43499. declare module "babylonjs/Shaders/background.fragment" {
  43500. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43501. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43502. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43503. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43504. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43505. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43506. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43507. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43508. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43509. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43510. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43511. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43512. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43513. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43514. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43515. /** @hidden */
  43516. export var backgroundPixelShader: {
  43517. name: string;
  43518. shader: string;
  43519. };
  43520. }
  43521. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43522. /** @hidden */
  43523. export var backgroundVertexDeclaration: {
  43524. name: string;
  43525. shader: string;
  43526. };
  43527. }
  43528. declare module "babylonjs/Shaders/background.vertex" {
  43529. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43530. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43531. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43532. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43533. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43535. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43536. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43537. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43538. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43539. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43540. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43541. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43542. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43543. /** @hidden */
  43544. export var backgroundVertexShader: {
  43545. name: string;
  43546. shader: string;
  43547. };
  43548. }
  43549. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43550. import { Nullable, int, float } from "babylonjs/types";
  43551. import { Scene } from "babylonjs/scene";
  43552. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43555. import { Mesh } from "babylonjs/Meshes/mesh";
  43556. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43557. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43558. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43560. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43561. import "babylonjs/Shaders/background.fragment";
  43562. import "babylonjs/Shaders/background.vertex";
  43563. /**
  43564. * Background material used to create an efficient environement around your scene.
  43565. */
  43566. export class BackgroundMaterial extends PushMaterial {
  43567. /**
  43568. * Standard reflectance value at parallel view angle.
  43569. */
  43570. static StandardReflectance0: number;
  43571. /**
  43572. * Standard reflectance value at grazing angle.
  43573. */
  43574. static StandardReflectance90: number;
  43575. protected _primaryColor: Color3;
  43576. /**
  43577. * Key light Color (multiply against the environement texture)
  43578. */
  43579. primaryColor: Color3;
  43580. protected __perceptualColor: Nullable<Color3>;
  43581. /**
  43582. * Experimental Internal Use Only.
  43583. *
  43584. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43585. * This acts as a helper to set the primary color to a more "human friendly" value.
  43586. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43587. * output color as close as possible from the chosen value.
  43588. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43589. * part of lighting setup.)
  43590. */
  43591. _perceptualColor: Nullable<Color3>;
  43592. protected _primaryColorShadowLevel: float;
  43593. /**
  43594. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43595. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43596. */
  43597. primaryColorShadowLevel: float;
  43598. protected _primaryColorHighlightLevel: float;
  43599. /**
  43600. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43601. * The primary color is used at the level chosen to define what the white area would look.
  43602. */
  43603. primaryColorHighlightLevel: float;
  43604. protected _reflectionTexture: Nullable<BaseTexture>;
  43605. /**
  43606. * Reflection Texture used in the material.
  43607. * Should be author in a specific way for the best result (refer to the documentation).
  43608. */
  43609. reflectionTexture: Nullable<BaseTexture>;
  43610. protected _reflectionBlur: float;
  43611. /**
  43612. * Reflection Texture level of blur.
  43613. *
  43614. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43615. * texture twice.
  43616. */
  43617. reflectionBlur: float;
  43618. protected _diffuseTexture: Nullable<BaseTexture>;
  43619. /**
  43620. * Diffuse Texture used in the material.
  43621. * Should be author in a specific way for the best result (refer to the documentation).
  43622. */
  43623. diffuseTexture: Nullable<BaseTexture>;
  43624. protected _shadowLights: Nullable<IShadowLight[]>;
  43625. /**
  43626. * Specify the list of lights casting shadow on the material.
  43627. * All scene shadow lights will be included if null.
  43628. */
  43629. shadowLights: Nullable<IShadowLight[]>;
  43630. protected _shadowLevel: float;
  43631. /**
  43632. * Helps adjusting the shadow to a softer level if required.
  43633. * 0 means black shadows and 1 means no shadows.
  43634. */
  43635. shadowLevel: float;
  43636. protected _sceneCenter: Vector3;
  43637. /**
  43638. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43639. * It is usually zero but might be interesting to modify according to your setup.
  43640. */
  43641. sceneCenter: Vector3;
  43642. protected _opacityFresnel: boolean;
  43643. /**
  43644. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43645. * This helps ensuring a nice transition when the camera goes under the ground.
  43646. */
  43647. opacityFresnel: boolean;
  43648. protected _reflectionFresnel: boolean;
  43649. /**
  43650. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43651. * This helps adding a mirror texture on the ground.
  43652. */
  43653. reflectionFresnel: boolean;
  43654. protected _reflectionFalloffDistance: number;
  43655. /**
  43656. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43657. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43658. */
  43659. reflectionFalloffDistance: number;
  43660. protected _reflectionAmount: number;
  43661. /**
  43662. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43663. */
  43664. reflectionAmount: number;
  43665. protected _reflectionReflectance0: number;
  43666. /**
  43667. * This specifies the weight of the reflection at grazing angle.
  43668. */
  43669. reflectionReflectance0: number;
  43670. protected _reflectionReflectance90: number;
  43671. /**
  43672. * This specifies the weight of the reflection at a perpendicular point of view.
  43673. */
  43674. reflectionReflectance90: number;
  43675. /**
  43676. * Sets the reflection reflectance fresnel values according to the default standard
  43677. * empirically know to work well :-)
  43678. */
  43679. reflectionStandardFresnelWeight: number;
  43680. protected _useRGBColor: boolean;
  43681. /**
  43682. * Helps to directly use the maps channels instead of their level.
  43683. */
  43684. useRGBColor: boolean;
  43685. protected _enableNoise: boolean;
  43686. /**
  43687. * This helps reducing the banding effect that could occur on the background.
  43688. */
  43689. enableNoise: boolean;
  43690. /**
  43691. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43692. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43693. * Recommended to be keep at 1.0 except for special cases.
  43694. */
  43695. fovMultiplier: number;
  43696. private _fovMultiplier;
  43697. /**
  43698. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43699. */
  43700. useEquirectangularFOV: boolean;
  43701. private _maxSimultaneousLights;
  43702. /**
  43703. * Number of Simultaneous lights allowed on the material.
  43704. */
  43705. maxSimultaneousLights: int;
  43706. /**
  43707. * Default configuration related to image processing available in the Background Material.
  43708. */
  43709. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43710. /**
  43711. * Keep track of the image processing observer to allow dispose and replace.
  43712. */
  43713. private _imageProcessingObserver;
  43714. /**
  43715. * Attaches a new image processing configuration to the PBR Material.
  43716. * @param configuration (if null the scene configuration will be use)
  43717. */
  43718. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43719. /**
  43720. * Gets the image processing configuration used either in this material.
  43721. */
  43722. /**
  43723. * Sets the Default image processing configuration used either in the this material.
  43724. *
  43725. * If sets to null, the scene one is in use.
  43726. */
  43727. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43728. /**
  43729. * Gets wether the color curves effect is enabled.
  43730. */
  43731. /**
  43732. * Sets wether the color curves effect is enabled.
  43733. */
  43734. cameraColorCurvesEnabled: boolean;
  43735. /**
  43736. * Gets wether the color grading effect is enabled.
  43737. */
  43738. /**
  43739. * Gets wether the color grading effect is enabled.
  43740. */
  43741. cameraColorGradingEnabled: boolean;
  43742. /**
  43743. * Gets wether tonemapping is enabled or not.
  43744. */
  43745. /**
  43746. * Sets wether tonemapping is enabled or not
  43747. */
  43748. cameraToneMappingEnabled: boolean;
  43749. /**
  43750. * The camera exposure used on this material.
  43751. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43752. * This corresponds to a photographic exposure.
  43753. */
  43754. /**
  43755. * The camera exposure used on this material.
  43756. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43757. * This corresponds to a photographic exposure.
  43758. */
  43759. cameraExposure: float;
  43760. /**
  43761. * Gets The camera contrast used on this material.
  43762. */
  43763. /**
  43764. * Sets The camera contrast used on this material.
  43765. */
  43766. cameraContrast: float;
  43767. /**
  43768. * Gets the Color Grading 2D Lookup Texture.
  43769. */
  43770. /**
  43771. * Sets the Color Grading 2D Lookup Texture.
  43772. */
  43773. cameraColorGradingTexture: Nullable<BaseTexture>;
  43774. /**
  43775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43777. * 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;
  43778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43779. */
  43780. /**
  43781. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43782. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43783. * 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;
  43784. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43785. */
  43786. cameraColorCurves: Nullable<ColorCurves>;
  43787. /**
  43788. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43789. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43790. */
  43791. switchToBGR: boolean;
  43792. private _renderTargets;
  43793. private _reflectionControls;
  43794. private _white;
  43795. private _primaryShadowColor;
  43796. private _primaryHighlightColor;
  43797. /**
  43798. * Instantiates a Background Material in the given scene
  43799. * @param name The friendly name of the material
  43800. * @param scene The scene to add the material to
  43801. */
  43802. constructor(name: string, scene: Scene);
  43803. /**
  43804. * Gets a boolean indicating that current material needs to register RTT
  43805. */
  43806. readonly hasRenderTargetTextures: boolean;
  43807. /**
  43808. * The entire material has been created in order to prevent overdraw.
  43809. * @returns false
  43810. */
  43811. needAlphaTesting(): boolean;
  43812. /**
  43813. * The entire material has been created in order to prevent overdraw.
  43814. * @returns true if blending is enable
  43815. */
  43816. needAlphaBlending(): boolean;
  43817. /**
  43818. * Checks wether the material is ready to be rendered for a given mesh.
  43819. * @param mesh The mesh to render
  43820. * @param subMesh The submesh to check against
  43821. * @param useInstances Specify wether or not the material is used with instances
  43822. * @returns true if all the dependencies are ready (Textures, Effects...)
  43823. */
  43824. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43825. /**
  43826. * Compute the primary color according to the chosen perceptual color.
  43827. */
  43828. private _computePrimaryColorFromPerceptualColor;
  43829. /**
  43830. * Compute the highlights and shadow colors according to their chosen levels.
  43831. */
  43832. private _computePrimaryColors;
  43833. /**
  43834. * Build the uniform buffer used in the material.
  43835. */
  43836. buildUniformLayout(): void;
  43837. /**
  43838. * Unbind the material.
  43839. */
  43840. unbind(): void;
  43841. /**
  43842. * Bind only the world matrix to the material.
  43843. * @param world The world matrix to bind.
  43844. */
  43845. bindOnlyWorldMatrix(world: Matrix): void;
  43846. /**
  43847. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43848. * @param world The world matrix to bind.
  43849. * @param subMesh The submesh to bind for.
  43850. */
  43851. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43852. /**
  43853. * Dispose the material.
  43854. * @param forceDisposeEffect Force disposal of the associated effect.
  43855. * @param forceDisposeTextures Force disposal of the associated textures.
  43856. */
  43857. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43858. /**
  43859. * Clones the material.
  43860. * @param name The cloned name.
  43861. * @returns The cloned material.
  43862. */
  43863. clone(name: string): BackgroundMaterial;
  43864. /**
  43865. * Serializes the current material to its JSON representation.
  43866. * @returns The JSON representation.
  43867. */
  43868. serialize(): any;
  43869. /**
  43870. * Gets the class name of the material
  43871. * @returns "BackgroundMaterial"
  43872. */
  43873. getClassName(): string;
  43874. /**
  43875. * Parse a JSON input to create back a background material.
  43876. * @param source The JSON data to parse
  43877. * @param scene The scene to create the parsed material in
  43878. * @param rootUrl The root url of the assets the material depends upon
  43879. * @returns the instantiated BackgroundMaterial.
  43880. */
  43881. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43882. }
  43883. }
  43884. declare module "babylonjs/Helpers/environmentHelper" {
  43885. import { Observable } from "babylonjs/Misc/observable";
  43886. import { Nullable } from "babylonjs/types";
  43887. import { Scene } from "babylonjs/scene";
  43888. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43890. import { Mesh } from "babylonjs/Meshes/mesh";
  43891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43892. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43893. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43894. import "babylonjs/Meshes/Builders/planeBuilder";
  43895. import "babylonjs/Meshes/Builders/boxBuilder";
  43896. /**
  43897. * Represents the different options available during the creation of
  43898. * a Environment helper.
  43899. *
  43900. * This can control the default ground, skybox and image processing setup of your scene.
  43901. */
  43902. export interface IEnvironmentHelperOptions {
  43903. /**
  43904. * Specifies wether or not to create a ground.
  43905. * True by default.
  43906. */
  43907. createGround: boolean;
  43908. /**
  43909. * Specifies the ground size.
  43910. * 15 by default.
  43911. */
  43912. groundSize: number;
  43913. /**
  43914. * The texture used on the ground for the main color.
  43915. * Comes from the BabylonJS CDN by default.
  43916. *
  43917. * Remarks: Can be either a texture or a url.
  43918. */
  43919. groundTexture: string | BaseTexture;
  43920. /**
  43921. * The color mixed in the ground texture by default.
  43922. * BabylonJS clearColor by default.
  43923. */
  43924. groundColor: Color3;
  43925. /**
  43926. * Specifies the ground opacity.
  43927. * 1 by default.
  43928. */
  43929. groundOpacity: number;
  43930. /**
  43931. * Enables the ground to receive shadows.
  43932. * True by default.
  43933. */
  43934. enableGroundShadow: boolean;
  43935. /**
  43936. * Helps preventing the shadow to be fully black on the ground.
  43937. * 0.5 by default.
  43938. */
  43939. groundShadowLevel: number;
  43940. /**
  43941. * Creates a mirror texture attach to the ground.
  43942. * false by default.
  43943. */
  43944. enableGroundMirror: boolean;
  43945. /**
  43946. * Specifies the ground mirror size ratio.
  43947. * 0.3 by default as the default kernel is 64.
  43948. */
  43949. groundMirrorSizeRatio: number;
  43950. /**
  43951. * Specifies the ground mirror blur kernel size.
  43952. * 64 by default.
  43953. */
  43954. groundMirrorBlurKernel: number;
  43955. /**
  43956. * Specifies the ground mirror visibility amount.
  43957. * 1 by default
  43958. */
  43959. groundMirrorAmount: number;
  43960. /**
  43961. * Specifies the ground mirror reflectance weight.
  43962. * This uses the standard weight of the background material to setup the fresnel effect
  43963. * of the mirror.
  43964. * 1 by default.
  43965. */
  43966. groundMirrorFresnelWeight: number;
  43967. /**
  43968. * Specifies the ground mirror Falloff distance.
  43969. * This can helps reducing the size of the reflection.
  43970. * 0 by Default.
  43971. */
  43972. groundMirrorFallOffDistance: number;
  43973. /**
  43974. * Specifies the ground mirror texture type.
  43975. * Unsigned Int by Default.
  43976. */
  43977. groundMirrorTextureType: number;
  43978. /**
  43979. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43980. * the shown objects.
  43981. */
  43982. groundYBias: number;
  43983. /**
  43984. * Specifies wether or not to create a skybox.
  43985. * True by default.
  43986. */
  43987. createSkybox: boolean;
  43988. /**
  43989. * Specifies the skybox size.
  43990. * 20 by default.
  43991. */
  43992. skyboxSize: number;
  43993. /**
  43994. * The texture used on the skybox for the main color.
  43995. * Comes from the BabylonJS CDN by default.
  43996. *
  43997. * Remarks: Can be either a texture or a url.
  43998. */
  43999. skyboxTexture: string | BaseTexture;
  44000. /**
  44001. * The color mixed in the skybox texture by default.
  44002. * BabylonJS clearColor by default.
  44003. */
  44004. skyboxColor: Color3;
  44005. /**
  44006. * The background rotation around the Y axis of the scene.
  44007. * This helps aligning the key lights of your scene with the background.
  44008. * 0 by default.
  44009. */
  44010. backgroundYRotation: number;
  44011. /**
  44012. * Compute automatically the size of the elements to best fit with the scene.
  44013. */
  44014. sizeAuto: boolean;
  44015. /**
  44016. * Default position of the rootMesh if autoSize is not true.
  44017. */
  44018. rootPosition: Vector3;
  44019. /**
  44020. * Sets up the image processing in the scene.
  44021. * true by default.
  44022. */
  44023. setupImageProcessing: boolean;
  44024. /**
  44025. * The texture used as your environment texture in the scene.
  44026. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44027. *
  44028. * Remarks: Can be either a texture or a url.
  44029. */
  44030. environmentTexture: string | BaseTexture;
  44031. /**
  44032. * The value of the exposure to apply to the scene.
  44033. * 0.6 by default if setupImageProcessing is true.
  44034. */
  44035. cameraExposure: number;
  44036. /**
  44037. * The value of the contrast to apply to the scene.
  44038. * 1.6 by default if setupImageProcessing is true.
  44039. */
  44040. cameraContrast: number;
  44041. /**
  44042. * Specifies wether or not tonemapping should be enabled in the scene.
  44043. * true by default if setupImageProcessing is true.
  44044. */
  44045. toneMappingEnabled: boolean;
  44046. }
  44047. /**
  44048. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44049. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44050. * It also helps with the default setup of your imageProcessing configuration.
  44051. */
  44052. export class EnvironmentHelper {
  44053. /**
  44054. * Default ground texture URL.
  44055. */
  44056. private static _groundTextureCDNUrl;
  44057. /**
  44058. * Default skybox texture URL.
  44059. */
  44060. private static _skyboxTextureCDNUrl;
  44061. /**
  44062. * Default environment texture URL.
  44063. */
  44064. private static _environmentTextureCDNUrl;
  44065. /**
  44066. * Creates the default options for the helper.
  44067. */
  44068. private static _getDefaultOptions;
  44069. private _rootMesh;
  44070. /**
  44071. * Gets the root mesh created by the helper.
  44072. */
  44073. readonly rootMesh: Mesh;
  44074. private _skybox;
  44075. /**
  44076. * Gets the skybox created by the helper.
  44077. */
  44078. readonly skybox: Nullable<Mesh>;
  44079. private _skyboxTexture;
  44080. /**
  44081. * Gets the skybox texture created by the helper.
  44082. */
  44083. readonly skyboxTexture: Nullable<BaseTexture>;
  44084. private _skyboxMaterial;
  44085. /**
  44086. * Gets the skybox material created by the helper.
  44087. */
  44088. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44089. private _ground;
  44090. /**
  44091. * Gets the ground mesh created by the helper.
  44092. */
  44093. readonly ground: Nullable<Mesh>;
  44094. private _groundTexture;
  44095. /**
  44096. * Gets the ground texture created by the helper.
  44097. */
  44098. readonly groundTexture: Nullable<BaseTexture>;
  44099. private _groundMirror;
  44100. /**
  44101. * Gets the ground mirror created by the helper.
  44102. */
  44103. readonly groundMirror: Nullable<MirrorTexture>;
  44104. /**
  44105. * Gets the ground mirror render list to helps pushing the meshes
  44106. * you wish in the ground reflection.
  44107. */
  44108. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44109. private _groundMaterial;
  44110. /**
  44111. * Gets the ground material created by the helper.
  44112. */
  44113. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44114. /**
  44115. * Stores the creation options.
  44116. */
  44117. private readonly _scene;
  44118. private _options;
  44119. /**
  44120. * This observable will be notified with any error during the creation of the environment,
  44121. * mainly texture creation errors.
  44122. */
  44123. onErrorObservable: Observable<{
  44124. message?: string;
  44125. exception?: any;
  44126. }>;
  44127. /**
  44128. * constructor
  44129. * @param options Defines the options we want to customize the helper
  44130. * @param scene The scene to add the material to
  44131. */
  44132. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44133. /**
  44134. * Updates the background according to the new options
  44135. * @param options
  44136. */
  44137. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44138. /**
  44139. * Sets the primary color of all the available elements.
  44140. * @param color the main color to affect to the ground and the background
  44141. */
  44142. setMainColor(color: Color3): void;
  44143. /**
  44144. * Setup the image processing according to the specified options.
  44145. */
  44146. private _setupImageProcessing;
  44147. /**
  44148. * Setup the environment texture according to the specified options.
  44149. */
  44150. private _setupEnvironmentTexture;
  44151. /**
  44152. * Setup the background according to the specified options.
  44153. */
  44154. private _setupBackground;
  44155. /**
  44156. * Get the scene sizes according to the setup.
  44157. */
  44158. private _getSceneSize;
  44159. /**
  44160. * Setup the ground according to the specified options.
  44161. */
  44162. private _setupGround;
  44163. /**
  44164. * Setup the ground material according to the specified options.
  44165. */
  44166. private _setupGroundMaterial;
  44167. /**
  44168. * Setup the ground diffuse texture according to the specified options.
  44169. */
  44170. private _setupGroundDiffuseTexture;
  44171. /**
  44172. * Setup the ground mirror texture according to the specified options.
  44173. */
  44174. private _setupGroundMirrorTexture;
  44175. /**
  44176. * Setup the ground to receive the mirror texture.
  44177. */
  44178. private _setupMirrorInGroundMaterial;
  44179. /**
  44180. * Setup the skybox according to the specified options.
  44181. */
  44182. private _setupSkybox;
  44183. /**
  44184. * Setup the skybox material according to the specified options.
  44185. */
  44186. private _setupSkyboxMaterial;
  44187. /**
  44188. * Setup the skybox reflection texture according to the specified options.
  44189. */
  44190. private _setupSkyboxReflectionTexture;
  44191. private _errorHandler;
  44192. /**
  44193. * Dispose all the elements created by the Helper.
  44194. */
  44195. dispose(): void;
  44196. }
  44197. }
  44198. declare module "babylonjs/Helpers/photoDome" {
  44199. import { Observable } from "babylonjs/Misc/observable";
  44200. import { Nullable } from "babylonjs/types";
  44201. import { Scene } from "babylonjs/scene";
  44202. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44203. import { Mesh } from "babylonjs/Meshes/mesh";
  44204. import { Texture } from "babylonjs/Materials/Textures/texture";
  44205. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44206. import "babylonjs/Meshes/Builders/sphereBuilder";
  44207. /**
  44208. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44209. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44210. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44211. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44212. */
  44213. export class PhotoDome extends TransformNode {
  44214. private _useDirectMapping;
  44215. /**
  44216. * The texture being displayed on the sphere
  44217. */
  44218. protected _photoTexture: Texture;
  44219. /**
  44220. * Gets or sets the texture being displayed on the sphere
  44221. */
  44222. photoTexture: Texture;
  44223. /**
  44224. * Observable raised when an error occured while loading the 360 image
  44225. */
  44226. onLoadErrorObservable: Observable<string>;
  44227. /**
  44228. * The skybox material
  44229. */
  44230. protected _material: BackgroundMaterial;
  44231. /**
  44232. * The surface used for the skybox
  44233. */
  44234. protected _mesh: Mesh;
  44235. /**
  44236. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44237. * Also see the options.resolution property.
  44238. */
  44239. fovMultiplier: number;
  44240. /**
  44241. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44242. * @param name Element's name, child elements will append suffixes for their own names.
  44243. * @param urlsOfPhoto defines the url of the photo to display
  44244. * @param options defines an object containing optional or exposed sub element properties
  44245. * @param onError defines a callback called when an error occured while loading the texture
  44246. */
  44247. constructor(name: string, urlOfPhoto: string, options: {
  44248. resolution?: number;
  44249. size?: number;
  44250. useDirectMapping?: boolean;
  44251. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44252. /**
  44253. * Releases resources associated with this node.
  44254. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44255. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44256. */
  44257. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44258. }
  44259. }
  44260. declare module "babylonjs/Misc/textureTools" {
  44261. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44262. import { Texture } from "babylonjs/Materials/Textures/texture";
  44263. import { Scene } from "babylonjs/scene";
  44264. /**
  44265. * Class used to host texture specific utilities
  44266. */
  44267. export class TextureTools {
  44268. /**
  44269. * Uses the GPU to create a copy texture rescaled at a given size
  44270. * @param texture Texture to copy from
  44271. * @param width defines the desired width
  44272. * @param height defines the desired height
  44273. * @param useBilinearMode defines if bilinear mode has to be used
  44274. * @return the generated texture
  44275. */
  44276. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44277. /**
  44278. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44279. * @param scene defines the hosting scene
  44280. * @returns the environment BRDF texture
  44281. */
  44282. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44283. private static _environmentBRDFBase64Texture;
  44284. }
  44285. }
  44286. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44287. import { Nullable } from "babylonjs/types";
  44288. import { IAnimatable } from "babylonjs/Misc/tools";
  44289. import { Color3 } from "babylonjs/Maths/math";
  44290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44291. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44292. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44293. import { Engine } from "babylonjs/Engines/engine";
  44294. import { Scene } from "babylonjs/scene";
  44295. /**
  44296. * @hidden
  44297. */
  44298. export interface IMaterialClearCoatDefines {
  44299. CLEARCOAT: boolean;
  44300. CLEARCOAT_DEFAULTIOR: boolean;
  44301. CLEARCOAT_TEXTURE: boolean;
  44302. CLEARCOAT_TEXTUREDIRECTUV: number;
  44303. CLEARCOAT_BUMP: boolean;
  44304. CLEARCOAT_BUMPDIRECTUV: number;
  44305. CLEARCOAT_TINT: boolean;
  44306. CLEARCOAT_TINT_TEXTURE: boolean;
  44307. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44308. /** @hidden */
  44309. _areTexturesDirty: boolean;
  44310. }
  44311. /**
  44312. * Define the code related to the clear coat parameters of the pbr material.
  44313. */
  44314. export class PBRClearCoatConfiguration {
  44315. /**
  44316. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44317. * The default fits with a polyurethane material.
  44318. */
  44319. private static readonly _DefaultIndiceOfRefraction;
  44320. private _isEnabled;
  44321. /**
  44322. * Defines if the clear coat is enabled in the material.
  44323. */
  44324. isEnabled: boolean;
  44325. /**
  44326. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44327. */
  44328. intensity: number;
  44329. /**
  44330. * Defines the clear coat layer roughness.
  44331. */
  44332. roughness: number;
  44333. private _indiceOfRefraction;
  44334. /**
  44335. * Defines the indice of refraction of the clear coat.
  44336. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44337. * The default fits with a polyurethane material.
  44338. * Changing the default value is more performance intensive.
  44339. */
  44340. indiceOfRefraction: number;
  44341. private _texture;
  44342. /**
  44343. * Stores the clear coat values in a texture.
  44344. */
  44345. texture: Nullable<BaseTexture>;
  44346. private _bumpTexture;
  44347. /**
  44348. * Define the clear coat specific bump texture.
  44349. */
  44350. bumpTexture: Nullable<BaseTexture>;
  44351. private _isTintEnabled;
  44352. /**
  44353. * Defines if the clear coat tint is enabled in the material.
  44354. */
  44355. isTintEnabled: boolean;
  44356. /**
  44357. * Defines if the clear coat tint is enabled in the material.
  44358. * This is only use if tint is enabled
  44359. */
  44360. tintColor: Color3;
  44361. /**
  44362. * Defines if the distance at which the tint color should be found in the
  44363. * clear coat media.
  44364. * This is only use if tint is enabled
  44365. */
  44366. tintColorAtDistance: number;
  44367. /**
  44368. * Defines the clear coat layer thickness.
  44369. * This is only use if tint is enabled
  44370. */
  44371. tintThickness: number;
  44372. private _tintTexture;
  44373. /**
  44374. * Stores the clear tint values in a texture.
  44375. * rgb is tint
  44376. * a is a thickness factor
  44377. */
  44378. tintTexture: Nullable<BaseTexture>;
  44379. /** @hidden */
  44380. private _internalMarkAllSubMeshesAsTexturesDirty;
  44381. /** @hidden */
  44382. _markAllSubMeshesAsTexturesDirty(): void;
  44383. /**
  44384. * Instantiate a new istance of clear coat configuration.
  44385. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44386. */
  44387. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44388. /**
  44389. * Specifies that the submesh is ready to be used.
  44390. * @param defines the list of "defines" to update.
  44391. * @param scene defines the scene the material belongs to.
  44392. * @param engine defines the engine the material belongs to.
  44393. * @param disableBumpMap defines wether the material disables bump or not.
  44394. * @returns - boolean indicating that the submesh is ready or not.
  44395. */
  44396. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44397. /**
  44398. * Checks to see if a texture is used in the material.
  44399. * @param defines the list of "defines" to update.
  44400. * @param scene defines the scene to the material belongs to.
  44401. */
  44402. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44403. /**
  44404. * Binds the material data.
  44405. * @param uniformBuffer defines the Uniform buffer to fill in.
  44406. * @param scene defines the scene the material belongs to.
  44407. * @param engine defines the engine the material belongs to.
  44408. * @param disableBumpMap defines wether the material disables bump or not.
  44409. * @param isFrozen defines wether the material is frozen or not.
  44410. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44411. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44412. */
  44413. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44414. /**
  44415. * Checks to see if a texture is used in the material.
  44416. * @param texture - Base texture to use.
  44417. * @returns - Boolean specifying if a texture is used in the material.
  44418. */
  44419. hasTexture(texture: BaseTexture): boolean;
  44420. /**
  44421. * Returns an array of the actively used textures.
  44422. * @param activeTextures Array of BaseTextures
  44423. */
  44424. getActiveTextures(activeTextures: BaseTexture[]): void;
  44425. /**
  44426. * Returns the animatable textures.
  44427. * @param animatables Array of animatable textures.
  44428. */
  44429. getAnimatables(animatables: IAnimatable[]): void;
  44430. /**
  44431. * Disposes the resources of the material.
  44432. * @param forceDisposeTextures - Forces the disposal of all textures.
  44433. */
  44434. dispose(forceDisposeTextures?: boolean): void;
  44435. /**
  44436. * Get the current class name of the texture useful for serialization or dynamic coding.
  44437. * @returns "PBRClearCoatConfiguration"
  44438. */
  44439. getClassName(): string;
  44440. /**
  44441. * Add fallbacks to the effect fallbacks list.
  44442. * @param defines defines the Base texture to use.
  44443. * @param fallbacks defines the current fallback list.
  44444. * @param currentRank defines the current fallback rank.
  44445. * @returns the new fallback rank.
  44446. */
  44447. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44448. /**
  44449. * Add the required uniforms to the current list.
  44450. * @param uniforms defines the current uniform list.
  44451. */
  44452. static AddUniforms(uniforms: string[]): void;
  44453. /**
  44454. * Add the required samplers to the current list.
  44455. * @param samplers defines the current sampler list.
  44456. */
  44457. static AddSamplers(samplers: string[]): void;
  44458. /**
  44459. * Add the required uniforms to the current buffer.
  44460. * @param uniformBuffer defines the current uniform buffer.
  44461. */
  44462. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44463. /**
  44464. * Makes a duplicate of the current configuration into another one.
  44465. * @param clearCoatConfiguration define the config where to copy the info
  44466. */
  44467. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44468. /**
  44469. * Serializes this clear coat configuration.
  44470. * @returns - An object with the serialized config.
  44471. */
  44472. serialize(): any;
  44473. /**
  44474. * Parses a Clear Coat Configuration from a serialized object.
  44475. * @param source - Serialized object.
  44476. */
  44477. parse(source: any): void;
  44478. }
  44479. }
  44480. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44481. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44482. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44484. import { Vector2 } from "babylonjs/Maths/math";
  44485. import { Scene } from "babylonjs/scene";
  44486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44487. import { IAnimatable } from "babylonjs/Misc/tools";
  44488. import { Nullable } from "babylonjs/types";
  44489. /**
  44490. * @hidden
  44491. */
  44492. export interface IMaterialAnisotropicDefines {
  44493. ANISOTROPIC: boolean;
  44494. ANISOTROPIC_TEXTURE: boolean;
  44495. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44496. MAINUV1: boolean;
  44497. _areTexturesDirty: boolean;
  44498. _needUVs: boolean;
  44499. }
  44500. /**
  44501. * Define the code related to the anisotropic parameters of the pbr material.
  44502. */
  44503. export class PBRAnisotropicConfiguration {
  44504. private _isEnabled;
  44505. /**
  44506. * Defines if the anisotropy is enabled in the material.
  44507. */
  44508. isEnabled: boolean;
  44509. /**
  44510. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44511. */
  44512. intensity: number;
  44513. /**
  44514. * Defines if the effect is along the tangents, bitangents or in between.
  44515. * By default, the effect is "strectching" the highlights along the tangents.
  44516. */
  44517. direction: Vector2;
  44518. private _texture;
  44519. /**
  44520. * Stores the anisotropy values in a texture.
  44521. * rg is direction (like normal from -1 to 1)
  44522. * b is a intensity
  44523. */
  44524. texture: Nullable<BaseTexture>;
  44525. /** @hidden */
  44526. private _internalMarkAllSubMeshesAsTexturesDirty;
  44527. /** @hidden */
  44528. _markAllSubMeshesAsTexturesDirty(): void;
  44529. /**
  44530. * Instantiate a new istance of anisotropy configuration.
  44531. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44532. */
  44533. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44534. /**
  44535. * Specifies that the submesh is ready to be used.
  44536. * @param defines the list of "defines" to update.
  44537. * @param scene defines the scene the material belongs to.
  44538. * @returns - boolean indicating that the submesh is ready or not.
  44539. */
  44540. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44541. /**
  44542. * Checks to see if a texture is used in the material.
  44543. * @param defines the list of "defines" to update.
  44544. * @param mesh the mesh we are preparing the defines for.
  44545. * @param scene defines the scene the material belongs to.
  44546. */
  44547. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44548. /**
  44549. * Binds the material data.
  44550. * @param uniformBuffer defines the Uniform buffer to fill in.
  44551. * @param scene defines the scene the material belongs to.
  44552. * @param isFrozen defines wether the material is frozen or not.
  44553. */
  44554. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44555. /**
  44556. * Checks to see if a texture is used in the material.
  44557. * @param texture - Base texture to use.
  44558. * @returns - Boolean specifying if a texture is used in the material.
  44559. */
  44560. hasTexture(texture: BaseTexture): boolean;
  44561. /**
  44562. * Returns an array of the actively used textures.
  44563. * @param activeTextures Array of BaseTextures
  44564. */
  44565. getActiveTextures(activeTextures: BaseTexture[]): void;
  44566. /**
  44567. * Returns the animatable textures.
  44568. * @param animatables Array of animatable textures.
  44569. */
  44570. getAnimatables(animatables: IAnimatable[]): void;
  44571. /**
  44572. * Disposes the resources of the material.
  44573. * @param forceDisposeTextures - Forces the disposal of all textures.
  44574. */
  44575. dispose(forceDisposeTextures?: boolean): void;
  44576. /**
  44577. * Get the current class name of the texture useful for serialization or dynamic coding.
  44578. * @returns "PBRAnisotropicConfiguration"
  44579. */
  44580. getClassName(): string;
  44581. /**
  44582. * Add fallbacks to the effect fallbacks list.
  44583. * @param defines defines the Base texture to use.
  44584. * @param fallbacks defines the current fallback list.
  44585. * @param currentRank defines the current fallback rank.
  44586. * @returns the new fallback rank.
  44587. */
  44588. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44589. /**
  44590. * Add the required uniforms to the current list.
  44591. * @param uniforms defines the current uniform list.
  44592. */
  44593. static AddUniforms(uniforms: string[]): void;
  44594. /**
  44595. * Add the required uniforms to the current buffer.
  44596. * @param uniformBuffer defines the current uniform buffer.
  44597. */
  44598. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44599. /**
  44600. * Add the required samplers to the current list.
  44601. * @param samplers defines the current sampler list.
  44602. */
  44603. static AddSamplers(samplers: string[]): void;
  44604. /**
  44605. * Makes a duplicate of the current configuration into another one.
  44606. * @param anisotropicConfiguration define the config where to copy the info
  44607. */
  44608. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44609. /**
  44610. * Serializes this anisotropy configuration.
  44611. * @returns - An object with the serialized config.
  44612. */
  44613. serialize(): any;
  44614. /**
  44615. * Parses a anisotropy Configuration from a serialized object.
  44616. * @param source - Serialized object.
  44617. */
  44618. parse(source: any): void;
  44619. }
  44620. }
  44621. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  44622. /**
  44623. * @hidden
  44624. */
  44625. export interface IMaterialBRDFDefines {
  44626. BRDF_V_HEIGHT_CORRELATED: boolean;
  44627. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44628. /** @hidden */
  44629. _areMiscDirty: boolean;
  44630. }
  44631. /**
  44632. * Define the code related to the BRDF parameters of the pbr material.
  44633. */
  44634. export class PBRBRDFConfiguration {
  44635. private _useEnergyConservation;
  44636. /**
  44637. * Defines if the material uses energy conservation.
  44638. */
  44639. useEnergyConservation: boolean;
  44640. private _useSmithVisibilityHeightCorrelated;
  44641. /**
  44642. * LEGACY Mode set to false
  44643. * Defines if the material uses height smith correlated visibility term.
  44644. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44645. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44646. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44647. * Not relying on height correlated will also disable energy conservation.
  44648. */
  44649. useSmithVisibilityHeightCorrelated: boolean;
  44650. /** @hidden */
  44651. private _internalMarkAllSubMeshesAsMiscDirty;
  44652. /** @hidden */
  44653. _markAllSubMeshesAsMiscDirty(): void;
  44654. /**
  44655. * Instantiate a new istance of clear coat configuration.
  44656. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44657. */
  44658. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44659. /**
  44660. * Checks to see if a texture is used in the material.
  44661. * @param defines the list of "defines" to update.
  44662. */
  44663. prepareDefines(defines: IMaterialBRDFDefines): void;
  44664. /**
  44665. * Get the current class name of the texture useful for serialization or dynamic coding.
  44666. * @returns "PBRClearCoatConfiguration"
  44667. */
  44668. getClassName(): string;
  44669. /**
  44670. * Makes a duplicate of the current configuration into another one.
  44671. * @param brdfConfiguration define the config where to copy the info
  44672. */
  44673. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44674. /**
  44675. * Serializes this BRDF configuration.
  44676. * @returns - An object with the serialized config.
  44677. */
  44678. serialize(): any;
  44679. /**
  44680. * Parses a BRDF Configuration from a serialized object.
  44681. * @param source - Serialized object.
  44682. */
  44683. parse(source: any): void;
  44684. }
  44685. }
  44686. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  44687. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44688. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44689. import { Color3 } from "babylonjs/Maths/math";
  44690. import { Scene } from "babylonjs/scene";
  44691. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44692. import { IAnimatable } from "babylonjs/Misc/tools";
  44693. import { Nullable } from "babylonjs/types";
  44694. /**
  44695. * @hidden
  44696. */
  44697. export interface IMaterialSheenDefines {
  44698. SHEEN: boolean;
  44699. SHEEN_TEXTURE: boolean;
  44700. SHEEN_TEXTUREDIRECTUV: number;
  44701. SHEEN_LINKWITHALBEDO: boolean;
  44702. /** @hidden */
  44703. _areTexturesDirty: boolean;
  44704. }
  44705. /**
  44706. * Define the code related to the Sheen parameters of the pbr material.
  44707. */
  44708. export class PBRSheenConfiguration {
  44709. private _isEnabled;
  44710. /**
  44711. * Defines if the material uses sheen.
  44712. */
  44713. isEnabled: boolean;
  44714. private _linkSheenWithAlbedo;
  44715. /**
  44716. * Defines if the sheen is linked to the sheen color.
  44717. */
  44718. linkSheenWithAlbedo: boolean;
  44719. /**
  44720. * Defines the sheen intensity.
  44721. */
  44722. intensity: number;
  44723. /**
  44724. * Defines the sheen color.
  44725. */
  44726. color: Color3;
  44727. private _texture;
  44728. /**
  44729. * Stores the sheen tint values in a texture.
  44730. * rgb is tint
  44731. * a is a intensity
  44732. */
  44733. texture: Nullable<BaseTexture>;
  44734. /** @hidden */
  44735. private _internalMarkAllSubMeshesAsTexturesDirty;
  44736. /** @hidden */
  44737. _markAllSubMeshesAsTexturesDirty(): void;
  44738. /**
  44739. * Instantiate a new istance of clear coat configuration.
  44740. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44741. */
  44742. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44743. /**
  44744. * Specifies that the submesh is ready to be used.
  44745. * @param defines the list of "defines" to update.
  44746. * @param scene defines the scene the material belongs to.
  44747. * @returns - boolean indicating that the submesh is ready or not.
  44748. */
  44749. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44750. /**
  44751. * Checks to see if a texture is used in the material.
  44752. * @param defines the list of "defines" to update.
  44753. * @param scene defines the scene the material belongs to.
  44754. */
  44755. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44756. /**
  44757. * Binds the material data.
  44758. * @param uniformBuffer defines the Uniform buffer to fill in.
  44759. * @param scene defines the scene the material belongs to.
  44760. * @param isFrozen defines wether the material is frozen or not.
  44761. */
  44762. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44763. /**
  44764. * Checks to see if a texture is used in the material.
  44765. * @param texture - Base texture to use.
  44766. * @returns - Boolean specifying if a texture is used in the material.
  44767. */
  44768. hasTexture(texture: BaseTexture): boolean;
  44769. /**
  44770. * Returns an array of the actively used textures.
  44771. * @param activeTextures Array of BaseTextures
  44772. */
  44773. getActiveTextures(activeTextures: BaseTexture[]): void;
  44774. /**
  44775. * Returns the animatable textures.
  44776. * @param animatables Array of animatable textures.
  44777. */
  44778. getAnimatables(animatables: IAnimatable[]): void;
  44779. /**
  44780. * Disposes the resources of the material.
  44781. * @param forceDisposeTextures - Forces the disposal of all textures.
  44782. */
  44783. dispose(forceDisposeTextures?: boolean): void;
  44784. /**
  44785. * Get the current class name of the texture useful for serialization or dynamic coding.
  44786. * @returns "PBRSheenConfiguration"
  44787. */
  44788. getClassName(): string;
  44789. /**
  44790. * Add fallbacks to the effect fallbacks list.
  44791. * @param defines defines the Base texture to use.
  44792. * @param fallbacks defines the current fallback list.
  44793. * @param currentRank defines the current fallback rank.
  44794. * @returns the new fallback rank.
  44795. */
  44796. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44797. /**
  44798. * Add the required uniforms to the current list.
  44799. * @param uniforms defines the current uniform list.
  44800. */
  44801. static AddUniforms(uniforms: string[]): void;
  44802. /**
  44803. * Add the required uniforms to the current buffer.
  44804. * @param uniformBuffer defines the current uniform buffer.
  44805. */
  44806. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44807. /**
  44808. * Add the required samplers to the current list.
  44809. * @param samplers defines the current sampler list.
  44810. */
  44811. static AddSamplers(samplers: string[]): void;
  44812. /**
  44813. * Makes a duplicate of the current configuration into another one.
  44814. * @param sheenConfiguration define the config where to copy the info
  44815. */
  44816. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44817. /**
  44818. * Serializes this BRDF configuration.
  44819. * @returns - An object with the serialized config.
  44820. */
  44821. serialize(): any;
  44822. /**
  44823. * Parses a Sheen Configuration from a serialized object.
  44824. * @param source - Serialized object.
  44825. */
  44826. parse(source: any): void;
  44827. }
  44828. }
  44829. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  44830. /** @hidden */
  44831. export var pbrFragmentDeclaration: {
  44832. name: string;
  44833. shader: string;
  44834. };
  44835. }
  44836. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  44837. /** @hidden */
  44838. export var pbrUboDeclaration: {
  44839. name: string;
  44840. shader: string;
  44841. };
  44842. }
  44843. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  44844. /** @hidden */
  44845. export var pbrFunctions: {
  44846. name: string;
  44847. shader: string;
  44848. };
  44849. }
  44850. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  44851. /** @hidden */
  44852. export var harmonicsFunctions: {
  44853. name: string;
  44854. shader: string;
  44855. };
  44856. }
  44857. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  44858. /** @hidden */
  44859. export var pbrPreLightingFunctions: {
  44860. name: string;
  44861. shader: string;
  44862. };
  44863. }
  44864. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  44865. /** @hidden */
  44866. export var pbrFalloffLightingFunctions: {
  44867. name: string;
  44868. shader: string;
  44869. };
  44870. }
  44871. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  44872. /** @hidden */
  44873. export var pbrLightingFunctions: {
  44874. name: string;
  44875. shader: string;
  44876. };
  44877. }
  44878. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  44879. /** @hidden */
  44880. export var pbrDebug: {
  44881. name: string;
  44882. shader: string;
  44883. };
  44884. }
  44885. declare module "babylonjs/Shaders/pbr.fragment" {
  44886. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  44887. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44888. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44889. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44890. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44891. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44892. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44893. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44894. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44895. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  44896. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44897. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  44898. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  44899. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  44900. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  44901. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44902. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44903. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44904. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44905. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  44906. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  44907. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44908. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  44909. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44910. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  44911. /** @hidden */
  44912. export var pbrPixelShader: {
  44913. name: string;
  44914. shader: string;
  44915. };
  44916. }
  44917. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  44918. /** @hidden */
  44919. export var pbrVertexDeclaration: {
  44920. name: string;
  44921. shader: string;
  44922. };
  44923. }
  44924. declare module "babylonjs/Shaders/pbr.vertex" {
  44925. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  44926. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  44927. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44928. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44929. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44930. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  44931. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  44932. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44933. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44934. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44935. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44936. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  44937. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  44938. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  44939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  44940. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44941. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44942. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  44943. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44944. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44945. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44946. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  44947. /** @hidden */
  44948. export var pbrVertexShader: {
  44949. name: string;
  44950. shader: string;
  44951. };
  44952. }
  44953. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  44954. import { IAnimatable } from "babylonjs/Misc/tools";
  44955. import { Nullable } from "babylonjs/types";
  44956. import { Scene } from "babylonjs/scene";
  44957. import { Matrix, Color3 } from "babylonjs/Maths/math";
  44958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44960. import { Mesh } from "babylonjs/Meshes/mesh";
  44961. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  44962. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  44963. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  44964. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  44965. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44966. import { Material } from "babylonjs/Materials/material";
  44967. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44969. import "babylonjs/Shaders/pbr.fragment";
  44970. import "babylonjs/Shaders/pbr.vertex";
  44971. /**
  44972. * The Physically based material base class of BJS.
  44973. *
  44974. * This offers the main features of a standard PBR material.
  44975. * For more information, please refer to the documentation :
  44976. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44977. */
  44978. export abstract class PBRBaseMaterial extends PushMaterial {
  44979. /**
  44980. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44981. */
  44982. static readonly PBRMATERIAL_OPAQUE: number;
  44983. /**
  44984. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44985. */
  44986. static readonly PBRMATERIAL_ALPHATEST: number;
  44987. /**
  44988. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44989. */
  44990. static readonly PBRMATERIAL_ALPHABLEND: number;
  44991. /**
  44992. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44993. * They are also discarded below the alpha cutoff threshold to improve performances.
  44994. */
  44995. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44996. /**
  44997. * Defines the default value of how much AO map is occluding the analytical lights
  44998. * (point spot...).
  44999. */
  45000. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45001. /**
  45002. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45003. */
  45004. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45005. /**
  45006. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45007. * to enhance interoperability with other engines.
  45008. */
  45009. static readonly LIGHTFALLOFF_GLTF: number;
  45010. /**
  45011. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45012. * to enhance interoperability with other materials.
  45013. */
  45014. static readonly LIGHTFALLOFF_STANDARD: number;
  45015. /**
  45016. * Intensity of the direct lights e.g. the four lights available in your scene.
  45017. * This impacts both the direct diffuse and specular highlights.
  45018. */
  45019. protected _directIntensity: number;
  45020. /**
  45021. * Intensity of the emissive part of the material.
  45022. * This helps controlling the emissive effect without modifying the emissive color.
  45023. */
  45024. protected _emissiveIntensity: number;
  45025. /**
  45026. * Intensity of the environment e.g. how much the environment will light the object
  45027. * either through harmonics for rough material or through the refelction for shiny ones.
  45028. */
  45029. protected _environmentIntensity: number;
  45030. /**
  45031. * This is a special control allowing the reduction of the specular highlights coming from the
  45032. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45033. */
  45034. protected _specularIntensity: number;
  45035. /**
  45036. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45037. */
  45038. private _lightingInfos;
  45039. /**
  45040. * Debug Control allowing disabling the bump map on this material.
  45041. */
  45042. protected _disableBumpMap: boolean;
  45043. /**
  45044. * AKA Diffuse Texture in standard nomenclature.
  45045. */
  45046. protected _albedoTexture: BaseTexture;
  45047. /**
  45048. * AKA Occlusion Texture in other nomenclature.
  45049. */
  45050. protected _ambientTexture: BaseTexture;
  45051. /**
  45052. * AKA Occlusion Texture Intensity in other nomenclature.
  45053. */
  45054. protected _ambientTextureStrength: number;
  45055. /**
  45056. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45057. * 1 means it completely occludes it
  45058. * 0 mean it has no impact
  45059. */
  45060. protected _ambientTextureImpactOnAnalyticalLights: number;
  45061. /**
  45062. * Stores the alpha values in a texture.
  45063. */
  45064. protected _opacityTexture: BaseTexture;
  45065. /**
  45066. * Stores the reflection values in a texture.
  45067. */
  45068. protected _reflectionTexture: BaseTexture;
  45069. /**
  45070. * Stores the refraction values in a texture.
  45071. */
  45072. protected _refractionTexture: BaseTexture;
  45073. /**
  45074. * Stores the emissive values in a texture.
  45075. */
  45076. protected _emissiveTexture: BaseTexture;
  45077. /**
  45078. * AKA Specular texture in other nomenclature.
  45079. */
  45080. protected _reflectivityTexture: BaseTexture;
  45081. /**
  45082. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45083. */
  45084. protected _metallicTexture: BaseTexture;
  45085. /**
  45086. * Specifies the metallic scalar of the metallic/roughness workflow.
  45087. * Can also be used to scale the metalness values of the metallic texture.
  45088. */
  45089. protected _metallic: Nullable<number>;
  45090. /**
  45091. * Specifies the roughness scalar of the metallic/roughness workflow.
  45092. * Can also be used to scale the roughness values of the metallic texture.
  45093. */
  45094. protected _roughness: Nullable<number>;
  45095. /**
  45096. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45097. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45098. */
  45099. protected _microSurfaceTexture: BaseTexture;
  45100. /**
  45101. * Stores surface normal data used to displace a mesh in a texture.
  45102. */
  45103. protected _bumpTexture: BaseTexture;
  45104. /**
  45105. * Stores the pre-calculated light information of a mesh in a texture.
  45106. */
  45107. protected _lightmapTexture: BaseTexture;
  45108. /**
  45109. * The color of a material in ambient lighting.
  45110. */
  45111. protected _ambientColor: Color3;
  45112. /**
  45113. * AKA Diffuse Color in other nomenclature.
  45114. */
  45115. protected _albedoColor: Color3;
  45116. /**
  45117. * AKA Specular Color in other nomenclature.
  45118. */
  45119. protected _reflectivityColor: Color3;
  45120. /**
  45121. * The color applied when light is reflected from a material.
  45122. */
  45123. protected _reflectionColor: Color3;
  45124. /**
  45125. * The color applied when light is emitted from a material.
  45126. */
  45127. protected _emissiveColor: Color3;
  45128. /**
  45129. * AKA Glossiness in other nomenclature.
  45130. */
  45131. protected _microSurface: number;
  45132. /**
  45133. * source material index of refraction (IOR)' / 'destination material IOR.
  45134. */
  45135. protected _indexOfRefraction: number;
  45136. /**
  45137. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45138. */
  45139. protected _invertRefractionY: boolean;
  45140. /**
  45141. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45142. * Materials half opaque for instance using refraction could benefit from this control.
  45143. */
  45144. protected _linkRefractionWithTransparency: boolean;
  45145. /**
  45146. * Specifies that the material will use the light map as a show map.
  45147. */
  45148. protected _useLightmapAsShadowmap: boolean;
  45149. /**
  45150. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45151. * makes the reflect vector face the model (under horizon).
  45152. */
  45153. protected _useHorizonOcclusion: boolean;
  45154. /**
  45155. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45156. * too much the area relying on ambient texture to define their ambient occlusion.
  45157. */
  45158. protected _useRadianceOcclusion: boolean;
  45159. /**
  45160. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45161. */
  45162. protected _useAlphaFromAlbedoTexture: boolean;
  45163. /**
  45164. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45165. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45166. */
  45167. protected _useSpecularOverAlpha: boolean;
  45168. /**
  45169. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45170. */
  45171. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45172. /**
  45173. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45174. */
  45175. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45176. /**
  45177. * Specifies if the metallic texture contains the roughness information in its green channel.
  45178. */
  45179. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45180. /**
  45181. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45182. */
  45183. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45184. /**
  45185. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45186. */
  45187. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45188. /**
  45189. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45190. */
  45191. protected _useAmbientInGrayScale: boolean;
  45192. /**
  45193. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45194. * The material will try to infer what glossiness each pixel should be.
  45195. */
  45196. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45197. /**
  45198. * Defines the falloff type used in this material.
  45199. * It by default is Physical.
  45200. */
  45201. protected _lightFalloff: number;
  45202. /**
  45203. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45204. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45205. */
  45206. protected _useRadianceOverAlpha: boolean;
  45207. /**
  45208. * Allows using an object space normal map (instead of tangent space).
  45209. */
  45210. protected _useObjectSpaceNormalMap: boolean;
  45211. /**
  45212. * Allows using the bump map in parallax mode.
  45213. */
  45214. protected _useParallax: boolean;
  45215. /**
  45216. * Allows using the bump map in parallax occlusion mode.
  45217. */
  45218. protected _useParallaxOcclusion: boolean;
  45219. /**
  45220. * Controls the scale bias of the parallax mode.
  45221. */
  45222. protected _parallaxScaleBias: number;
  45223. /**
  45224. * If sets to true, disables all the lights affecting the material.
  45225. */
  45226. protected _disableLighting: boolean;
  45227. /**
  45228. * Number of Simultaneous lights allowed on the material.
  45229. */
  45230. protected _maxSimultaneousLights: number;
  45231. /**
  45232. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45233. */
  45234. protected _invertNormalMapX: boolean;
  45235. /**
  45236. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45237. */
  45238. protected _invertNormalMapY: boolean;
  45239. /**
  45240. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45241. */
  45242. protected _twoSidedLighting: boolean;
  45243. /**
  45244. * Defines the alpha limits in alpha test mode.
  45245. */
  45246. protected _alphaCutOff: number;
  45247. /**
  45248. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45249. */
  45250. protected _forceAlphaTest: boolean;
  45251. /**
  45252. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45253. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45254. */
  45255. protected _useAlphaFresnel: boolean;
  45256. /**
  45257. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45258. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45259. */
  45260. protected _useLinearAlphaFresnel: boolean;
  45261. /**
  45262. * The transparency mode of the material.
  45263. */
  45264. protected _transparencyMode: Nullable<number>;
  45265. /**
  45266. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45267. * from cos thetav and roughness:
  45268. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45269. */
  45270. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45271. /**
  45272. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45273. */
  45274. protected _forceIrradianceInFragment: boolean;
  45275. /**
  45276. * Force normal to face away from face.
  45277. */
  45278. protected _forceNormalForward: boolean;
  45279. /**
  45280. * Enables specular anti aliasing in the PBR shader.
  45281. * It will both interacts on the Geometry for analytical and IBL lighting.
  45282. * It also prefilter the roughness map based on the bump values.
  45283. */
  45284. protected _enableSpecularAntiAliasing: boolean;
  45285. /**
  45286. * Default configuration related to image processing available in the PBR Material.
  45287. */
  45288. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45289. /**
  45290. * Keep track of the image processing observer to allow dispose and replace.
  45291. */
  45292. private _imageProcessingObserver;
  45293. /**
  45294. * Attaches a new image processing configuration to the PBR Material.
  45295. * @param configuration
  45296. */
  45297. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45298. /**
  45299. * Stores the available render targets.
  45300. */
  45301. private _renderTargets;
  45302. /**
  45303. * Sets the global ambient color for the material used in lighting calculations.
  45304. */
  45305. private _globalAmbientColor;
  45306. /**
  45307. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45308. */
  45309. private _useLogarithmicDepth;
  45310. /**
  45311. * If set to true, no lighting calculations will be applied.
  45312. */
  45313. private _unlit;
  45314. private _debugMode;
  45315. /**
  45316. * @hidden
  45317. * This is reserved for the inspector.
  45318. * Defines the material debug mode.
  45319. * It helps seeing only some components of the material while troubleshooting.
  45320. */
  45321. debugMode: number;
  45322. /**
  45323. * @hidden
  45324. * This is reserved for the inspector.
  45325. * Specify from where on screen the debug mode should start.
  45326. * The value goes from -1 (full screen) to 1 (not visible)
  45327. * It helps with side by side comparison against the final render
  45328. * This defaults to -1
  45329. */
  45330. private debugLimit;
  45331. /**
  45332. * @hidden
  45333. * This is reserved for the inspector.
  45334. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45335. * You can use the factor to better multiply the final value.
  45336. */
  45337. private debugFactor;
  45338. /**
  45339. * Defines the clear coat layer parameters for the material.
  45340. */
  45341. readonly clearCoat: PBRClearCoatConfiguration;
  45342. /**
  45343. * Defines the anisotropic parameters for the material.
  45344. */
  45345. readonly anisotropy: PBRAnisotropicConfiguration;
  45346. /**
  45347. * Defines the BRDF parameters for the material.
  45348. */
  45349. readonly brdf: PBRBRDFConfiguration;
  45350. /**
  45351. * Defines the Sheen parameters for the material.
  45352. */
  45353. readonly sheen: PBRSheenConfiguration;
  45354. /**
  45355. * Instantiates a new PBRMaterial instance.
  45356. *
  45357. * @param name The material name
  45358. * @param scene The scene the material will be use in.
  45359. */
  45360. constructor(name: string, scene: Scene);
  45361. /**
  45362. * Gets a boolean indicating that current material needs to register RTT
  45363. */
  45364. readonly hasRenderTargetTextures: boolean;
  45365. /**
  45366. * Gets the name of the material class.
  45367. */
  45368. getClassName(): string;
  45369. /**
  45370. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45371. */
  45372. /**
  45373. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45374. */
  45375. useLogarithmicDepth: boolean;
  45376. /**
  45377. * Gets the current transparency mode.
  45378. */
  45379. /**
  45380. * Sets the transparency mode of the material.
  45381. *
  45382. * | Value | Type | Description |
  45383. * | ----- | ----------------------------------- | ----------- |
  45384. * | 0 | OPAQUE | |
  45385. * | 1 | ALPHATEST | |
  45386. * | 2 | ALPHABLEND | |
  45387. * | 3 | ALPHATESTANDBLEND | |
  45388. *
  45389. */
  45390. transparencyMode: Nullable<number>;
  45391. /**
  45392. * Returns true if alpha blending should be disabled.
  45393. */
  45394. private readonly _disableAlphaBlending;
  45395. /**
  45396. * Specifies whether or not this material should be rendered in alpha blend mode.
  45397. */
  45398. needAlphaBlending(): boolean;
  45399. /**
  45400. * Specifies if the mesh will require alpha blending.
  45401. * @param mesh - BJS mesh.
  45402. */
  45403. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45404. /**
  45405. * Specifies whether or not this material should be rendered in alpha test mode.
  45406. */
  45407. needAlphaTesting(): boolean;
  45408. /**
  45409. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45410. */
  45411. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45412. /**
  45413. * Gets the texture used for the alpha test.
  45414. */
  45415. getAlphaTestTexture(): BaseTexture;
  45416. /**
  45417. * Specifies that the submesh is ready to be used.
  45418. * @param mesh - BJS mesh.
  45419. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45420. * @param useInstances - Specifies that instances should be used.
  45421. * @returns - boolean indicating that the submesh is ready or not.
  45422. */
  45423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45424. /**
  45425. * Specifies if the material uses metallic roughness workflow.
  45426. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45427. */
  45428. isMetallicWorkflow(): boolean;
  45429. private _prepareEffect;
  45430. private _prepareDefines;
  45431. /**
  45432. * Force shader compilation
  45433. */
  45434. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45435. clipPlane: boolean;
  45436. }>): void;
  45437. /**
  45438. * Initializes the uniform buffer layout for the shader.
  45439. */
  45440. buildUniformLayout(): void;
  45441. /**
  45442. * Unbinds the textures.
  45443. */
  45444. unbind(): void;
  45445. /**
  45446. * Binds the submesh data.
  45447. * @param world - The world matrix.
  45448. * @param mesh - The BJS mesh.
  45449. * @param subMesh - A submesh of the BJS mesh.
  45450. */
  45451. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45452. /**
  45453. * Returns the animatable textures.
  45454. * @returns - Array of animatable textures.
  45455. */
  45456. getAnimatables(): IAnimatable[];
  45457. /**
  45458. * Returns the texture used for reflections.
  45459. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45460. */
  45461. private _getReflectionTexture;
  45462. /**
  45463. * Returns the texture used for refraction or null if none is used.
  45464. * @returns - Refection texture if present. If no refraction texture and refraction
  45465. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45466. */
  45467. private _getRefractionTexture;
  45468. /**
  45469. * Returns an array of the actively used textures.
  45470. * @returns - Array of BaseTextures
  45471. */
  45472. getActiveTextures(): BaseTexture[];
  45473. /**
  45474. * Checks to see if a texture is used in the material.
  45475. * @param texture - Base texture to use.
  45476. * @returns - Boolean specifying if a texture is used in the material.
  45477. */
  45478. hasTexture(texture: BaseTexture): boolean;
  45479. /**
  45480. * Disposes the resources of the material.
  45481. * @param forceDisposeEffect - Forces the disposal of effects.
  45482. * @param forceDisposeTextures - Forces the disposal of all textures.
  45483. */
  45484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45485. }
  45486. }
  45487. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45488. import { Nullable } from "babylonjs/types";
  45489. import { Scene } from "babylonjs/scene";
  45490. import { Color3 } from "babylonjs/Maths/math";
  45491. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45492. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45493. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45494. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45495. /**
  45496. * The Physically based material of BJS.
  45497. *
  45498. * This offers the main features of a standard PBR material.
  45499. * For more information, please refer to the documentation :
  45500. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45501. */
  45502. export class PBRMaterial extends PBRBaseMaterial {
  45503. /**
  45504. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45505. */
  45506. static readonly PBRMATERIAL_OPAQUE: number;
  45507. /**
  45508. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45509. */
  45510. static readonly PBRMATERIAL_ALPHATEST: number;
  45511. /**
  45512. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45513. */
  45514. static readonly PBRMATERIAL_ALPHABLEND: number;
  45515. /**
  45516. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45517. * They are also discarded below the alpha cutoff threshold to improve performances.
  45518. */
  45519. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45520. /**
  45521. * Defines the default value of how much AO map is occluding the analytical lights
  45522. * (point spot...).
  45523. */
  45524. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45525. /**
  45526. * Intensity of the direct lights e.g. the four lights available in your scene.
  45527. * This impacts both the direct diffuse and specular highlights.
  45528. */
  45529. directIntensity: number;
  45530. /**
  45531. * Intensity of the emissive part of the material.
  45532. * This helps controlling the emissive effect without modifying the emissive color.
  45533. */
  45534. emissiveIntensity: number;
  45535. /**
  45536. * Intensity of the environment e.g. how much the environment will light the object
  45537. * either through harmonics for rough material or through the refelction for shiny ones.
  45538. */
  45539. environmentIntensity: number;
  45540. /**
  45541. * This is a special control allowing the reduction of the specular highlights coming from the
  45542. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45543. */
  45544. specularIntensity: number;
  45545. /**
  45546. * Debug Control allowing disabling the bump map on this material.
  45547. */
  45548. disableBumpMap: boolean;
  45549. /**
  45550. * AKA Diffuse Texture in standard nomenclature.
  45551. */
  45552. albedoTexture: BaseTexture;
  45553. /**
  45554. * AKA Occlusion Texture in other nomenclature.
  45555. */
  45556. ambientTexture: BaseTexture;
  45557. /**
  45558. * AKA Occlusion Texture Intensity in other nomenclature.
  45559. */
  45560. ambientTextureStrength: number;
  45561. /**
  45562. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45563. * 1 means it completely occludes it
  45564. * 0 mean it has no impact
  45565. */
  45566. ambientTextureImpactOnAnalyticalLights: number;
  45567. /**
  45568. * Stores the alpha values in a texture.
  45569. */
  45570. opacityTexture: BaseTexture;
  45571. /**
  45572. * Stores the reflection values in a texture.
  45573. */
  45574. reflectionTexture: Nullable<BaseTexture>;
  45575. /**
  45576. * Stores the emissive values in a texture.
  45577. */
  45578. emissiveTexture: BaseTexture;
  45579. /**
  45580. * AKA Specular texture in other nomenclature.
  45581. */
  45582. reflectivityTexture: BaseTexture;
  45583. /**
  45584. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45585. */
  45586. metallicTexture: BaseTexture;
  45587. /**
  45588. * Specifies the metallic scalar of the metallic/roughness workflow.
  45589. * Can also be used to scale the metalness values of the metallic texture.
  45590. */
  45591. metallic: Nullable<number>;
  45592. /**
  45593. * Specifies the roughness scalar of the metallic/roughness workflow.
  45594. * Can also be used to scale the roughness values of the metallic texture.
  45595. */
  45596. roughness: Nullable<number>;
  45597. /**
  45598. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45599. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45600. */
  45601. microSurfaceTexture: BaseTexture;
  45602. /**
  45603. * Stores surface normal data used to displace a mesh in a texture.
  45604. */
  45605. bumpTexture: BaseTexture;
  45606. /**
  45607. * Stores the pre-calculated light information of a mesh in a texture.
  45608. */
  45609. lightmapTexture: BaseTexture;
  45610. /**
  45611. * Stores the refracted light information in a texture.
  45612. */
  45613. refractionTexture: BaseTexture;
  45614. /**
  45615. * The color of a material in ambient lighting.
  45616. */
  45617. ambientColor: Color3;
  45618. /**
  45619. * AKA Diffuse Color in other nomenclature.
  45620. */
  45621. albedoColor: Color3;
  45622. /**
  45623. * AKA Specular Color in other nomenclature.
  45624. */
  45625. reflectivityColor: Color3;
  45626. /**
  45627. * The color reflected from the material.
  45628. */
  45629. reflectionColor: Color3;
  45630. /**
  45631. * The color emitted from the material.
  45632. */
  45633. emissiveColor: Color3;
  45634. /**
  45635. * AKA Glossiness in other nomenclature.
  45636. */
  45637. microSurface: number;
  45638. /**
  45639. * source material index of refraction (IOR)' / 'destination material IOR.
  45640. */
  45641. indexOfRefraction: number;
  45642. /**
  45643. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45644. */
  45645. invertRefractionY: boolean;
  45646. /**
  45647. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45648. * Materials half opaque for instance using refraction could benefit from this control.
  45649. */
  45650. linkRefractionWithTransparency: boolean;
  45651. /**
  45652. * If true, the light map contains occlusion information instead of lighting info.
  45653. */
  45654. useLightmapAsShadowmap: boolean;
  45655. /**
  45656. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45657. */
  45658. useAlphaFromAlbedoTexture: boolean;
  45659. /**
  45660. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45661. */
  45662. forceAlphaTest: boolean;
  45663. /**
  45664. * Defines the alpha limits in alpha test mode.
  45665. */
  45666. alphaCutOff: number;
  45667. /**
  45668. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45669. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45670. */
  45671. useSpecularOverAlpha: boolean;
  45672. /**
  45673. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45674. */
  45675. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45676. /**
  45677. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45678. */
  45679. useRoughnessFromMetallicTextureAlpha: boolean;
  45680. /**
  45681. * Specifies if the metallic texture contains the roughness information in its green channel.
  45682. */
  45683. useRoughnessFromMetallicTextureGreen: boolean;
  45684. /**
  45685. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45686. */
  45687. useMetallnessFromMetallicTextureBlue: boolean;
  45688. /**
  45689. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45690. */
  45691. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45692. /**
  45693. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45694. */
  45695. useAmbientInGrayScale: boolean;
  45696. /**
  45697. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45698. * The material will try to infer what glossiness each pixel should be.
  45699. */
  45700. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45701. /**
  45702. * BJS is using an harcoded light falloff based on a manually sets up range.
  45703. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45704. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45705. */
  45706. /**
  45707. * BJS is using an harcoded light falloff based on a manually sets up range.
  45708. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45709. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45710. */
  45711. usePhysicalLightFalloff: boolean;
  45712. /**
  45713. * In order to support the falloff compatibility with gltf, a special mode has been added
  45714. * to reproduce the gltf light falloff.
  45715. */
  45716. /**
  45717. * In order to support the falloff compatibility with gltf, a special mode has been added
  45718. * to reproduce the gltf light falloff.
  45719. */
  45720. useGLTFLightFalloff: boolean;
  45721. /**
  45722. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45723. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45724. */
  45725. useRadianceOverAlpha: boolean;
  45726. /**
  45727. * Allows using an object space normal map (instead of tangent space).
  45728. */
  45729. useObjectSpaceNormalMap: boolean;
  45730. /**
  45731. * Allows using the bump map in parallax mode.
  45732. */
  45733. useParallax: boolean;
  45734. /**
  45735. * Allows using the bump map in parallax occlusion mode.
  45736. */
  45737. useParallaxOcclusion: boolean;
  45738. /**
  45739. * Controls the scale bias of the parallax mode.
  45740. */
  45741. parallaxScaleBias: number;
  45742. /**
  45743. * If sets to true, disables all the lights affecting the material.
  45744. */
  45745. disableLighting: boolean;
  45746. /**
  45747. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45748. */
  45749. forceIrradianceInFragment: boolean;
  45750. /**
  45751. * Number of Simultaneous lights allowed on the material.
  45752. */
  45753. maxSimultaneousLights: number;
  45754. /**
  45755. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45756. */
  45757. invertNormalMapX: boolean;
  45758. /**
  45759. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45760. */
  45761. invertNormalMapY: boolean;
  45762. /**
  45763. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45764. */
  45765. twoSidedLighting: boolean;
  45766. /**
  45767. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45768. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45769. */
  45770. useAlphaFresnel: boolean;
  45771. /**
  45772. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45773. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45774. */
  45775. useLinearAlphaFresnel: boolean;
  45776. /**
  45777. * Let user defines the brdf lookup texture used for IBL.
  45778. * A default 8bit version is embedded but you could point at :
  45779. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45780. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45781. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45782. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45783. */
  45784. environmentBRDFTexture: Nullable<BaseTexture>;
  45785. /**
  45786. * Force normal to face away from face.
  45787. */
  45788. forceNormalForward: boolean;
  45789. /**
  45790. * Enables specular anti aliasing in the PBR shader.
  45791. * It will both interacts on the Geometry for analytical and IBL lighting.
  45792. * It also prefilter the roughness map based on the bump values.
  45793. */
  45794. enableSpecularAntiAliasing: boolean;
  45795. /**
  45796. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45797. * makes the reflect vector face the model (under horizon).
  45798. */
  45799. useHorizonOcclusion: boolean;
  45800. /**
  45801. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45802. * too much the area relying on ambient texture to define their ambient occlusion.
  45803. */
  45804. useRadianceOcclusion: boolean;
  45805. /**
  45806. * If set to true, no lighting calculations will be applied.
  45807. */
  45808. unlit: boolean;
  45809. /**
  45810. * Gets the image processing configuration used either in this material.
  45811. */
  45812. /**
  45813. * Sets the Default image processing configuration used either in the this material.
  45814. *
  45815. * If sets to null, the scene one is in use.
  45816. */
  45817. imageProcessingConfiguration: ImageProcessingConfiguration;
  45818. /**
  45819. * Gets wether the color curves effect is enabled.
  45820. */
  45821. /**
  45822. * Sets wether the color curves effect is enabled.
  45823. */
  45824. cameraColorCurvesEnabled: boolean;
  45825. /**
  45826. * Gets wether the color grading effect is enabled.
  45827. */
  45828. /**
  45829. * Gets wether the color grading effect is enabled.
  45830. */
  45831. cameraColorGradingEnabled: boolean;
  45832. /**
  45833. * Gets wether tonemapping is enabled or not.
  45834. */
  45835. /**
  45836. * Sets wether tonemapping is enabled or not
  45837. */
  45838. cameraToneMappingEnabled: boolean;
  45839. /**
  45840. * The camera exposure used on this material.
  45841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45842. * This corresponds to a photographic exposure.
  45843. */
  45844. /**
  45845. * The camera exposure used on this material.
  45846. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45847. * This corresponds to a photographic exposure.
  45848. */
  45849. cameraExposure: number;
  45850. /**
  45851. * Gets The camera contrast used on this material.
  45852. */
  45853. /**
  45854. * Sets The camera contrast used on this material.
  45855. */
  45856. cameraContrast: number;
  45857. /**
  45858. * Gets the Color Grading 2D Lookup Texture.
  45859. */
  45860. /**
  45861. * Sets the Color Grading 2D Lookup Texture.
  45862. */
  45863. cameraColorGradingTexture: Nullable<BaseTexture>;
  45864. /**
  45865. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45866. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45867. * 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;
  45868. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45869. */
  45870. /**
  45871. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45872. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45873. * 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;
  45874. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45875. */
  45876. cameraColorCurves: Nullable<ColorCurves>;
  45877. /**
  45878. * Instantiates a new PBRMaterial instance.
  45879. *
  45880. * @param name The material name
  45881. * @param scene The scene the material will be use in.
  45882. */
  45883. constructor(name: string, scene: Scene);
  45884. /**
  45885. * Returns the name of this material class.
  45886. */
  45887. getClassName(): string;
  45888. /**
  45889. * Makes a duplicate of the current material.
  45890. * @param name - name to use for the new material.
  45891. */
  45892. clone(name: string): PBRMaterial;
  45893. /**
  45894. * Serializes this PBR Material.
  45895. * @returns - An object with the serialized material.
  45896. */
  45897. serialize(): any;
  45898. /**
  45899. * Parses a PBR Material from a serialized object.
  45900. * @param source - Serialized object.
  45901. * @param scene - BJS scene instance.
  45902. * @param rootUrl - url for the scene object
  45903. * @returns - PBRMaterial
  45904. */
  45905. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45906. }
  45907. }
  45908. declare module "babylonjs/Misc/dds" {
  45909. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45910. import { Engine } from "babylonjs/Engines/engine";
  45911. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45912. import { Nullable } from "babylonjs/types";
  45913. import { Scene } from "babylonjs/scene";
  45914. /**
  45915. * Direct draw surface info
  45916. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45917. */
  45918. export interface DDSInfo {
  45919. /**
  45920. * Width of the texture
  45921. */
  45922. width: number;
  45923. /**
  45924. * Width of the texture
  45925. */
  45926. height: number;
  45927. /**
  45928. * Number of Mipmaps for the texture
  45929. * @see https://en.wikipedia.org/wiki/Mipmap
  45930. */
  45931. mipmapCount: number;
  45932. /**
  45933. * If the textures format is a known fourCC format
  45934. * @see https://www.fourcc.org/
  45935. */
  45936. isFourCC: boolean;
  45937. /**
  45938. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45939. */
  45940. isRGB: boolean;
  45941. /**
  45942. * If the texture is a lumincance format
  45943. */
  45944. isLuminance: boolean;
  45945. /**
  45946. * If this is a cube texture
  45947. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45948. */
  45949. isCube: boolean;
  45950. /**
  45951. * If the texture is a compressed format eg. FOURCC_DXT1
  45952. */
  45953. isCompressed: boolean;
  45954. /**
  45955. * The dxgiFormat of the texture
  45956. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45957. */
  45958. dxgiFormat: number;
  45959. /**
  45960. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45961. */
  45962. textureType: number;
  45963. /**
  45964. * Sphericle polynomial created for the dds texture
  45965. */
  45966. sphericalPolynomial?: SphericalPolynomial;
  45967. }
  45968. /**
  45969. * Class used to provide DDS decompression tools
  45970. */
  45971. export class DDSTools {
  45972. /**
  45973. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45974. */
  45975. static StoreLODInAlphaChannel: boolean;
  45976. /**
  45977. * Gets DDS information from an array buffer
  45978. * @param arrayBuffer defines the array buffer to read data from
  45979. * @returns the DDS information
  45980. */
  45981. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45982. private static _FloatView;
  45983. private static _Int32View;
  45984. private static _ToHalfFloat;
  45985. private static _FromHalfFloat;
  45986. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45987. private static _GetHalfFloatRGBAArrayBuffer;
  45988. private static _GetFloatRGBAArrayBuffer;
  45989. private static _GetFloatAsUIntRGBAArrayBuffer;
  45990. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45991. private static _GetRGBAArrayBuffer;
  45992. private static _ExtractLongWordOrder;
  45993. private static _GetRGBArrayBuffer;
  45994. private static _GetLuminanceArrayBuffer;
  45995. /**
  45996. * Uploads DDS Levels to a Babylon Texture
  45997. * @hidden
  45998. */
  45999. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46000. }
  46001. module "babylonjs/Engines/engine" {
  46002. interface Engine {
  46003. /**
  46004. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46005. * @param rootUrl defines the url where the file to load is located
  46006. * @param scene defines the current scene
  46007. * @param lodScale defines scale to apply to the mip map selection
  46008. * @param lodOffset defines offset to apply to the mip map selection
  46009. * @param onLoad defines an optional callback raised when the texture is loaded
  46010. * @param onError defines an optional callback raised if there is an issue to load the texture
  46011. * @param format defines the format of the data
  46012. * @param forcedExtension defines the extension to use to pick the right loader
  46013. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46014. * @returns the cube texture as an InternalTexture
  46015. */
  46016. 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;
  46017. }
  46018. }
  46019. }
  46020. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46021. import { Nullable } from "babylonjs/types";
  46022. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46023. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46024. /**
  46025. * Implementation of the DDS Texture Loader.
  46026. * @hidden
  46027. */
  46028. export class _DDSTextureLoader implements IInternalTextureLoader {
  46029. /**
  46030. * Defines wether the loader supports cascade loading the different faces.
  46031. */
  46032. readonly supportCascades: boolean;
  46033. /**
  46034. * This returns if the loader support the current file information.
  46035. * @param extension defines the file extension of the file being loaded
  46036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46037. * @param fallback defines the fallback internal texture if any
  46038. * @param isBase64 defines whether the texture is encoded as a base64
  46039. * @param isBuffer defines whether the texture data are stored as a buffer
  46040. * @returns true if the loader can load the specified file
  46041. */
  46042. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46043. /**
  46044. * Transform the url before loading if required.
  46045. * @param rootUrl the url of the texture
  46046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46047. * @returns the transformed texture
  46048. */
  46049. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46050. /**
  46051. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46052. * @param rootUrl the url of the texture
  46053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46054. * @returns the fallback texture
  46055. */
  46056. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46057. /**
  46058. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46059. * @param data contains the texture data
  46060. * @param texture defines the BabylonJS internal texture
  46061. * @param createPolynomials will be true if polynomials have been requested
  46062. * @param onLoad defines the callback to trigger once the texture is ready
  46063. * @param onError defines the callback to trigger in case of error
  46064. */
  46065. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46066. /**
  46067. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46068. * @param data contains the texture data
  46069. * @param texture defines the BabylonJS internal texture
  46070. * @param callback defines the method to call once ready to upload
  46071. */
  46072. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46073. }
  46074. }
  46075. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46076. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46077. /** @hidden */
  46078. export var rgbdEncodePixelShader: {
  46079. name: string;
  46080. shader: string;
  46081. };
  46082. }
  46083. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46085. /** @hidden */
  46086. export var rgbdDecodePixelShader: {
  46087. name: string;
  46088. shader: string;
  46089. };
  46090. }
  46091. declare module "babylonjs/Misc/environmentTextureTools" {
  46092. import { Nullable } from "babylonjs/types";
  46093. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46094. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46095. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46096. import "babylonjs/Shaders/rgbdEncode.fragment";
  46097. import "babylonjs/Shaders/rgbdDecode.fragment";
  46098. /**
  46099. * Raw texture data and descriptor sufficient for WebGL texture upload
  46100. */
  46101. export interface EnvironmentTextureInfo {
  46102. /**
  46103. * Version of the environment map
  46104. */
  46105. version: number;
  46106. /**
  46107. * Width of image
  46108. */
  46109. width: number;
  46110. /**
  46111. * Irradiance information stored in the file.
  46112. */
  46113. irradiance: any;
  46114. /**
  46115. * Specular information stored in the file.
  46116. */
  46117. specular: any;
  46118. }
  46119. /**
  46120. * Sets of helpers addressing the serialization and deserialization of environment texture
  46121. * stored in a BabylonJS env file.
  46122. * Those files are usually stored as .env files.
  46123. */
  46124. export class EnvironmentTextureTools {
  46125. /**
  46126. * Magic number identifying the env file.
  46127. */
  46128. private static _MagicBytes;
  46129. /**
  46130. * Gets the environment info from an env file.
  46131. * @param data The array buffer containing the .env bytes.
  46132. * @returns the environment file info (the json header) if successfully parsed.
  46133. */
  46134. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46135. /**
  46136. * Creates an environment texture from a loaded cube texture.
  46137. * @param texture defines the cube texture to convert in env file
  46138. * @return a promise containing the environment data if succesfull.
  46139. */
  46140. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46141. /**
  46142. * Creates a JSON representation of the spherical data.
  46143. * @param texture defines the texture containing the polynomials
  46144. * @return the JSON representation of the spherical info
  46145. */
  46146. private static _CreateEnvTextureIrradiance;
  46147. /**
  46148. * Uploads the texture info contained in the env file to the GPU.
  46149. * @param texture defines the internal texture to upload to
  46150. * @param arrayBuffer defines the buffer cotaining the data to load
  46151. * @param info defines the texture info retrieved through the GetEnvInfo method
  46152. * @returns a promise
  46153. */
  46154. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46155. /**
  46156. * Uploads the levels of image data to the GPU.
  46157. * @param texture defines the internal texture to upload to
  46158. * @param imageData defines the array buffer views of image data [mipmap][face]
  46159. * @returns a promise
  46160. */
  46161. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46162. /**
  46163. * Uploads spherical polynomials information to the texture.
  46164. * @param texture defines the texture we are trying to upload the information to
  46165. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46166. */
  46167. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46168. /** @hidden */
  46169. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46170. }
  46171. }
  46172. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46173. import { Nullable } from "babylonjs/types";
  46174. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46175. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46176. /**
  46177. * Implementation of the ENV Texture Loader.
  46178. * @hidden
  46179. */
  46180. export class _ENVTextureLoader implements IInternalTextureLoader {
  46181. /**
  46182. * Defines wether the loader supports cascade loading the different faces.
  46183. */
  46184. readonly supportCascades: boolean;
  46185. /**
  46186. * This returns if the loader support the current file information.
  46187. * @param extension defines the file extension of the file being loaded
  46188. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46189. * @param fallback defines the fallback internal texture if any
  46190. * @param isBase64 defines whether the texture is encoded as a base64
  46191. * @param isBuffer defines whether the texture data are stored as a buffer
  46192. * @returns true if the loader can load the specified file
  46193. */
  46194. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46195. /**
  46196. * Transform the url before loading if required.
  46197. * @param rootUrl the url of the texture
  46198. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46199. * @returns the transformed texture
  46200. */
  46201. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46202. /**
  46203. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46204. * @param rootUrl the url of the texture
  46205. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46206. * @returns the fallback texture
  46207. */
  46208. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46209. /**
  46210. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46211. * @param data contains the texture data
  46212. * @param texture defines the BabylonJS internal texture
  46213. * @param createPolynomials will be true if polynomials have been requested
  46214. * @param onLoad defines the callback to trigger once the texture is ready
  46215. * @param onError defines the callback to trigger in case of error
  46216. */
  46217. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46218. /**
  46219. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46220. * @param data contains the texture data
  46221. * @param texture defines the BabylonJS internal texture
  46222. * @param callback defines the method to call once ready to upload
  46223. */
  46224. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46225. }
  46226. }
  46227. declare module "babylonjs/Misc/khronosTextureContainer" {
  46228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46229. /**
  46230. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46231. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46232. */
  46233. export class KhronosTextureContainer {
  46234. /** contents of the KTX container file */
  46235. arrayBuffer: any;
  46236. private static HEADER_LEN;
  46237. private static COMPRESSED_2D;
  46238. private static COMPRESSED_3D;
  46239. private static TEX_2D;
  46240. private static TEX_3D;
  46241. /**
  46242. * Gets the openGL type
  46243. */
  46244. glType: number;
  46245. /**
  46246. * Gets the openGL type size
  46247. */
  46248. glTypeSize: number;
  46249. /**
  46250. * Gets the openGL format
  46251. */
  46252. glFormat: number;
  46253. /**
  46254. * Gets the openGL internal format
  46255. */
  46256. glInternalFormat: number;
  46257. /**
  46258. * Gets the base internal format
  46259. */
  46260. glBaseInternalFormat: number;
  46261. /**
  46262. * Gets image width in pixel
  46263. */
  46264. pixelWidth: number;
  46265. /**
  46266. * Gets image height in pixel
  46267. */
  46268. pixelHeight: number;
  46269. /**
  46270. * Gets image depth in pixels
  46271. */
  46272. pixelDepth: number;
  46273. /**
  46274. * Gets the number of array elements
  46275. */
  46276. numberOfArrayElements: number;
  46277. /**
  46278. * Gets the number of faces
  46279. */
  46280. numberOfFaces: number;
  46281. /**
  46282. * Gets the number of mipmap levels
  46283. */
  46284. numberOfMipmapLevels: number;
  46285. /**
  46286. * Gets the bytes of key value data
  46287. */
  46288. bytesOfKeyValueData: number;
  46289. /**
  46290. * Gets the load type
  46291. */
  46292. loadType: number;
  46293. /**
  46294. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46295. */
  46296. isInvalid: boolean;
  46297. /**
  46298. * Creates a new KhronosTextureContainer
  46299. * @param arrayBuffer contents of the KTX container file
  46300. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46301. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46302. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46303. */
  46304. constructor(
  46305. /** contents of the KTX container file */
  46306. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46307. /**
  46308. * Uploads KTX content to a Babylon Texture.
  46309. * It is assumed that the texture has already been created & is currently bound
  46310. * @hidden
  46311. */
  46312. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46313. private _upload2DCompressedLevels;
  46314. }
  46315. }
  46316. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46317. import { Nullable } from "babylonjs/types";
  46318. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46319. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46320. /**
  46321. * Implementation of the KTX Texture Loader.
  46322. * @hidden
  46323. */
  46324. export class _KTXTextureLoader implements IInternalTextureLoader {
  46325. /**
  46326. * Defines wether the loader supports cascade loading the different faces.
  46327. */
  46328. readonly supportCascades: boolean;
  46329. /**
  46330. * This returns if the loader support the current file information.
  46331. * @param extension defines the file extension of the file being loaded
  46332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46333. * @param fallback defines the fallback internal texture if any
  46334. * @param isBase64 defines whether the texture is encoded as a base64
  46335. * @param isBuffer defines whether the texture data are stored as a buffer
  46336. * @returns true if the loader can load the specified file
  46337. */
  46338. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46339. /**
  46340. * Transform the url before loading if required.
  46341. * @param rootUrl the url of the texture
  46342. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46343. * @returns the transformed texture
  46344. */
  46345. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46346. /**
  46347. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46348. * @param rootUrl the url of the texture
  46349. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46350. * @returns the fallback texture
  46351. */
  46352. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46353. /**
  46354. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46355. * @param data contains the texture data
  46356. * @param texture defines the BabylonJS internal texture
  46357. * @param createPolynomials will be true if polynomials have been requested
  46358. * @param onLoad defines the callback to trigger once the texture is ready
  46359. * @param onError defines the callback to trigger in case of error
  46360. */
  46361. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46362. /**
  46363. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46364. * @param data contains the texture data
  46365. * @param texture defines the BabylonJS internal texture
  46366. * @param callback defines the method to call once ready to upload
  46367. */
  46368. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46369. }
  46370. }
  46371. declare module "babylonjs/Helpers/sceneHelpers" {
  46372. import { Nullable } from "babylonjs/types";
  46373. import { Mesh } from "babylonjs/Meshes/mesh";
  46374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46375. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46376. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46377. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46378. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46379. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46380. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46381. import "babylonjs/Meshes/Builders/boxBuilder";
  46382. /** @hidden */
  46383. export var _forceSceneHelpersToBundle: boolean;
  46384. module "babylonjs/scene" {
  46385. interface Scene {
  46386. /**
  46387. * Creates a default light for the scene.
  46388. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46389. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46390. */
  46391. createDefaultLight(replace?: boolean): void;
  46392. /**
  46393. * Creates a default camera for the scene.
  46394. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46395. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46396. * @param replace has default false, when true replaces the active camera in the scene
  46397. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46398. */
  46399. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46400. /**
  46401. * Creates a default camera and a default light.
  46402. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46403. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46404. * @param replace has the default false, when true replaces the active camera/light in the scene
  46405. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46406. */
  46407. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46408. /**
  46409. * Creates a new sky box
  46410. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46411. * @param environmentTexture defines the texture to use as environment texture
  46412. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46413. * @param scale defines the overall scale of the skybox
  46414. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46415. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46416. * @returns a new mesh holding the sky box
  46417. */
  46418. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46419. /**
  46420. * Creates a new environment
  46421. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46422. * @param options defines the options you can use to configure the environment
  46423. * @returns the new EnvironmentHelper
  46424. */
  46425. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46426. /**
  46427. * Creates a new VREXperienceHelper
  46428. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46429. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46430. * @returns a new VREXperienceHelper
  46431. */
  46432. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46433. /**
  46434. * Creates a new XREXperienceHelper
  46435. * @see http://doc.babylonjs.com/how_to/webxr
  46436. * @returns a promise for a new XREXperienceHelper
  46437. */
  46438. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46439. }
  46440. }
  46441. }
  46442. declare module "babylonjs/Helpers/videoDome" {
  46443. import { Scene } from "babylonjs/scene";
  46444. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46445. import { Mesh } from "babylonjs/Meshes/mesh";
  46446. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46447. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46448. import "babylonjs/Meshes/Builders/sphereBuilder";
  46449. /**
  46450. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46451. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46452. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46453. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46454. */
  46455. export class VideoDome extends TransformNode {
  46456. /**
  46457. * Define the video source as a Monoscopic panoramic 360 video.
  46458. */
  46459. static readonly MODE_MONOSCOPIC: number;
  46460. /**
  46461. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46462. */
  46463. static readonly MODE_TOPBOTTOM: number;
  46464. /**
  46465. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46466. */
  46467. static readonly MODE_SIDEBYSIDE: number;
  46468. private _useDirectMapping;
  46469. /**
  46470. * The video texture being displayed on the sphere
  46471. */
  46472. protected _videoTexture: VideoTexture;
  46473. /**
  46474. * Gets the video texture being displayed on the sphere
  46475. */
  46476. readonly videoTexture: VideoTexture;
  46477. /**
  46478. * The skybox material
  46479. */
  46480. protected _material: BackgroundMaterial;
  46481. /**
  46482. * The surface used for the skybox
  46483. */
  46484. protected _mesh: Mesh;
  46485. /**
  46486. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46487. * Also see the options.resolution property.
  46488. */
  46489. fovMultiplier: number;
  46490. private _videoMode;
  46491. /**
  46492. * Gets or set the current video mode for the video. It can be:
  46493. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46494. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46495. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46496. */
  46497. videoMode: number;
  46498. /**
  46499. * Oberserver used in Stereoscopic VR Mode.
  46500. */
  46501. private _onBeforeCameraRenderObserver;
  46502. /**
  46503. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46504. * @param name Element's name, child elements will append suffixes for their own names.
  46505. * @param urlsOrVideo defines the url(s) or the video element to use
  46506. * @param options An object containing optional or exposed sub element properties
  46507. */
  46508. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46509. resolution?: number;
  46510. clickToPlay?: boolean;
  46511. autoPlay?: boolean;
  46512. loop?: boolean;
  46513. size?: number;
  46514. poster?: string;
  46515. useDirectMapping?: boolean;
  46516. }, scene: Scene);
  46517. private _changeVideoMode;
  46518. /**
  46519. * Releases resources associated with this node.
  46520. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46521. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46522. */
  46523. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46524. }
  46525. }
  46526. declare module "babylonjs/Helpers/index" {
  46527. export * from "babylonjs/Helpers/environmentHelper";
  46528. export * from "babylonjs/Helpers/photoDome";
  46529. export * from "babylonjs/Helpers/sceneHelpers";
  46530. export * from "babylonjs/Helpers/videoDome";
  46531. }
  46532. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46533. import { PerfCounter } from "babylonjs/Misc/tools";
  46534. import { IDisposable } from "babylonjs/scene";
  46535. import { Engine } from "babylonjs/Engines/engine";
  46536. /**
  46537. * This class can be used to get instrumentation data from a Babylon engine
  46538. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46539. */
  46540. export class EngineInstrumentation implements IDisposable {
  46541. /**
  46542. * Define the instrumented engine.
  46543. */
  46544. engine: Engine;
  46545. private _captureGPUFrameTime;
  46546. private _gpuFrameTimeToken;
  46547. private _gpuFrameTime;
  46548. private _captureShaderCompilationTime;
  46549. private _shaderCompilationTime;
  46550. private _onBeginFrameObserver;
  46551. private _onEndFrameObserver;
  46552. private _onBeforeShaderCompilationObserver;
  46553. private _onAfterShaderCompilationObserver;
  46554. /**
  46555. * Gets the perf counter used for GPU frame time
  46556. */
  46557. readonly gpuFrameTimeCounter: PerfCounter;
  46558. /**
  46559. * Gets the GPU frame time capture status
  46560. */
  46561. /**
  46562. * Enable or disable the GPU frame time capture
  46563. */
  46564. captureGPUFrameTime: boolean;
  46565. /**
  46566. * Gets the perf counter used for shader compilation time
  46567. */
  46568. readonly shaderCompilationTimeCounter: PerfCounter;
  46569. /**
  46570. * Gets the shader compilation time capture status
  46571. */
  46572. /**
  46573. * Enable or disable the shader compilation time capture
  46574. */
  46575. captureShaderCompilationTime: boolean;
  46576. /**
  46577. * Instantiates a new engine instrumentation.
  46578. * This class can be used to get instrumentation data from a Babylon engine
  46579. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46580. * @param engine Defines the engine to instrument
  46581. */
  46582. constructor(
  46583. /**
  46584. * Define the instrumented engine.
  46585. */
  46586. engine: Engine);
  46587. /**
  46588. * Dispose and release associated resources.
  46589. */
  46590. dispose(): void;
  46591. }
  46592. }
  46593. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46594. import { PerfCounter } from "babylonjs/Misc/tools";
  46595. import { Scene, IDisposable } from "babylonjs/scene";
  46596. /**
  46597. * This class can be used to get instrumentation data from a Babylon engine
  46598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46599. */
  46600. export class SceneInstrumentation implements IDisposable {
  46601. /**
  46602. * Defines the scene to instrument
  46603. */
  46604. scene: Scene;
  46605. private _captureActiveMeshesEvaluationTime;
  46606. private _activeMeshesEvaluationTime;
  46607. private _captureRenderTargetsRenderTime;
  46608. private _renderTargetsRenderTime;
  46609. private _captureFrameTime;
  46610. private _frameTime;
  46611. private _captureRenderTime;
  46612. private _renderTime;
  46613. private _captureInterFrameTime;
  46614. private _interFrameTime;
  46615. private _captureParticlesRenderTime;
  46616. private _particlesRenderTime;
  46617. private _captureSpritesRenderTime;
  46618. private _spritesRenderTime;
  46619. private _capturePhysicsTime;
  46620. private _physicsTime;
  46621. private _captureAnimationsTime;
  46622. private _animationsTime;
  46623. private _captureCameraRenderTime;
  46624. private _cameraRenderTime;
  46625. private _onBeforeActiveMeshesEvaluationObserver;
  46626. private _onAfterActiveMeshesEvaluationObserver;
  46627. private _onBeforeRenderTargetsRenderObserver;
  46628. private _onAfterRenderTargetsRenderObserver;
  46629. private _onAfterRenderObserver;
  46630. private _onBeforeDrawPhaseObserver;
  46631. private _onAfterDrawPhaseObserver;
  46632. private _onBeforeAnimationsObserver;
  46633. private _onBeforeParticlesRenderingObserver;
  46634. private _onAfterParticlesRenderingObserver;
  46635. private _onBeforeSpritesRenderingObserver;
  46636. private _onAfterSpritesRenderingObserver;
  46637. private _onBeforePhysicsObserver;
  46638. private _onAfterPhysicsObserver;
  46639. private _onAfterAnimationsObserver;
  46640. private _onBeforeCameraRenderObserver;
  46641. private _onAfterCameraRenderObserver;
  46642. /**
  46643. * Gets the perf counter used for active meshes evaluation time
  46644. */
  46645. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46646. /**
  46647. * Gets the active meshes evaluation time capture status
  46648. */
  46649. /**
  46650. * Enable or disable the active meshes evaluation time capture
  46651. */
  46652. captureActiveMeshesEvaluationTime: boolean;
  46653. /**
  46654. * Gets the perf counter used for render targets render time
  46655. */
  46656. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46657. /**
  46658. * Gets the render targets render time capture status
  46659. */
  46660. /**
  46661. * Enable or disable the render targets render time capture
  46662. */
  46663. captureRenderTargetsRenderTime: boolean;
  46664. /**
  46665. * Gets the perf counter used for particles render time
  46666. */
  46667. readonly particlesRenderTimeCounter: PerfCounter;
  46668. /**
  46669. * Gets the particles render time capture status
  46670. */
  46671. /**
  46672. * Enable or disable the particles render time capture
  46673. */
  46674. captureParticlesRenderTime: boolean;
  46675. /**
  46676. * Gets the perf counter used for sprites render time
  46677. */
  46678. readonly spritesRenderTimeCounter: PerfCounter;
  46679. /**
  46680. * Gets the sprites render time capture status
  46681. */
  46682. /**
  46683. * Enable or disable the sprites render time capture
  46684. */
  46685. captureSpritesRenderTime: boolean;
  46686. /**
  46687. * Gets the perf counter used for physics time
  46688. */
  46689. readonly physicsTimeCounter: PerfCounter;
  46690. /**
  46691. * Gets the physics time capture status
  46692. */
  46693. /**
  46694. * Enable or disable the physics time capture
  46695. */
  46696. capturePhysicsTime: boolean;
  46697. /**
  46698. * Gets the perf counter used for animations time
  46699. */
  46700. readonly animationsTimeCounter: PerfCounter;
  46701. /**
  46702. * Gets the animations time capture status
  46703. */
  46704. /**
  46705. * Enable or disable the animations time capture
  46706. */
  46707. captureAnimationsTime: boolean;
  46708. /**
  46709. * Gets the perf counter used for frame time capture
  46710. */
  46711. readonly frameTimeCounter: PerfCounter;
  46712. /**
  46713. * Gets the frame time capture status
  46714. */
  46715. /**
  46716. * Enable or disable the frame time capture
  46717. */
  46718. captureFrameTime: boolean;
  46719. /**
  46720. * Gets the perf counter used for inter-frames time capture
  46721. */
  46722. readonly interFrameTimeCounter: PerfCounter;
  46723. /**
  46724. * Gets the inter-frames time capture status
  46725. */
  46726. /**
  46727. * Enable or disable the inter-frames time capture
  46728. */
  46729. captureInterFrameTime: boolean;
  46730. /**
  46731. * Gets the perf counter used for render time capture
  46732. */
  46733. readonly renderTimeCounter: PerfCounter;
  46734. /**
  46735. * Gets the render time capture status
  46736. */
  46737. /**
  46738. * Enable or disable the render time capture
  46739. */
  46740. captureRenderTime: boolean;
  46741. /**
  46742. * Gets the perf counter used for camera render time capture
  46743. */
  46744. readonly cameraRenderTimeCounter: PerfCounter;
  46745. /**
  46746. * Gets the camera render time capture status
  46747. */
  46748. /**
  46749. * Enable or disable the camera render time capture
  46750. */
  46751. captureCameraRenderTime: boolean;
  46752. /**
  46753. * Gets the perf counter used for draw calls
  46754. */
  46755. readonly drawCallsCounter: PerfCounter;
  46756. /**
  46757. * Gets the perf counter used for texture collisions
  46758. */
  46759. readonly textureCollisionsCounter: PerfCounter;
  46760. /**
  46761. * Instantiates a new scene instrumentation.
  46762. * This class can be used to get instrumentation data from a Babylon engine
  46763. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46764. * @param scene Defines the scene to instrument
  46765. */
  46766. constructor(
  46767. /**
  46768. * Defines the scene to instrument
  46769. */
  46770. scene: Scene);
  46771. /**
  46772. * Dispose and release associated resources.
  46773. */
  46774. dispose(): void;
  46775. }
  46776. }
  46777. declare module "babylonjs/Instrumentation/index" {
  46778. export * from "babylonjs/Instrumentation/engineInstrumentation";
  46779. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  46780. export * from "babylonjs/Instrumentation/timeToken";
  46781. }
  46782. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  46783. /** @hidden */
  46784. export var glowMapGenerationPixelShader: {
  46785. name: string;
  46786. shader: string;
  46787. };
  46788. }
  46789. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  46790. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46791. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46792. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46793. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46794. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46795. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46796. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46797. /** @hidden */
  46798. export var glowMapGenerationVertexShader: {
  46799. name: string;
  46800. shader: string;
  46801. };
  46802. }
  46803. declare module "babylonjs/Layers/effectLayer" {
  46804. import { Observable } from "babylonjs/Misc/observable";
  46805. import { Nullable } from "babylonjs/types";
  46806. import { Camera } from "babylonjs/Cameras/camera";
  46807. import { Scene } from "babylonjs/scene";
  46808. import { Color4, ISize } from "babylonjs/Maths/math";
  46809. import { Engine } from "babylonjs/Engines/engine";
  46810. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46812. import { Mesh } from "babylonjs/Meshes/mesh";
  46813. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46815. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46816. import { Effect } from "babylonjs/Materials/effect";
  46817. import { Material } from "babylonjs/Materials/material";
  46818. import "babylonjs/Shaders/glowMapGeneration.fragment";
  46819. import "babylonjs/Shaders/glowMapGeneration.vertex";
  46820. /**
  46821. * Effect layer options. This helps customizing the behaviour
  46822. * of the effect layer.
  46823. */
  46824. export interface IEffectLayerOptions {
  46825. /**
  46826. * Multiplication factor apply to the canvas size to compute the render target size
  46827. * used to generated the objects (the smaller the faster).
  46828. */
  46829. mainTextureRatio: number;
  46830. /**
  46831. * Enforces a fixed size texture to ensure effect stability across devices.
  46832. */
  46833. mainTextureFixedSize?: number;
  46834. /**
  46835. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46836. */
  46837. alphaBlendingMode: number;
  46838. /**
  46839. * The camera attached to the layer.
  46840. */
  46841. camera: Nullable<Camera>;
  46842. /**
  46843. * The rendering group to draw the layer in.
  46844. */
  46845. renderingGroupId: number;
  46846. }
  46847. /**
  46848. * The effect layer Helps adding post process effect blended with the main pass.
  46849. *
  46850. * This can be for instance use to generate glow or higlight effects on the scene.
  46851. *
  46852. * The effect layer class can not be used directly and is intented to inherited from to be
  46853. * customized per effects.
  46854. */
  46855. export abstract class EffectLayer {
  46856. private _vertexBuffers;
  46857. private _indexBuffer;
  46858. private _cachedDefines;
  46859. private _effectLayerMapGenerationEffect;
  46860. private _effectLayerOptions;
  46861. private _mergeEffect;
  46862. protected _scene: Scene;
  46863. protected _engine: Engine;
  46864. protected _maxSize: number;
  46865. protected _mainTextureDesiredSize: ISize;
  46866. protected _mainTexture: RenderTargetTexture;
  46867. protected _shouldRender: boolean;
  46868. protected _postProcesses: PostProcess[];
  46869. protected _textures: BaseTexture[];
  46870. protected _emissiveTextureAndColor: {
  46871. texture: Nullable<BaseTexture>;
  46872. color: Color4;
  46873. };
  46874. /**
  46875. * The name of the layer
  46876. */
  46877. name: string;
  46878. /**
  46879. * The clear color of the texture used to generate the glow map.
  46880. */
  46881. neutralColor: Color4;
  46882. /**
  46883. * Specifies wether the highlight layer is enabled or not.
  46884. */
  46885. isEnabled: boolean;
  46886. /**
  46887. * Gets the camera attached to the layer.
  46888. */
  46889. readonly camera: Nullable<Camera>;
  46890. /**
  46891. * Gets the rendering group id the layer should render in.
  46892. */
  46893. readonly renderingGroupId: number;
  46894. /**
  46895. * An event triggered when the effect layer has been disposed.
  46896. */
  46897. onDisposeObservable: Observable<EffectLayer>;
  46898. /**
  46899. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46900. */
  46901. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46902. /**
  46903. * An event triggered when the generated texture is being merged in the scene.
  46904. */
  46905. onBeforeComposeObservable: Observable<EffectLayer>;
  46906. /**
  46907. * An event triggered when the generated texture has been merged in the scene.
  46908. */
  46909. onAfterComposeObservable: Observable<EffectLayer>;
  46910. /**
  46911. * An event triggered when the efffect layer changes its size.
  46912. */
  46913. onSizeChangedObservable: Observable<EffectLayer>;
  46914. /** @hidden */
  46915. static _SceneComponentInitialization: (scene: Scene) => void;
  46916. /**
  46917. * Instantiates a new effect Layer and references it in the scene.
  46918. * @param name The name of the layer
  46919. * @param scene The scene to use the layer in
  46920. */
  46921. constructor(
  46922. /** The Friendly of the effect in the scene */
  46923. name: string, scene: Scene);
  46924. /**
  46925. * Get the effect name of the layer.
  46926. * @return The effect name
  46927. */
  46928. abstract getEffectName(): string;
  46929. /**
  46930. * Checks for the readiness of the element composing the layer.
  46931. * @param subMesh the mesh to check for
  46932. * @param useInstances specify wether or not to use instances to render the mesh
  46933. * @return true if ready otherwise, false
  46934. */
  46935. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46936. /**
  46937. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46938. * @returns true if the effect requires stencil during the main canvas render pass.
  46939. */
  46940. abstract needStencil(): boolean;
  46941. /**
  46942. * Create the merge effect. This is the shader use to blit the information back
  46943. * to the main canvas at the end of the scene rendering.
  46944. * @returns The effect containing the shader used to merge the effect on the main canvas
  46945. */
  46946. protected abstract _createMergeEffect(): Effect;
  46947. /**
  46948. * Creates the render target textures and post processes used in the effect layer.
  46949. */
  46950. protected abstract _createTextureAndPostProcesses(): void;
  46951. /**
  46952. * Implementation specific of rendering the generating effect on the main canvas.
  46953. * @param effect The effect used to render through
  46954. */
  46955. protected abstract _internalRender(effect: Effect): void;
  46956. /**
  46957. * Sets the required values for both the emissive texture and and the main color.
  46958. */
  46959. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46960. /**
  46961. * Free any resources and references associated to a mesh.
  46962. * Internal use
  46963. * @param mesh The mesh to free.
  46964. */
  46965. abstract _disposeMesh(mesh: Mesh): void;
  46966. /**
  46967. * Serializes this layer (Glow or Highlight for example)
  46968. * @returns a serialized layer object
  46969. */
  46970. abstract serialize?(): any;
  46971. /**
  46972. * Initializes the effect layer with the required options.
  46973. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46974. */
  46975. protected _init(options: Partial<IEffectLayerOptions>): void;
  46976. /**
  46977. * Generates the index buffer of the full screen quad blending to the main canvas.
  46978. */
  46979. private _generateIndexBuffer;
  46980. /**
  46981. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46982. */
  46983. private _genrateVertexBuffer;
  46984. /**
  46985. * Sets the main texture desired size which is the closest power of two
  46986. * of the engine canvas size.
  46987. */
  46988. private _setMainTextureSize;
  46989. /**
  46990. * Creates the main texture for the effect layer.
  46991. */
  46992. protected _createMainTexture(): void;
  46993. /**
  46994. * Adds specific effects defines.
  46995. * @param defines The defines to add specifics to.
  46996. */
  46997. protected _addCustomEffectDefines(defines: string[]): void;
  46998. /**
  46999. * Checks for the readiness of the element composing the layer.
  47000. * @param subMesh the mesh to check for
  47001. * @param useInstances specify wether or not to use instances to render the mesh
  47002. * @param emissiveTexture the associated emissive texture used to generate the glow
  47003. * @return true if ready otherwise, false
  47004. */
  47005. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47006. /**
  47007. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47008. */
  47009. render(): void;
  47010. /**
  47011. * Determine if a given mesh will be used in the current effect.
  47012. * @param mesh mesh to test
  47013. * @returns true if the mesh will be used
  47014. */
  47015. hasMesh(mesh: AbstractMesh): boolean;
  47016. /**
  47017. * Returns true if the layer contains information to display, otherwise false.
  47018. * @returns true if the glow layer should be rendered
  47019. */
  47020. shouldRender(): boolean;
  47021. /**
  47022. * Returns true if the mesh should render, otherwise false.
  47023. * @param mesh The mesh to render
  47024. * @returns true if it should render otherwise false
  47025. */
  47026. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47027. /**
  47028. * Returns true if the mesh can be rendered, otherwise false.
  47029. * @param mesh The mesh to render
  47030. * @param material The material used on the mesh
  47031. * @returns true if it can be rendered otherwise false
  47032. */
  47033. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47034. /**
  47035. * Returns true if the mesh should render, otherwise false.
  47036. * @param mesh The mesh to render
  47037. * @returns true if it should render otherwise false
  47038. */
  47039. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47040. /**
  47041. * Renders the submesh passed in parameter to the generation map.
  47042. */
  47043. protected _renderSubMesh(subMesh: SubMesh): void;
  47044. /**
  47045. * Rebuild the required buffers.
  47046. * @hidden Internal use only.
  47047. */
  47048. _rebuild(): void;
  47049. /**
  47050. * Dispose only the render target textures and post process.
  47051. */
  47052. private _disposeTextureAndPostProcesses;
  47053. /**
  47054. * Dispose the highlight layer and free resources.
  47055. */
  47056. dispose(): void;
  47057. /**
  47058. * Gets the class name of the effect layer
  47059. * @returns the string with the class name of the effect layer
  47060. */
  47061. getClassName(): string;
  47062. /**
  47063. * Creates an effect layer from parsed effect layer data
  47064. * @param parsedEffectLayer defines effect layer data
  47065. * @param scene defines the current scene
  47066. * @param rootUrl defines the root URL containing the effect layer information
  47067. * @returns a parsed effect Layer
  47068. */
  47069. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47070. }
  47071. }
  47072. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47073. import { Scene } from "babylonjs/scene";
  47074. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47075. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47076. import { AbstractScene } from "babylonjs/abstractScene";
  47077. module "babylonjs/abstractScene" {
  47078. interface AbstractScene {
  47079. /**
  47080. * The list of effect layers (highlights/glow) added to the scene
  47081. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47082. * @see http://doc.babylonjs.com/how_to/glow_layer
  47083. */
  47084. effectLayers: Array<EffectLayer>;
  47085. /**
  47086. * Removes the given effect layer from this scene.
  47087. * @param toRemove defines the effect layer to remove
  47088. * @returns the index of the removed effect layer
  47089. */
  47090. removeEffectLayer(toRemove: EffectLayer): number;
  47091. /**
  47092. * Adds the given effect layer to this scene
  47093. * @param newEffectLayer defines the effect layer to add
  47094. */
  47095. addEffectLayer(newEffectLayer: EffectLayer): void;
  47096. }
  47097. }
  47098. /**
  47099. * Defines the layer scene component responsible to manage any effect layers
  47100. * in a given scene.
  47101. */
  47102. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47103. /**
  47104. * The component name helpfull to identify the component in the list of scene components.
  47105. */
  47106. readonly name: string;
  47107. /**
  47108. * The scene the component belongs to.
  47109. */
  47110. scene: Scene;
  47111. private _engine;
  47112. private _renderEffects;
  47113. private _needStencil;
  47114. private _previousStencilState;
  47115. /**
  47116. * Creates a new instance of the component for the given scene
  47117. * @param scene Defines the scene to register the component in
  47118. */
  47119. constructor(scene: Scene);
  47120. /**
  47121. * Registers the component in a given scene
  47122. */
  47123. register(): void;
  47124. /**
  47125. * Rebuilds the elements related to this component in case of
  47126. * context lost for instance.
  47127. */
  47128. rebuild(): void;
  47129. /**
  47130. * Serializes the component data to the specified json object
  47131. * @param serializationObject The object to serialize to
  47132. */
  47133. serialize(serializationObject: any): void;
  47134. /**
  47135. * Adds all the element from the container to the scene
  47136. * @param container the container holding the elements
  47137. */
  47138. addFromContainer(container: AbstractScene): void;
  47139. /**
  47140. * Removes all the elements in the container from the scene
  47141. * @param container contains the elements to remove
  47142. */
  47143. removeFromContainer(container: AbstractScene): void;
  47144. /**
  47145. * Disposes the component and the associated ressources.
  47146. */
  47147. dispose(): void;
  47148. private _isReadyForMesh;
  47149. private _renderMainTexture;
  47150. private _setStencil;
  47151. private _setStencilBack;
  47152. private _draw;
  47153. private _drawCamera;
  47154. private _drawRenderingGroup;
  47155. }
  47156. }
  47157. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47158. /** @hidden */
  47159. export var glowMapMergePixelShader: {
  47160. name: string;
  47161. shader: string;
  47162. };
  47163. }
  47164. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47165. /** @hidden */
  47166. export var glowMapMergeVertexShader: {
  47167. name: string;
  47168. shader: string;
  47169. };
  47170. }
  47171. declare module "babylonjs/Layers/glowLayer" {
  47172. import { Nullable } from "babylonjs/types";
  47173. import { Camera } from "babylonjs/Cameras/camera";
  47174. import { Scene } from "babylonjs/scene";
  47175. import { Color4 } from "babylonjs/Maths/math";
  47176. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47178. import { Mesh } from "babylonjs/Meshes/mesh";
  47179. import { Texture } from "babylonjs/Materials/Textures/texture";
  47180. import { Effect } from "babylonjs/Materials/effect";
  47181. import { Material } from "babylonjs/Materials/material";
  47182. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47183. import "babylonjs/Shaders/glowMapMerge.fragment";
  47184. import "babylonjs/Shaders/glowMapMerge.vertex";
  47185. import "babylonjs/Layers/effectLayerSceneComponent";
  47186. module "babylonjs/abstractScene" {
  47187. interface AbstractScene {
  47188. /**
  47189. * Return a the first highlight layer of the scene with a given name.
  47190. * @param name The name of the highlight layer to look for.
  47191. * @return The highlight layer if found otherwise null.
  47192. */
  47193. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47194. }
  47195. }
  47196. /**
  47197. * Glow layer options. This helps customizing the behaviour
  47198. * of the glow layer.
  47199. */
  47200. export interface IGlowLayerOptions {
  47201. /**
  47202. * Multiplication factor apply to the canvas size to compute the render target size
  47203. * used to generated the glowing objects (the smaller the faster).
  47204. */
  47205. mainTextureRatio: number;
  47206. /**
  47207. * Enforces a fixed size texture to ensure resize independant blur.
  47208. */
  47209. mainTextureFixedSize?: number;
  47210. /**
  47211. * How big is the kernel of the blur texture.
  47212. */
  47213. blurKernelSize: number;
  47214. /**
  47215. * The camera attached to the layer.
  47216. */
  47217. camera: Nullable<Camera>;
  47218. /**
  47219. * Enable MSAA by chosing the number of samples.
  47220. */
  47221. mainTextureSamples?: number;
  47222. /**
  47223. * The rendering group to draw the layer in.
  47224. */
  47225. renderingGroupId: number;
  47226. }
  47227. /**
  47228. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47229. *
  47230. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47231. * glowy meshes to your scene.
  47232. *
  47233. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47234. */
  47235. export class GlowLayer extends EffectLayer {
  47236. /**
  47237. * Effect Name of the layer.
  47238. */
  47239. static readonly EffectName: string;
  47240. /**
  47241. * The default blur kernel size used for the glow.
  47242. */
  47243. static DefaultBlurKernelSize: number;
  47244. /**
  47245. * The default texture size ratio used for the glow.
  47246. */
  47247. static DefaultTextureRatio: number;
  47248. /**
  47249. * Sets the kernel size of the blur.
  47250. */
  47251. /**
  47252. * Gets the kernel size of the blur.
  47253. */
  47254. blurKernelSize: number;
  47255. /**
  47256. * Sets the glow intensity.
  47257. */
  47258. /**
  47259. * Gets the glow intensity.
  47260. */
  47261. intensity: number;
  47262. private _options;
  47263. private _intensity;
  47264. private _horizontalBlurPostprocess1;
  47265. private _verticalBlurPostprocess1;
  47266. private _horizontalBlurPostprocess2;
  47267. private _verticalBlurPostprocess2;
  47268. private _blurTexture1;
  47269. private _blurTexture2;
  47270. private _postProcesses1;
  47271. private _postProcesses2;
  47272. private _includedOnlyMeshes;
  47273. private _excludedMeshes;
  47274. /**
  47275. * Callback used to let the user override the color selection on a per mesh basis
  47276. */
  47277. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47278. /**
  47279. * Callback used to let the user override the texture selection on a per mesh basis
  47280. */
  47281. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47282. /**
  47283. * Instantiates a new glow Layer and references it to the scene.
  47284. * @param name The name of the layer
  47285. * @param scene The scene to use the layer in
  47286. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47287. */
  47288. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47289. /**
  47290. * Get the effect name of the layer.
  47291. * @return The effect name
  47292. */
  47293. getEffectName(): string;
  47294. /**
  47295. * Create the merge effect. This is the shader use to blit the information back
  47296. * to the main canvas at the end of the scene rendering.
  47297. */
  47298. protected _createMergeEffect(): Effect;
  47299. /**
  47300. * Creates the render target textures and post processes used in the glow layer.
  47301. */
  47302. protected _createTextureAndPostProcesses(): void;
  47303. /**
  47304. * Checks for the readiness of the element composing the layer.
  47305. * @param subMesh the mesh to check for
  47306. * @param useInstances specify wether or not to use instances to render the mesh
  47307. * @param emissiveTexture the associated emissive texture used to generate the glow
  47308. * @return true if ready otherwise, false
  47309. */
  47310. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47311. /**
  47312. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47313. */
  47314. needStencil(): boolean;
  47315. /**
  47316. * Returns true if the mesh can be rendered, otherwise false.
  47317. * @param mesh The mesh to render
  47318. * @param material The material used on the mesh
  47319. * @returns true if it can be rendered otherwise false
  47320. */
  47321. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47322. /**
  47323. * Implementation specific of rendering the generating effect on the main canvas.
  47324. * @param effect The effect used to render through
  47325. */
  47326. protected _internalRender(effect: Effect): void;
  47327. /**
  47328. * Sets the required values for both the emissive texture and and the main color.
  47329. */
  47330. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47331. /**
  47332. * Returns true if the mesh should render, otherwise false.
  47333. * @param mesh The mesh to render
  47334. * @returns true if it should render otherwise false
  47335. */
  47336. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47337. /**
  47338. * Adds specific effects defines.
  47339. * @param defines The defines to add specifics to.
  47340. */
  47341. protected _addCustomEffectDefines(defines: string[]): void;
  47342. /**
  47343. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47344. * @param mesh The mesh to exclude from the glow layer
  47345. */
  47346. addExcludedMesh(mesh: Mesh): void;
  47347. /**
  47348. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47349. * @param mesh The mesh to remove
  47350. */
  47351. removeExcludedMesh(mesh: Mesh): void;
  47352. /**
  47353. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47354. * @param mesh The mesh to include in the glow layer
  47355. */
  47356. addIncludedOnlyMesh(mesh: Mesh): void;
  47357. /**
  47358. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47359. * @param mesh The mesh to remove
  47360. */
  47361. removeIncludedOnlyMesh(mesh: Mesh): void;
  47362. /**
  47363. * Determine if a given mesh will be used in the glow layer
  47364. * @param mesh The mesh to test
  47365. * @returns true if the mesh will be highlighted by the current glow layer
  47366. */
  47367. hasMesh(mesh: AbstractMesh): boolean;
  47368. /**
  47369. * Free any resources and references associated to a mesh.
  47370. * Internal use
  47371. * @param mesh The mesh to free.
  47372. * @hidden
  47373. */
  47374. _disposeMesh(mesh: Mesh): void;
  47375. /**
  47376. * Gets the class name of the effect layer
  47377. * @returns the string with the class name of the effect layer
  47378. */
  47379. getClassName(): string;
  47380. /**
  47381. * Serializes this glow layer
  47382. * @returns a serialized glow layer object
  47383. */
  47384. serialize(): any;
  47385. /**
  47386. * Creates a Glow Layer from parsed glow layer data
  47387. * @param parsedGlowLayer defines glow layer data
  47388. * @param scene defines the current scene
  47389. * @param rootUrl defines the root URL containing the glow layer information
  47390. * @returns a parsed Glow Layer
  47391. */
  47392. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47393. }
  47394. }
  47395. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47396. /** @hidden */
  47397. export var glowBlurPostProcessPixelShader: {
  47398. name: string;
  47399. shader: string;
  47400. };
  47401. }
  47402. declare module "babylonjs/Layers/highlightLayer" {
  47403. import { Observable } from "babylonjs/Misc/observable";
  47404. import { Nullable } from "babylonjs/types";
  47405. import { Camera } from "babylonjs/Cameras/camera";
  47406. import { Scene } from "babylonjs/scene";
  47407. import { Color3, Color4 } from "babylonjs/Maths/math";
  47408. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47410. import { Mesh } from "babylonjs/Meshes/mesh";
  47411. import { Effect } from "babylonjs/Materials/effect";
  47412. import { Material } from "babylonjs/Materials/material";
  47413. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47414. import "babylonjs/Shaders/glowMapMerge.fragment";
  47415. import "babylonjs/Shaders/glowMapMerge.vertex";
  47416. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47417. module "babylonjs/abstractScene" {
  47418. interface AbstractScene {
  47419. /**
  47420. * Return a the first highlight layer of the scene with a given name.
  47421. * @param name The name of the highlight layer to look for.
  47422. * @return The highlight layer if found otherwise null.
  47423. */
  47424. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47425. }
  47426. }
  47427. /**
  47428. * Highlight layer options. This helps customizing the behaviour
  47429. * of the highlight layer.
  47430. */
  47431. export interface IHighlightLayerOptions {
  47432. /**
  47433. * Multiplication factor apply to the canvas size to compute the render target size
  47434. * used to generated the glowing objects (the smaller the faster).
  47435. */
  47436. mainTextureRatio: number;
  47437. /**
  47438. * Enforces a fixed size texture to ensure resize independant blur.
  47439. */
  47440. mainTextureFixedSize?: number;
  47441. /**
  47442. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47443. * of the picture to blur (the smaller the faster).
  47444. */
  47445. blurTextureSizeRatio: number;
  47446. /**
  47447. * How big in texel of the blur texture is the vertical blur.
  47448. */
  47449. blurVerticalSize: number;
  47450. /**
  47451. * How big in texel of the blur texture is the horizontal blur.
  47452. */
  47453. blurHorizontalSize: number;
  47454. /**
  47455. * Alpha blending mode used to apply the blur. Default is combine.
  47456. */
  47457. alphaBlendingMode: number;
  47458. /**
  47459. * The camera attached to the layer.
  47460. */
  47461. camera: Nullable<Camera>;
  47462. /**
  47463. * Should we display highlight as a solid stroke?
  47464. */
  47465. isStroke?: boolean;
  47466. /**
  47467. * The rendering group to draw the layer in.
  47468. */
  47469. renderingGroupId: number;
  47470. }
  47471. /**
  47472. * The highlight layer Helps adding a glow effect around a mesh.
  47473. *
  47474. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47475. * glowy meshes to your scene.
  47476. *
  47477. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47478. */
  47479. export class HighlightLayer extends EffectLayer {
  47480. name: string;
  47481. /**
  47482. * Effect Name of the highlight layer.
  47483. */
  47484. static readonly EffectName: string;
  47485. /**
  47486. * The neutral color used during the preparation of the glow effect.
  47487. * This is black by default as the blend operation is a blend operation.
  47488. */
  47489. static NeutralColor: Color4;
  47490. /**
  47491. * Stencil value used for glowing meshes.
  47492. */
  47493. static GlowingMeshStencilReference: number;
  47494. /**
  47495. * Stencil value used for the other meshes in the scene.
  47496. */
  47497. static NormalMeshStencilReference: number;
  47498. /**
  47499. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47500. */
  47501. innerGlow: boolean;
  47502. /**
  47503. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47504. */
  47505. outerGlow: boolean;
  47506. /**
  47507. * Specifies the horizontal size of the blur.
  47508. */
  47509. /**
  47510. * Gets the horizontal size of the blur.
  47511. */
  47512. blurHorizontalSize: number;
  47513. /**
  47514. * Specifies the vertical size of the blur.
  47515. */
  47516. /**
  47517. * Gets the vertical size of the blur.
  47518. */
  47519. blurVerticalSize: number;
  47520. /**
  47521. * An event triggered when the highlight layer is being blurred.
  47522. */
  47523. onBeforeBlurObservable: Observable<HighlightLayer>;
  47524. /**
  47525. * An event triggered when the highlight layer has been blurred.
  47526. */
  47527. onAfterBlurObservable: Observable<HighlightLayer>;
  47528. private _instanceGlowingMeshStencilReference;
  47529. private _options;
  47530. private _downSamplePostprocess;
  47531. private _horizontalBlurPostprocess;
  47532. private _verticalBlurPostprocess;
  47533. private _blurTexture;
  47534. private _meshes;
  47535. private _excludedMeshes;
  47536. /**
  47537. * Instantiates a new highlight Layer and references it to the scene..
  47538. * @param name The name of the layer
  47539. * @param scene The scene to use the layer in
  47540. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47541. */
  47542. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47543. /**
  47544. * Get the effect name of the layer.
  47545. * @return The effect name
  47546. */
  47547. getEffectName(): string;
  47548. /**
  47549. * Create the merge effect. This is the shader use to blit the information back
  47550. * to the main canvas at the end of the scene rendering.
  47551. */
  47552. protected _createMergeEffect(): Effect;
  47553. /**
  47554. * Creates the render target textures and post processes used in the highlight layer.
  47555. */
  47556. protected _createTextureAndPostProcesses(): void;
  47557. /**
  47558. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47559. */
  47560. needStencil(): boolean;
  47561. /**
  47562. * Checks for the readiness of the element composing the layer.
  47563. * @param subMesh the mesh to check for
  47564. * @param useInstances specify wether or not to use instances to render the mesh
  47565. * @param emissiveTexture the associated emissive texture used to generate the glow
  47566. * @return true if ready otherwise, false
  47567. */
  47568. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47569. /**
  47570. * Implementation specific of rendering the generating effect on the main canvas.
  47571. * @param effect The effect used to render through
  47572. */
  47573. protected _internalRender(effect: Effect): void;
  47574. /**
  47575. * Returns true if the layer contains information to display, otherwise false.
  47576. */
  47577. shouldRender(): boolean;
  47578. /**
  47579. * Returns true if the mesh should render, otherwise false.
  47580. * @param mesh The mesh to render
  47581. * @returns true if it should render otherwise false
  47582. */
  47583. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47584. /**
  47585. * Sets the required values for both the emissive texture and and the main color.
  47586. */
  47587. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47588. /**
  47589. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47590. * @param mesh The mesh to exclude from the highlight layer
  47591. */
  47592. addExcludedMesh(mesh: Mesh): void;
  47593. /**
  47594. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47595. * @param mesh The mesh to highlight
  47596. */
  47597. removeExcludedMesh(mesh: Mesh): void;
  47598. /**
  47599. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47600. * @param mesh mesh to test
  47601. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47602. */
  47603. hasMesh(mesh: AbstractMesh): boolean;
  47604. /**
  47605. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47606. * @param mesh The mesh to highlight
  47607. * @param color The color of the highlight
  47608. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47609. */
  47610. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47611. /**
  47612. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47613. * @param mesh The mesh to highlight
  47614. */
  47615. removeMesh(mesh: Mesh): void;
  47616. /**
  47617. * Force the stencil to the normal expected value for none glowing parts
  47618. */
  47619. private _defaultStencilReference;
  47620. /**
  47621. * Free any resources and references associated to a mesh.
  47622. * Internal use
  47623. * @param mesh The mesh to free.
  47624. * @hidden
  47625. */
  47626. _disposeMesh(mesh: Mesh): void;
  47627. /**
  47628. * Dispose the highlight layer and free resources.
  47629. */
  47630. dispose(): void;
  47631. /**
  47632. * Gets the class name of the effect layer
  47633. * @returns the string with the class name of the effect layer
  47634. */
  47635. getClassName(): string;
  47636. /**
  47637. * Serializes this Highlight layer
  47638. * @returns a serialized Highlight layer object
  47639. */
  47640. serialize(): any;
  47641. /**
  47642. * Creates a Highlight layer from parsed Highlight layer data
  47643. * @param parsedHightlightLayer defines the Highlight layer data
  47644. * @param scene defines the current scene
  47645. * @param rootUrl defines the root URL containing the Highlight layer information
  47646. * @returns a parsed Highlight layer
  47647. */
  47648. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47649. }
  47650. }
  47651. declare module "babylonjs/Layers/index" {
  47652. export * from "babylonjs/Layers/effectLayer";
  47653. export * from "babylonjs/Layers/effectLayerSceneComponent";
  47654. export * from "babylonjs/Layers/glowLayer";
  47655. export * from "babylonjs/Layers/highlightLayer";
  47656. export * from "babylonjs/Layers/layer";
  47657. export * from "babylonjs/Layers/layerSceneComponent";
  47658. }
  47659. declare module "babylonjs/Shaders/lensFlare.fragment" {
  47660. /** @hidden */
  47661. export var lensFlarePixelShader: {
  47662. name: string;
  47663. shader: string;
  47664. };
  47665. }
  47666. declare module "babylonjs/Shaders/lensFlare.vertex" {
  47667. /** @hidden */
  47668. export var lensFlareVertexShader: {
  47669. name: string;
  47670. shader: string;
  47671. };
  47672. }
  47673. declare module "babylonjs/LensFlares/lensFlareSystem" {
  47674. import { Scene } from "babylonjs/scene";
  47675. import { Vector3, Viewport } from "babylonjs/Maths/math";
  47676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47677. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  47678. import "babylonjs/Shaders/lensFlare.fragment";
  47679. import "babylonjs/Shaders/lensFlare.vertex";
  47680. /**
  47681. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47682. * It is usually composed of several `lensFlare`.
  47683. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47684. */
  47685. export class LensFlareSystem {
  47686. /**
  47687. * Define the name of the lens flare system
  47688. */
  47689. name: string;
  47690. /**
  47691. * List of lens flares used in this system.
  47692. */
  47693. lensFlares: LensFlare[];
  47694. /**
  47695. * Define a limit from the border the lens flare can be visible.
  47696. */
  47697. borderLimit: number;
  47698. /**
  47699. * Define a viewport border we do not want to see the lens flare in.
  47700. */
  47701. viewportBorder: number;
  47702. /**
  47703. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47704. */
  47705. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47706. /**
  47707. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47708. */
  47709. layerMask: number;
  47710. /**
  47711. * Define the id of the lens flare system in the scene.
  47712. * (equal to name by default)
  47713. */
  47714. id: string;
  47715. private _scene;
  47716. private _emitter;
  47717. private _vertexBuffers;
  47718. private _indexBuffer;
  47719. private _effect;
  47720. private _positionX;
  47721. private _positionY;
  47722. private _isEnabled;
  47723. /** @hidden */
  47724. static _SceneComponentInitialization: (scene: Scene) => void;
  47725. /**
  47726. * Instantiates a lens flare system.
  47727. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47728. * It is usually composed of several `lensFlare`.
  47729. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47730. * @param name Define the name of the lens flare system in the scene
  47731. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47732. * @param scene Define the scene the lens flare system belongs to
  47733. */
  47734. constructor(
  47735. /**
  47736. * Define the name of the lens flare system
  47737. */
  47738. name: string, emitter: any, scene: Scene);
  47739. /**
  47740. * Define if the lens flare system is enabled.
  47741. */
  47742. isEnabled: boolean;
  47743. /**
  47744. * Get the scene the effects belongs to.
  47745. * @returns the scene holding the lens flare system
  47746. */
  47747. getScene(): Scene;
  47748. /**
  47749. * Get the emitter of the lens flare system.
  47750. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47751. * @returns the emitter of the lens flare system
  47752. */
  47753. getEmitter(): any;
  47754. /**
  47755. * Set the emitter of the lens flare system.
  47756. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47757. * @param newEmitter Define the new emitter of the system
  47758. */
  47759. setEmitter(newEmitter: any): void;
  47760. /**
  47761. * Get the lens flare system emitter position.
  47762. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47763. * @returns the position
  47764. */
  47765. getEmitterPosition(): Vector3;
  47766. /**
  47767. * @hidden
  47768. */
  47769. computeEffectivePosition(globalViewport: Viewport): boolean;
  47770. /** @hidden */
  47771. _isVisible(): boolean;
  47772. /**
  47773. * @hidden
  47774. */
  47775. render(): boolean;
  47776. /**
  47777. * Dispose and release the lens flare with its associated resources.
  47778. */
  47779. dispose(): void;
  47780. /**
  47781. * Parse a lens flare system from a JSON repressentation
  47782. * @param parsedLensFlareSystem Define the JSON to parse
  47783. * @param scene Define the scene the parsed system should be instantiated in
  47784. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47785. * @returns the parsed system
  47786. */
  47787. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47788. /**
  47789. * Serialize the current Lens Flare System into a JSON representation.
  47790. * @returns the serialized JSON
  47791. */
  47792. serialize(): any;
  47793. }
  47794. }
  47795. declare module "babylonjs/LensFlares/lensFlare" {
  47796. import { Nullable } from "babylonjs/types";
  47797. import { Color3 } from "babylonjs/Maths/math";
  47798. import { Texture } from "babylonjs/Materials/Textures/texture";
  47799. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47800. /**
  47801. * This represents one of the lens effect in a `lensFlareSystem`.
  47802. * It controls one of the indiviual texture used in the effect.
  47803. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47804. */
  47805. export class LensFlare {
  47806. /**
  47807. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47808. */
  47809. size: number;
  47810. /**
  47811. * 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.
  47812. */
  47813. position: number;
  47814. /**
  47815. * Define the lens color.
  47816. */
  47817. color: Color3;
  47818. /**
  47819. * Define the lens texture.
  47820. */
  47821. texture: Nullable<Texture>;
  47822. /**
  47823. * Define the alpha mode to render this particular lens.
  47824. */
  47825. alphaMode: number;
  47826. private _system;
  47827. /**
  47828. * Creates a new Lens Flare.
  47829. * This represents one of the lens effect in a `lensFlareSystem`.
  47830. * It controls one of the indiviual texture used in the effect.
  47831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47832. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47833. * @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.
  47834. * @param color Define the lens color
  47835. * @param imgUrl Define the lens texture url
  47836. * @param system Define the `lensFlareSystem` this flare is part of
  47837. * @returns The newly created Lens Flare
  47838. */
  47839. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47840. /**
  47841. * Instantiates a new Lens Flare.
  47842. * This represents one of the lens effect in a `lensFlareSystem`.
  47843. * It controls one of the indiviual texture used in the effect.
  47844. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47845. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47846. * @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.
  47847. * @param color Define the lens color
  47848. * @param imgUrl Define the lens texture url
  47849. * @param system Define the `lensFlareSystem` this flare is part of
  47850. */
  47851. constructor(
  47852. /**
  47853. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47854. */
  47855. size: number,
  47856. /**
  47857. * 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.
  47858. */
  47859. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47860. /**
  47861. * Dispose and release the lens flare with its associated resources.
  47862. */
  47863. dispose(): void;
  47864. }
  47865. }
  47866. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  47867. import { Nullable } from "babylonjs/types";
  47868. import { Scene } from "babylonjs/scene";
  47869. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47870. import { AbstractScene } from "babylonjs/abstractScene";
  47871. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  47872. module "babylonjs/abstractScene" {
  47873. interface AbstractScene {
  47874. /**
  47875. * The list of lens flare system added to the scene
  47876. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47877. */
  47878. lensFlareSystems: Array<LensFlareSystem>;
  47879. /**
  47880. * Removes the given lens flare system from this scene.
  47881. * @param toRemove The lens flare system to remove
  47882. * @returns The index of the removed lens flare system
  47883. */
  47884. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47885. /**
  47886. * Adds the given lens flare system to this scene
  47887. * @param newLensFlareSystem The lens flare system to add
  47888. */
  47889. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47890. /**
  47891. * Gets a lens flare system using its name
  47892. * @param name defines the name to look for
  47893. * @returns the lens flare system or null if not found
  47894. */
  47895. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47896. /**
  47897. * Gets a lens flare system using its id
  47898. * @param id defines the id to look for
  47899. * @returns the lens flare system or null if not found
  47900. */
  47901. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47902. }
  47903. }
  47904. /**
  47905. * Defines the lens flare scene component responsible to manage any lens flares
  47906. * in a given scene.
  47907. */
  47908. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47909. /**
  47910. * The component name helpfull to identify the component in the list of scene components.
  47911. */
  47912. readonly name: string;
  47913. /**
  47914. * The scene the component belongs to.
  47915. */
  47916. scene: Scene;
  47917. /**
  47918. * Creates a new instance of the component for the given scene
  47919. * @param scene Defines the scene to register the component in
  47920. */
  47921. constructor(scene: Scene);
  47922. /**
  47923. * Registers the component in a given scene
  47924. */
  47925. register(): void;
  47926. /**
  47927. * Rebuilds the elements related to this component in case of
  47928. * context lost for instance.
  47929. */
  47930. rebuild(): void;
  47931. /**
  47932. * Adds all the element from the container to the scene
  47933. * @param container the container holding the elements
  47934. */
  47935. addFromContainer(container: AbstractScene): void;
  47936. /**
  47937. * Removes all the elements in the container from the scene
  47938. * @param container contains the elements to remove
  47939. */
  47940. removeFromContainer(container: AbstractScene): void;
  47941. /**
  47942. * Serializes the component data to the specified json object
  47943. * @param serializationObject The object to serialize to
  47944. */
  47945. serialize(serializationObject: any): void;
  47946. /**
  47947. * Disposes the component and the associated ressources.
  47948. */
  47949. dispose(): void;
  47950. private _draw;
  47951. }
  47952. }
  47953. declare module "babylonjs/LensFlares/index" {
  47954. export * from "babylonjs/LensFlares/lensFlare";
  47955. export * from "babylonjs/LensFlares/lensFlareSystem";
  47956. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  47957. }
  47958. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  47959. import { Scene } from "babylonjs/scene";
  47960. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47961. import { AbstractScene } from "babylonjs/abstractScene";
  47962. /**
  47963. * Defines the shadow generator component responsible to manage any shadow generators
  47964. * in a given scene.
  47965. */
  47966. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47967. /**
  47968. * The component name helpfull to identify the component in the list of scene components.
  47969. */
  47970. readonly name: string;
  47971. /**
  47972. * The scene the component belongs to.
  47973. */
  47974. scene: Scene;
  47975. /**
  47976. * Creates a new instance of the component for the given scene
  47977. * @param scene Defines the scene to register the component in
  47978. */
  47979. constructor(scene: Scene);
  47980. /**
  47981. * Registers the component in a given scene
  47982. */
  47983. register(): void;
  47984. /**
  47985. * Rebuilds the elements related to this component in case of
  47986. * context lost for instance.
  47987. */
  47988. rebuild(): void;
  47989. /**
  47990. * Serializes the component data to the specified json object
  47991. * @param serializationObject The object to serialize to
  47992. */
  47993. serialize(serializationObject: any): void;
  47994. /**
  47995. * Adds all the element from the container to the scene
  47996. * @param container the container holding the elements
  47997. */
  47998. addFromContainer(container: AbstractScene): void;
  47999. /**
  48000. * Removes all the elements in the container from the scene
  48001. * @param container contains the elements to remove
  48002. */
  48003. removeFromContainer(container: AbstractScene): void;
  48004. /**
  48005. * Rebuilds the elements related to this component in case of
  48006. * context lost for instance.
  48007. */
  48008. dispose(): void;
  48009. private _gatherRenderTargets;
  48010. }
  48011. }
  48012. declare module "babylonjs/Lights/Shadows/index" {
  48013. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48014. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48015. }
  48016. declare module "babylonjs/Lights/directionalLight" {
  48017. import { Camera } from "babylonjs/Cameras/camera";
  48018. import { Scene } from "babylonjs/scene";
  48019. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48021. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48022. import { Effect } from "babylonjs/Materials/effect";
  48023. /**
  48024. * A directional light is defined by a direction (what a surprise!).
  48025. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48026. * 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.
  48027. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48028. */
  48029. export class DirectionalLight extends ShadowLight {
  48030. private _shadowFrustumSize;
  48031. /**
  48032. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48033. */
  48034. /**
  48035. * Specifies a fix frustum size for the shadow generation.
  48036. */
  48037. shadowFrustumSize: number;
  48038. private _shadowOrthoScale;
  48039. /**
  48040. * Gets the shadow projection scale against the optimal computed one.
  48041. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48042. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48043. */
  48044. /**
  48045. * Sets the shadow projection scale against the optimal computed one.
  48046. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48047. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48048. */
  48049. shadowOrthoScale: number;
  48050. /**
  48051. * Automatically compute the projection matrix to best fit (including all the casters)
  48052. * on each frame.
  48053. */
  48054. autoUpdateExtends: boolean;
  48055. private _orthoLeft;
  48056. private _orthoRight;
  48057. private _orthoTop;
  48058. private _orthoBottom;
  48059. /**
  48060. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48061. * The directional light is emitted from everywhere in the given direction.
  48062. * It can cast shadows.
  48063. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48064. * @param name The friendly name of the light
  48065. * @param direction The direction of the light
  48066. * @param scene The scene the light belongs to
  48067. */
  48068. constructor(name: string, direction: Vector3, scene: Scene);
  48069. /**
  48070. * Returns the string "DirectionalLight".
  48071. * @return The class name
  48072. */
  48073. getClassName(): string;
  48074. /**
  48075. * Returns the integer 1.
  48076. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48077. */
  48078. getTypeID(): number;
  48079. /**
  48080. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48081. * Returns the DirectionalLight Shadow projection matrix.
  48082. */
  48083. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48084. /**
  48085. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48086. * Returns the DirectionalLight Shadow projection matrix.
  48087. */
  48088. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48089. /**
  48090. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48091. * Returns the DirectionalLight Shadow projection matrix.
  48092. */
  48093. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48094. protected _buildUniformLayout(): void;
  48095. /**
  48096. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48097. * @param effect The effect to update
  48098. * @param lightIndex The index of the light in the effect to update
  48099. * @returns The directional light
  48100. */
  48101. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48102. /**
  48103. * Gets the minZ used for shadow according to both the scene and the light.
  48104. *
  48105. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48106. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48107. * @param activeCamera The camera we are returning the min for
  48108. * @returns the depth min z
  48109. */
  48110. getDepthMinZ(activeCamera: Camera): number;
  48111. /**
  48112. * Gets the maxZ used for shadow according to both the scene and the light.
  48113. *
  48114. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48115. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48116. * @param activeCamera The camera we are returning the max for
  48117. * @returns the depth max z
  48118. */
  48119. getDepthMaxZ(activeCamera: Camera): number;
  48120. /**
  48121. * Prepares the list of defines specific to the light type.
  48122. * @param defines the list of defines
  48123. * @param lightIndex defines the index of the light for the effect
  48124. */
  48125. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48126. }
  48127. }
  48128. declare module "babylonjs/Lights/pointLight" {
  48129. import { Scene } from "babylonjs/scene";
  48130. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48132. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48133. import { Effect } from "babylonjs/Materials/effect";
  48134. /**
  48135. * A point light is a light defined by an unique point in world space.
  48136. * The light is emitted in every direction from this point.
  48137. * A good example of a point light is a standard light bulb.
  48138. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48139. */
  48140. export class PointLight extends ShadowLight {
  48141. private _shadowAngle;
  48142. /**
  48143. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48144. * This specifies what angle the shadow will use to be created.
  48145. *
  48146. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48147. */
  48148. /**
  48149. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48150. * This specifies what angle the shadow will use to be created.
  48151. *
  48152. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48153. */
  48154. shadowAngle: number;
  48155. /**
  48156. * Gets the direction if it has been set.
  48157. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48158. */
  48159. /**
  48160. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48161. */
  48162. direction: Vector3;
  48163. /**
  48164. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48165. * A PointLight emits the light in every direction.
  48166. * It can cast shadows.
  48167. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48168. * ```javascript
  48169. * var pointLight = new PointLight("pl", camera.position, scene);
  48170. * ```
  48171. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48172. * @param name The light friendly name
  48173. * @param position The position of the point light in the scene
  48174. * @param scene The scene the lights belongs to
  48175. */
  48176. constructor(name: string, position: Vector3, scene: Scene);
  48177. /**
  48178. * Returns the string "PointLight"
  48179. * @returns the class name
  48180. */
  48181. getClassName(): string;
  48182. /**
  48183. * Returns the integer 0.
  48184. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48185. */
  48186. getTypeID(): number;
  48187. /**
  48188. * Specifies wether or not the shadowmap should be a cube texture.
  48189. * @returns true if the shadowmap needs to be a cube texture.
  48190. */
  48191. needCube(): boolean;
  48192. /**
  48193. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48194. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48195. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48196. */
  48197. getShadowDirection(faceIndex?: number): Vector3;
  48198. /**
  48199. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48200. * - fov = PI / 2
  48201. * - aspect ratio : 1.0
  48202. * - z-near and far equal to the active camera minZ and maxZ.
  48203. * Returns the PointLight.
  48204. */
  48205. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48206. protected _buildUniformLayout(): void;
  48207. /**
  48208. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48209. * @param effect The effect to update
  48210. * @param lightIndex The index of the light in the effect to update
  48211. * @returns The point light
  48212. */
  48213. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48214. /**
  48215. * Prepares the list of defines specific to the light type.
  48216. * @param defines the list of defines
  48217. * @param lightIndex defines the index of the light for the effect
  48218. */
  48219. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48220. }
  48221. }
  48222. declare module "babylonjs/Lights/spotLight" {
  48223. import { Nullable } from "babylonjs/types";
  48224. import { Scene } from "babylonjs/scene";
  48225. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48227. import { Effect } from "babylonjs/Materials/effect";
  48228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48229. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48230. /**
  48231. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48232. * These values define a cone of light starting from the position, emitting toward the direction.
  48233. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48234. * and the exponent defines the speed of the decay of the light with distance (reach).
  48235. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48236. */
  48237. export class SpotLight extends ShadowLight {
  48238. private _angle;
  48239. private _innerAngle;
  48240. private _cosHalfAngle;
  48241. private _lightAngleScale;
  48242. private _lightAngleOffset;
  48243. /**
  48244. * Gets the cone angle of the spot light in Radians.
  48245. */
  48246. /**
  48247. * Sets the cone angle of the spot light in Radians.
  48248. */
  48249. angle: number;
  48250. /**
  48251. * Only used in gltf falloff mode, this defines the angle where
  48252. * the directional falloff will start before cutting at angle which could be seen
  48253. * as outer angle.
  48254. */
  48255. /**
  48256. * Only used in gltf falloff mode, this defines the angle where
  48257. * the directional falloff will start before cutting at angle which could be seen
  48258. * as outer angle.
  48259. */
  48260. innerAngle: number;
  48261. private _shadowAngleScale;
  48262. /**
  48263. * Allows scaling the angle of the light for shadow generation only.
  48264. */
  48265. /**
  48266. * Allows scaling the angle of the light for shadow generation only.
  48267. */
  48268. shadowAngleScale: number;
  48269. /**
  48270. * The light decay speed with the distance from the emission spot.
  48271. */
  48272. exponent: number;
  48273. private _projectionTextureMatrix;
  48274. /**
  48275. * Allows reading the projecton texture
  48276. */
  48277. readonly projectionTextureMatrix: Matrix;
  48278. protected _projectionTextureLightNear: number;
  48279. /**
  48280. * Gets the near clip of the Spotlight for texture projection.
  48281. */
  48282. /**
  48283. * Sets the near clip of the Spotlight for texture projection.
  48284. */
  48285. projectionTextureLightNear: number;
  48286. protected _projectionTextureLightFar: number;
  48287. /**
  48288. * Gets the far clip of the Spotlight for texture projection.
  48289. */
  48290. /**
  48291. * Sets the far clip of the Spotlight for texture projection.
  48292. */
  48293. projectionTextureLightFar: number;
  48294. protected _projectionTextureUpDirection: Vector3;
  48295. /**
  48296. * Gets the Up vector of the Spotlight for texture projection.
  48297. */
  48298. /**
  48299. * Sets the Up vector of the Spotlight for texture projection.
  48300. */
  48301. projectionTextureUpDirection: Vector3;
  48302. private _projectionTexture;
  48303. /**
  48304. * Gets the projection texture of the light.
  48305. */
  48306. /**
  48307. * Sets the projection texture of the light.
  48308. */
  48309. projectionTexture: Nullable<BaseTexture>;
  48310. private _projectionTextureViewLightDirty;
  48311. private _projectionTextureProjectionLightDirty;
  48312. private _projectionTextureDirty;
  48313. private _projectionTextureViewTargetVector;
  48314. private _projectionTextureViewLightMatrix;
  48315. private _projectionTextureProjectionLightMatrix;
  48316. private _projectionTextureScalingMatrix;
  48317. /**
  48318. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48319. * It can cast shadows.
  48320. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48321. * @param name The light friendly name
  48322. * @param position The position of the spot light in the scene
  48323. * @param direction The direction of the light in the scene
  48324. * @param angle The cone angle of the light in Radians
  48325. * @param exponent The light decay speed with the distance from the emission spot
  48326. * @param scene The scene the lights belongs to
  48327. */
  48328. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48329. /**
  48330. * Returns the string "SpotLight".
  48331. * @returns the class name
  48332. */
  48333. getClassName(): string;
  48334. /**
  48335. * Returns the integer 2.
  48336. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48337. */
  48338. getTypeID(): number;
  48339. /**
  48340. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48341. */
  48342. protected _setDirection(value: Vector3): void;
  48343. /**
  48344. * Overrides the position setter to recompute the projection texture view light Matrix.
  48345. */
  48346. protected _setPosition(value: Vector3): void;
  48347. /**
  48348. * 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.
  48349. * Returns the SpotLight.
  48350. */
  48351. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48352. protected _computeProjectionTextureViewLightMatrix(): void;
  48353. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48354. /**
  48355. * Main function for light texture projection matrix computing.
  48356. */
  48357. protected _computeProjectionTextureMatrix(): void;
  48358. protected _buildUniformLayout(): void;
  48359. private _computeAngleValues;
  48360. /**
  48361. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48362. * @param effect The effect to update
  48363. * @param lightIndex The index of the light in the effect to update
  48364. * @returns The spot light
  48365. */
  48366. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48367. /**
  48368. * Disposes the light and the associated resources.
  48369. */
  48370. dispose(): void;
  48371. /**
  48372. * Prepares the list of defines specific to the light type.
  48373. * @param defines the list of defines
  48374. * @param lightIndex defines the index of the light for the effect
  48375. */
  48376. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48377. }
  48378. }
  48379. declare module "babylonjs/Lights/index" {
  48380. export * from "babylonjs/Lights/light";
  48381. export * from "babylonjs/Lights/shadowLight";
  48382. export * from "babylonjs/Lights/Shadows/index";
  48383. export * from "babylonjs/Lights/directionalLight";
  48384. export * from "babylonjs/Lights/hemisphericLight";
  48385. export * from "babylonjs/Lights/pointLight";
  48386. export * from "babylonjs/Lights/spotLight";
  48387. }
  48388. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48389. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48390. /**
  48391. * Header information of HDR texture files.
  48392. */
  48393. export interface HDRInfo {
  48394. /**
  48395. * The height of the texture in pixels.
  48396. */
  48397. height: number;
  48398. /**
  48399. * The width of the texture in pixels.
  48400. */
  48401. width: number;
  48402. /**
  48403. * The index of the beginning of the data in the binary file.
  48404. */
  48405. dataPosition: number;
  48406. }
  48407. /**
  48408. * This groups tools to convert HDR texture to native colors array.
  48409. */
  48410. export class HDRTools {
  48411. private static Ldexp;
  48412. private static Rgbe2float;
  48413. private static readStringLine;
  48414. /**
  48415. * Reads header information from an RGBE texture stored in a native array.
  48416. * More information on this format are available here:
  48417. * https://en.wikipedia.org/wiki/RGBE_image_format
  48418. *
  48419. * @param uint8array The binary file stored in native array.
  48420. * @return The header information.
  48421. */
  48422. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48423. /**
  48424. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48425. * This RGBE texture needs to store the information as a panorama.
  48426. *
  48427. * More information on this format are available here:
  48428. * https://en.wikipedia.org/wiki/RGBE_image_format
  48429. *
  48430. * @param buffer The binary file stored in an array buffer.
  48431. * @param size The expected size of the extracted cubemap.
  48432. * @return The Cube Map information.
  48433. */
  48434. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48435. /**
  48436. * Returns the pixels data extracted from an RGBE texture.
  48437. * This pixels will be stored left to right up to down in the R G B order in one array.
  48438. *
  48439. * More information on this format are available here:
  48440. * https://en.wikipedia.org/wiki/RGBE_image_format
  48441. *
  48442. * @param uint8array The binary file stored in an array buffer.
  48443. * @param hdrInfo The header information of the file.
  48444. * @return The pixels data in RGB right to left up to down order.
  48445. */
  48446. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48447. private static RGBE_ReadPixels_RLE;
  48448. }
  48449. }
  48450. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48451. import { Nullable } from "babylonjs/types";
  48452. import { Scene } from "babylonjs/scene";
  48453. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48455. /**
  48456. * This represents a texture coming from an HDR input.
  48457. *
  48458. * The only supported format is currently panorama picture stored in RGBE format.
  48459. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48460. */
  48461. export class HDRCubeTexture extends BaseTexture {
  48462. private static _facesMapping;
  48463. private _generateHarmonics;
  48464. private _noMipmap;
  48465. private _textureMatrix;
  48466. private _size;
  48467. private _onLoad;
  48468. private _onError;
  48469. /**
  48470. * The texture URL.
  48471. */
  48472. url: string;
  48473. /**
  48474. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48475. */
  48476. coordinatesMode: number;
  48477. protected _isBlocking: boolean;
  48478. /**
  48479. * Sets wether or not the texture is blocking during loading.
  48480. */
  48481. /**
  48482. * Gets wether or not the texture is blocking during loading.
  48483. */
  48484. isBlocking: boolean;
  48485. protected _rotationY: number;
  48486. /**
  48487. * Sets texture matrix rotation angle around Y axis in radians.
  48488. */
  48489. /**
  48490. * Gets texture matrix rotation angle around Y axis radians.
  48491. */
  48492. rotationY: number;
  48493. /**
  48494. * Gets or sets the center of the bounding box associated with the cube texture
  48495. * It must define where the camera used to render the texture was set
  48496. */
  48497. boundingBoxPosition: Vector3;
  48498. private _boundingBoxSize;
  48499. /**
  48500. * Gets or sets the size of the bounding box associated with the cube texture
  48501. * When defined, the cubemap will switch to local mode
  48502. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48503. * @example https://www.babylonjs-playground.com/#RNASML
  48504. */
  48505. boundingBoxSize: Vector3;
  48506. /**
  48507. * Instantiates an HDRTexture from the following parameters.
  48508. *
  48509. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48510. * @param scene The scene the texture will be used in
  48511. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48512. * @param noMipmap Forces to not generate the mipmap if true
  48513. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48514. * @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)
  48515. * @param reserved Reserved flag for internal use.
  48516. */
  48517. 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>);
  48518. /**
  48519. * Get the current class name of the texture useful for serialization or dynamic coding.
  48520. * @returns "HDRCubeTexture"
  48521. */
  48522. getClassName(): string;
  48523. /**
  48524. * Occurs when the file is raw .hdr file.
  48525. */
  48526. private loadTexture;
  48527. clone(): HDRCubeTexture;
  48528. delayLoad(): void;
  48529. /**
  48530. * Get the texture reflection matrix used to rotate/transform the reflection.
  48531. * @returns the reflection matrix
  48532. */
  48533. getReflectionTextureMatrix(): Matrix;
  48534. /**
  48535. * Set the texture reflection matrix used to rotate/transform the reflection.
  48536. * @param value Define the reflection matrix to set
  48537. */
  48538. setReflectionTextureMatrix(value: Matrix): void;
  48539. /**
  48540. * Parses a JSON representation of an HDR Texture in order to create the texture
  48541. * @param parsedTexture Define the JSON representation
  48542. * @param scene Define the scene the texture should be created in
  48543. * @param rootUrl Define the root url in case we need to load relative dependencies
  48544. * @returns the newly created texture after parsing
  48545. */
  48546. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48547. serialize(): any;
  48548. }
  48549. }
  48550. declare module "babylonjs/Physics/physicsEngine" {
  48551. import { Nullable } from "babylonjs/types";
  48552. import { Vector3 } from "babylonjs/Maths/math";
  48553. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48554. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48555. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48556. /**
  48557. * Class used to control physics engine
  48558. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48559. */
  48560. export class PhysicsEngine implements IPhysicsEngine {
  48561. private _physicsPlugin;
  48562. /**
  48563. * Global value used to control the smallest number supported by the simulation
  48564. */
  48565. static Epsilon: number;
  48566. private _impostors;
  48567. private _joints;
  48568. /**
  48569. * Gets the gravity vector used by the simulation
  48570. */
  48571. gravity: Vector3;
  48572. /**
  48573. * Factory used to create the default physics plugin.
  48574. * @returns The default physics plugin
  48575. */
  48576. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48577. /**
  48578. * Creates a new Physics Engine
  48579. * @param gravity defines the gravity vector used by the simulation
  48580. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48581. */
  48582. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48583. /**
  48584. * Sets the gravity vector used by the simulation
  48585. * @param gravity defines the gravity vector to use
  48586. */
  48587. setGravity(gravity: Vector3): void;
  48588. /**
  48589. * Set the time step of the physics engine.
  48590. * Default is 1/60.
  48591. * To slow it down, enter 1/600 for example.
  48592. * To speed it up, 1/30
  48593. * @param newTimeStep defines the new timestep to apply to this world.
  48594. */
  48595. setTimeStep(newTimeStep?: number): void;
  48596. /**
  48597. * Get the time step of the physics engine.
  48598. * @returns the current time step
  48599. */
  48600. getTimeStep(): number;
  48601. /**
  48602. * Release all resources
  48603. */
  48604. dispose(): void;
  48605. /**
  48606. * Gets the name of the current physics plugin
  48607. * @returns the name of the plugin
  48608. */
  48609. getPhysicsPluginName(): string;
  48610. /**
  48611. * Adding a new impostor for the impostor tracking.
  48612. * This will be done by the impostor itself.
  48613. * @param impostor the impostor to add
  48614. */
  48615. addImpostor(impostor: PhysicsImpostor): void;
  48616. /**
  48617. * Remove an impostor from the engine.
  48618. * This impostor and its mesh will not longer be updated by the physics engine.
  48619. * @param impostor the impostor to remove
  48620. */
  48621. removeImpostor(impostor: PhysicsImpostor): void;
  48622. /**
  48623. * Add a joint to the physics engine
  48624. * @param mainImpostor defines the main impostor to which the joint is added.
  48625. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48626. * @param joint defines the joint that will connect both impostors.
  48627. */
  48628. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48629. /**
  48630. * Removes a joint from the simulation
  48631. * @param mainImpostor defines the impostor used with the joint
  48632. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48633. * @param joint defines the joint to remove
  48634. */
  48635. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48636. /**
  48637. * Called by the scene. No need to call it.
  48638. * @param delta defines the timespam between frames
  48639. */
  48640. _step(delta: number): void;
  48641. /**
  48642. * Gets the current plugin used to run the simulation
  48643. * @returns current plugin
  48644. */
  48645. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48646. /**
  48647. * Gets the list of physic impostors
  48648. * @returns an array of PhysicsImpostor
  48649. */
  48650. getImpostors(): Array<PhysicsImpostor>;
  48651. /**
  48652. * Gets the impostor for a physics enabled object
  48653. * @param object defines the object impersonated by the impostor
  48654. * @returns the PhysicsImpostor or null if not found
  48655. */
  48656. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48657. /**
  48658. * Gets the impostor for a physics body object
  48659. * @param body defines physics body used by the impostor
  48660. * @returns the PhysicsImpostor or null if not found
  48661. */
  48662. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48663. }
  48664. }
  48665. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  48666. import { Nullable } from "babylonjs/types";
  48667. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48669. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48670. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48671. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48672. /** @hidden */
  48673. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48674. private _useDeltaForWorldStep;
  48675. world: any;
  48676. name: string;
  48677. private _physicsMaterials;
  48678. private _fixedTimeStep;
  48679. BJSCANNON: any;
  48680. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48681. setGravity(gravity: Vector3): void;
  48682. setTimeStep(timeStep: number): void;
  48683. getTimeStep(): number;
  48684. executeStep(delta: number): void;
  48685. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48686. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48687. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48688. private _processChildMeshes;
  48689. removePhysicsBody(impostor: PhysicsImpostor): void;
  48690. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48691. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48692. private _addMaterial;
  48693. private _checkWithEpsilon;
  48694. private _createShape;
  48695. private _createHeightmap;
  48696. private _minus90X;
  48697. private _plus90X;
  48698. private _tmpPosition;
  48699. private _tmpDeltaPosition;
  48700. private _tmpUnityRotation;
  48701. private _updatePhysicsBodyTransformation;
  48702. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48703. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48704. isSupported(): boolean;
  48705. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48706. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48707. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48708. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48709. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48710. getBodyMass(impostor: PhysicsImpostor): number;
  48711. getBodyFriction(impostor: PhysicsImpostor): number;
  48712. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48713. getBodyRestitution(impostor: PhysicsImpostor): number;
  48714. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48715. sleepBody(impostor: PhysicsImpostor): void;
  48716. wakeUpBody(impostor: PhysicsImpostor): void;
  48717. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48718. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48719. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48720. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48721. getRadius(impostor: PhysicsImpostor): number;
  48722. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48723. dispose(): void;
  48724. private _extendNamespace;
  48725. }
  48726. }
  48727. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  48728. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  48729. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48730. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  48731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48732. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  48733. import { Nullable } from "babylonjs/types";
  48734. /** @hidden */
  48735. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48736. world: any;
  48737. name: string;
  48738. BJSOIMO: any;
  48739. constructor(iterations?: number, oimoInjection?: any);
  48740. setGravity(gravity: Vector3): void;
  48741. setTimeStep(timeStep: number): void;
  48742. getTimeStep(): number;
  48743. private _tmpImpostorsArray;
  48744. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48745. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48746. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48747. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48748. private _tmpPositionVector;
  48749. removePhysicsBody(impostor: PhysicsImpostor): void;
  48750. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48751. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48752. isSupported(): boolean;
  48753. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48754. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48755. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48756. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48757. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48758. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48759. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48760. getBodyMass(impostor: PhysicsImpostor): number;
  48761. getBodyFriction(impostor: PhysicsImpostor): number;
  48762. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48763. getBodyRestitution(impostor: PhysicsImpostor): number;
  48764. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48765. sleepBody(impostor: PhysicsImpostor): void;
  48766. wakeUpBody(impostor: PhysicsImpostor): void;
  48767. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48768. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48769. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48770. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48771. getRadius(impostor: PhysicsImpostor): number;
  48772. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48773. dispose(): void;
  48774. }
  48775. }
  48776. declare module "babylonjs/Probes/reflectionProbe" {
  48777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48778. import { Vector3 } from "babylonjs/Maths/math";
  48779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48780. import { Nullable } from "babylonjs/types";
  48781. import { Scene } from "babylonjs/scene";
  48782. module "babylonjs/abstractScene" {
  48783. interface AbstractScene {
  48784. /**
  48785. * The list of reflection probes added to the scene
  48786. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48787. */
  48788. reflectionProbes: Array<ReflectionProbe>;
  48789. /**
  48790. * Removes the given reflection probe from this scene.
  48791. * @param toRemove The reflection probe to remove
  48792. * @returns The index of the removed reflection probe
  48793. */
  48794. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48795. /**
  48796. * Adds the given reflection probe to this scene.
  48797. * @param newReflectionProbe The reflection probe to add
  48798. */
  48799. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48800. }
  48801. }
  48802. /**
  48803. * Class used to generate realtime reflection / refraction cube textures
  48804. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48805. */
  48806. export class ReflectionProbe {
  48807. /** defines the name of the probe */
  48808. name: string;
  48809. private _scene;
  48810. private _renderTargetTexture;
  48811. private _projectionMatrix;
  48812. private _viewMatrix;
  48813. private _target;
  48814. private _add;
  48815. private _attachedMesh;
  48816. private _invertYAxis;
  48817. /** Gets or sets probe position (center of the cube map) */
  48818. position: Vector3;
  48819. /**
  48820. * Creates a new reflection probe
  48821. * @param name defines the name of the probe
  48822. * @param size defines the texture resolution (for each face)
  48823. * @param scene defines the hosting scene
  48824. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48825. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48826. */
  48827. constructor(
  48828. /** defines the name of the probe */
  48829. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48830. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48831. samples: number;
  48832. /** Gets or sets the refresh rate to use (on every frame by default) */
  48833. refreshRate: number;
  48834. /**
  48835. * Gets the hosting scene
  48836. * @returns a Scene
  48837. */
  48838. getScene(): Scene;
  48839. /** Gets the internal CubeTexture used to render to */
  48840. readonly cubeTexture: RenderTargetTexture;
  48841. /** Gets the list of meshes to render */
  48842. readonly renderList: Nullable<AbstractMesh[]>;
  48843. /**
  48844. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48845. * @param mesh defines the mesh to attach to
  48846. */
  48847. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48848. /**
  48849. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48850. * @param renderingGroupId The rendering group id corresponding to its index
  48851. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48852. */
  48853. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48854. /**
  48855. * Clean all associated resources
  48856. */
  48857. dispose(): void;
  48858. /**
  48859. * Converts the reflection probe information to a readable string for debug purpose.
  48860. * @param fullDetails Supports for multiple levels of logging within scene loading
  48861. * @returns the human readable reflection probe info
  48862. */
  48863. toString(fullDetails?: boolean): string;
  48864. /**
  48865. * Get the class name of the relfection probe.
  48866. * @returns "ReflectionProbe"
  48867. */
  48868. getClassName(): string;
  48869. /**
  48870. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48871. * @returns The JSON representation of the texture
  48872. */
  48873. serialize(): any;
  48874. /**
  48875. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48876. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48877. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48878. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48879. * @returns The parsed reflection probe if successful
  48880. */
  48881. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48882. }
  48883. }
  48884. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  48885. /** @hidden */
  48886. export var _BabylonLoaderRegistered: boolean;
  48887. }
  48888. declare module "babylonjs/Loading/Plugins/index" {
  48889. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  48890. }
  48891. declare module "babylonjs/Loading/index" {
  48892. export * from "babylonjs/Loading/loadingScreen";
  48893. export * from "babylonjs/Loading/Plugins/index";
  48894. export * from "babylonjs/Loading/sceneLoader";
  48895. export * from "babylonjs/Loading/sceneLoaderFlags";
  48896. }
  48897. declare module "babylonjs/Materials/Background/index" {
  48898. export * from "babylonjs/Materials/Background/backgroundMaterial";
  48899. }
  48900. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  48901. import { Scene } from "babylonjs/scene";
  48902. import { Color3 } from "babylonjs/Maths/math";
  48903. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48905. /**
  48906. * The Physically based simple base material of BJS.
  48907. *
  48908. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48909. * It is used as the base class for both the specGloss and metalRough conventions.
  48910. */
  48911. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48912. /**
  48913. * Number of Simultaneous lights allowed on the material.
  48914. */
  48915. maxSimultaneousLights: number;
  48916. /**
  48917. * If sets to true, disables all the lights affecting the material.
  48918. */
  48919. disableLighting: boolean;
  48920. /**
  48921. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48922. */
  48923. environmentTexture: BaseTexture;
  48924. /**
  48925. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48926. */
  48927. invertNormalMapX: boolean;
  48928. /**
  48929. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48930. */
  48931. invertNormalMapY: boolean;
  48932. /**
  48933. * Normal map used in the model.
  48934. */
  48935. normalTexture: BaseTexture;
  48936. /**
  48937. * Emissivie color used to self-illuminate the model.
  48938. */
  48939. emissiveColor: Color3;
  48940. /**
  48941. * Emissivie texture used to self-illuminate the model.
  48942. */
  48943. emissiveTexture: BaseTexture;
  48944. /**
  48945. * Occlusion Channel Strenght.
  48946. */
  48947. occlusionStrength: number;
  48948. /**
  48949. * Occlusion Texture of the material (adding extra occlusion effects).
  48950. */
  48951. occlusionTexture: BaseTexture;
  48952. /**
  48953. * Defines the alpha limits in alpha test mode.
  48954. */
  48955. alphaCutOff: number;
  48956. /**
  48957. * Gets the current double sided mode.
  48958. */
  48959. /**
  48960. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48961. */
  48962. doubleSided: boolean;
  48963. /**
  48964. * Stores the pre-calculated light information of a mesh in a texture.
  48965. */
  48966. lightmapTexture: BaseTexture;
  48967. /**
  48968. * If true, the light map contains occlusion information instead of lighting info.
  48969. */
  48970. useLightmapAsShadowmap: boolean;
  48971. /**
  48972. * Instantiates a new PBRMaterial instance.
  48973. *
  48974. * @param name The material name
  48975. * @param scene The scene the material will be use in.
  48976. */
  48977. constructor(name: string, scene: Scene);
  48978. getClassName(): string;
  48979. }
  48980. }
  48981. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  48982. import { Scene } from "babylonjs/scene";
  48983. import { Color3 } from "babylonjs/Maths/math";
  48984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48985. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  48986. /**
  48987. * The PBR material of BJS following the metal roughness convention.
  48988. *
  48989. * This fits to the PBR convention in the GLTF definition:
  48990. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48991. */
  48992. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48993. /**
  48994. * The base color has two different interpretations depending on the value of metalness.
  48995. * When the material is a metal, the base color is the specific measured reflectance value
  48996. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48997. * of the material.
  48998. */
  48999. baseColor: Color3;
  49000. /**
  49001. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49002. * well as opacity information in the alpha channel.
  49003. */
  49004. baseTexture: BaseTexture;
  49005. /**
  49006. * Specifies the metallic scalar value of the material.
  49007. * Can also be used to scale the metalness values of the metallic texture.
  49008. */
  49009. metallic: number;
  49010. /**
  49011. * Specifies the roughness scalar value of the material.
  49012. * Can also be used to scale the roughness values of the metallic texture.
  49013. */
  49014. roughness: number;
  49015. /**
  49016. * Texture containing both the metallic value in the B channel and the
  49017. * roughness value in the G channel to keep better precision.
  49018. */
  49019. metallicRoughnessTexture: BaseTexture;
  49020. /**
  49021. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49022. *
  49023. * @param name The material name
  49024. * @param scene The scene the material will be use in.
  49025. */
  49026. constructor(name: string, scene: Scene);
  49027. /**
  49028. * Return the currrent class name of the material.
  49029. */
  49030. getClassName(): string;
  49031. /**
  49032. * Makes a duplicate of the current material.
  49033. * @param name - name to use for the new material.
  49034. */
  49035. clone(name: string): PBRMetallicRoughnessMaterial;
  49036. /**
  49037. * Serialize the material to a parsable JSON object.
  49038. */
  49039. serialize(): any;
  49040. /**
  49041. * Parses a JSON object correponding to the serialize function.
  49042. */
  49043. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49044. }
  49045. }
  49046. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49047. import { Scene } from "babylonjs/scene";
  49048. import { Color3 } from "babylonjs/Maths/math";
  49049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49050. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49051. /**
  49052. * The PBR material of BJS following the specular glossiness convention.
  49053. *
  49054. * This fits to the PBR convention in the GLTF definition:
  49055. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49056. */
  49057. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49058. /**
  49059. * Specifies the diffuse color of the material.
  49060. */
  49061. diffuseColor: Color3;
  49062. /**
  49063. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49064. * channel.
  49065. */
  49066. diffuseTexture: BaseTexture;
  49067. /**
  49068. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49069. */
  49070. specularColor: Color3;
  49071. /**
  49072. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49073. */
  49074. glossiness: number;
  49075. /**
  49076. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49077. */
  49078. specularGlossinessTexture: BaseTexture;
  49079. /**
  49080. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49081. *
  49082. * @param name The material name
  49083. * @param scene The scene the material will be use in.
  49084. */
  49085. constructor(name: string, scene: Scene);
  49086. /**
  49087. * Return the currrent class name of the material.
  49088. */
  49089. getClassName(): string;
  49090. /**
  49091. * Makes a duplicate of the current material.
  49092. * @param name - name to use for the new material.
  49093. */
  49094. clone(name: string): PBRSpecularGlossinessMaterial;
  49095. /**
  49096. * Serialize the material to a parsable JSON object.
  49097. */
  49098. serialize(): any;
  49099. /**
  49100. * Parses a JSON object correponding to the serialize function.
  49101. */
  49102. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49103. }
  49104. }
  49105. declare module "babylonjs/Materials/PBR/index" {
  49106. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49107. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49108. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49109. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49110. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49111. }
  49112. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49113. import { Nullable } from "babylonjs/types";
  49114. import { Scene } from "babylonjs/scene";
  49115. import { Matrix } from "babylonjs/Maths/math";
  49116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49117. /**
  49118. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49119. * It can help converting any input color in a desired output one. This can then be used to create effects
  49120. * from sepia, black and white to sixties or futuristic rendering...
  49121. *
  49122. * The only supported format is currently 3dl.
  49123. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49124. */
  49125. export class ColorGradingTexture extends BaseTexture {
  49126. /**
  49127. * The current texture matrix. (will always be identity in color grading texture)
  49128. */
  49129. private _textureMatrix;
  49130. /**
  49131. * The texture URL.
  49132. */
  49133. url: string;
  49134. /**
  49135. * Empty line regex stored for GC.
  49136. */
  49137. private static _noneEmptyLineRegex;
  49138. private _engine;
  49139. /**
  49140. * Instantiates a ColorGradingTexture from the following parameters.
  49141. *
  49142. * @param url The location of the color gradind data (currently only supporting 3dl)
  49143. * @param scene The scene the texture will be used in
  49144. */
  49145. constructor(url: string, scene: Scene);
  49146. /**
  49147. * Returns the texture matrix used in most of the material.
  49148. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49149. */
  49150. getTextureMatrix(): Matrix;
  49151. /**
  49152. * Occurs when the file being loaded is a .3dl LUT file.
  49153. */
  49154. private load3dlTexture;
  49155. /**
  49156. * Starts the loading process of the texture.
  49157. */
  49158. private loadTexture;
  49159. /**
  49160. * Clones the color gradind texture.
  49161. */
  49162. clone(): ColorGradingTexture;
  49163. /**
  49164. * Called during delayed load for textures.
  49165. */
  49166. delayLoad(): void;
  49167. /**
  49168. * Parses a color grading texture serialized by Babylon.
  49169. * @param parsedTexture The texture information being parsedTexture
  49170. * @param scene The scene to load the texture in
  49171. * @param rootUrl The root url of the data assets to load
  49172. * @return A color gradind texture
  49173. */
  49174. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49175. /**
  49176. * Serializes the LUT texture to json format.
  49177. */
  49178. serialize(): any;
  49179. }
  49180. }
  49181. declare module "babylonjs/Misc/tga" {
  49182. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49183. /**
  49184. * Based on jsTGALoader - Javascript loader for TGA file
  49185. * By Vincent Thibault
  49186. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49187. */
  49188. export class TGATools {
  49189. private static _TYPE_INDEXED;
  49190. private static _TYPE_RGB;
  49191. private static _TYPE_GREY;
  49192. private static _TYPE_RLE_INDEXED;
  49193. private static _TYPE_RLE_RGB;
  49194. private static _TYPE_RLE_GREY;
  49195. private static _ORIGIN_MASK;
  49196. private static _ORIGIN_SHIFT;
  49197. private static _ORIGIN_BL;
  49198. private static _ORIGIN_BR;
  49199. private static _ORIGIN_UL;
  49200. private static _ORIGIN_UR;
  49201. /**
  49202. * Gets the header of a TGA file
  49203. * @param data defines the TGA data
  49204. * @returns the header
  49205. */
  49206. static GetTGAHeader(data: Uint8Array): any;
  49207. /**
  49208. * Uploads TGA content to a Babylon Texture
  49209. * @hidden
  49210. */
  49211. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49212. /** @hidden */
  49213. 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;
  49214. /** @hidden */
  49215. 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;
  49216. /** @hidden */
  49217. 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;
  49218. /** @hidden */
  49219. 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;
  49220. /** @hidden */
  49221. 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;
  49222. /** @hidden */
  49223. 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;
  49224. }
  49225. }
  49226. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49227. import { Nullable } from "babylonjs/types";
  49228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49229. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49230. /**
  49231. * Implementation of the TGA Texture Loader.
  49232. * @hidden
  49233. */
  49234. export class _TGATextureLoader implements IInternalTextureLoader {
  49235. /**
  49236. * Defines wether the loader supports cascade loading the different faces.
  49237. */
  49238. readonly supportCascades: boolean;
  49239. /**
  49240. * This returns if the loader support the current file information.
  49241. * @param extension defines the file extension of the file being loaded
  49242. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49243. * @param fallback defines the fallback internal texture if any
  49244. * @param isBase64 defines whether the texture is encoded as a base64
  49245. * @param isBuffer defines whether the texture data are stored as a buffer
  49246. * @returns true if the loader can load the specified file
  49247. */
  49248. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49249. /**
  49250. * Transform the url before loading if required.
  49251. * @param rootUrl the url of the texture
  49252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49253. * @returns the transformed texture
  49254. */
  49255. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49256. /**
  49257. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49258. * @param rootUrl the url of the texture
  49259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49260. * @returns the fallback texture
  49261. */
  49262. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49263. /**
  49264. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49265. * @param data contains the texture data
  49266. * @param texture defines the BabylonJS internal texture
  49267. * @param createPolynomials will be true if polynomials have been requested
  49268. * @param onLoad defines the callback to trigger once the texture is ready
  49269. * @param onError defines the callback to trigger in case of error
  49270. */
  49271. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49272. /**
  49273. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49274. * @param data contains the texture data
  49275. * @param texture defines the BabylonJS internal texture
  49276. * @param callback defines the method to call once ready to upload
  49277. */
  49278. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49279. }
  49280. }
  49281. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49282. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49283. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49284. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49285. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49286. }
  49287. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49288. import { Scene } from "babylonjs/scene";
  49289. import { Texture } from "babylonjs/Materials/Textures/texture";
  49290. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49291. /**
  49292. * 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.
  49293. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49294. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49295. */
  49296. export class CustomProceduralTexture extends ProceduralTexture {
  49297. private _animate;
  49298. private _time;
  49299. private _config;
  49300. private _texturePath;
  49301. /**
  49302. * Instantiates a new Custom Procedural Texture.
  49303. * 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.
  49304. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49305. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49306. * @param name Define the name of the texture
  49307. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49308. * @param size Define the size of the texture to create
  49309. * @param scene Define the scene the texture belongs to
  49310. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49311. * @param generateMipMaps Define if the texture should creates mip maps or not
  49312. */
  49313. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49314. private _loadJson;
  49315. /**
  49316. * Is the texture ready to be used ? (rendered at least once)
  49317. * @returns true if ready, otherwise, false.
  49318. */
  49319. isReady(): boolean;
  49320. /**
  49321. * Render the texture to its associated render target.
  49322. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49323. */
  49324. render(useCameraPostProcess?: boolean): void;
  49325. /**
  49326. * Update the list of dependant textures samplers in the shader.
  49327. */
  49328. updateTextures(): void;
  49329. /**
  49330. * Update the uniform values of the procedural texture in the shader.
  49331. */
  49332. updateShaderUniforms(): void;
  49333. /**
  49334. * Define if the texture animates or not.
  49335. */
  49336. animate: boolean;
  49337. }
  49338. }
  49339. declare module "babylonjs/Shaders/noise.fragment" {
  49340. /** @hidden */
  49341. export var noisePixelShader: {
  49342. name: string;
  49343. shader: string;
  49344. };
  49345. }
  49346. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49347. import { Nullable } from "babylonjs/types";
  49348. import { Scene } from "babylonjs/scene";
  49349. import { Texture } from "babylonjs/Materials/Textures/texture";
  49350. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49351. import "babylonjs/Shaders/noise.fragment";
  49352. /**
  49353. * Class used to generate noise procedural textures
  49354. */
  49355. export class NoiseProceduralTexture extends ProceduralTexture {
  49356. private _time;
  49357. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49358. brightness: number;
  49359. /** Defines the number of octaves to process */
  49360. octaves: number;
  49361. /** Defines the level of persistence (0.8 by default) */
  49362. persistence: number;
  49363. /** Gets or sets animation speed factor (default is 1) */
  49364. animationSpeedFactor: number;
  49365. /**
  49366. * Creates a new NoiseProceduralTexture
  49367. * @param name defines the name fo the texture
  49368. * @param size defines the size of the texture (default is 256)
  49369. * @param scene defines the hosting scene
  49370. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49371. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49372. */
  49373. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49374. private _updateShaderUniforms;
  49375. protected _getDefines(): string;
  49376. /** Generate the current state of the procedural texture */
  49377. render(useCameraPostProcess?: boolean): void;
  49378. /**
  49379. * Serializes this noise procedural texture
  49380. * @returns a serialized noise procedural texture object
  49381. */
  49382. serialize(): any;
  49383. /**
  49384. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49385. * @param parsedTexture defines parsed texture data
  49386. * @param scene defines the current scene
  49387. * @param rootUrl defines the root URL containing noise procedural texture information
  49388. * @returns a parsed NoiseProceduralTexture
  49389. */
  49390. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49391. }
  49392. }
  49393. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49394. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49395. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49396. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49397. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49398. }
  49399. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49400. import { Nullable } from "babylonjs/types";
  49401. import { Scene } from "babylonjs/scene";
  49402. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49404. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49405. /**
  49406. * Raw cube texture where the raw buffers are passed in
  49407. */
  49408. export class RawCubeTexture extends CubeTexture {
  49409. /**
  49410. * Creates a cube texture where the raw buffers are passed in.
  49411. * @param scene defines the scene the texture is attached to
  49412. * @param data defines the array of data to use to create each face
  49413. * @param size defines the size of the textures
  49414. * @param format defines the format of the data
  49415. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49416. * @param generateMipMaps defines if the engine should generate the mip levels
  49417. * @param invertY defines if data must be stored with Y axis inverted
  49418. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49419. * @param compression defines the compression used (null by default)
  49420. */
  49421. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49422. /**
  49423. * Updates the raw cube texture.
  49424. * @param data defines the data to store
  49425. * @param format defines the data format
  49426. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49427. * @param invertY defines if data must be stored with Y axis inverted
  49428. * @param compression defines the compression used (null by default)
  49429. * @param level defines which level of the texture to update
  49430. */
  49431. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49432. /**
  49433. * Updates a raw cube texture with RGBD encoded data.
  49434. * @param data defines the array of data [mipmap][face] to use to create each face
  49435. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49436. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49437. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49438. * @returns a promsie that resolves when the operation is complete
  49439. */
  49440. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49441. /**
  49442. * Clones the raw cube texture.
  49443. * @return a new cube texture
  49444. */
  49445. clone(): CubeTexture;
  49446. /** @hidden */
  49447. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49448. }
  49449. }
  49450. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49451. import { Scene } from "babylonjs/scene";
  49452. import { Texture } from "babylonjs/Materials/Textures/texture";
  49453. /**
  49454. * Class used to store 3D textures containing user data
  49455. */
  49456. export class RawTexture3D extends Texture {
  49457. /** Gets or sets the texture format to use */
  49458. format: number;
  49459. private _engine;
  49460. /**
  49461. * Create a new RawTexture3D
  49462. * @param data defines the data of the texture
  49463. * @param width defines the width of the texture
  49464. * @param height defines the height of the texture
  49465. * @param depth defines the depth of the texture
  49466. * @param format defines the texture format to use
  49467. * @param scene defines the hosting scene
  49468. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49469. * @param invertY defines if texture must be stored with Y axis inverted
  49470. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49471. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49472. */
  49473. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49474. /** Gets or sets the texture format to use */
  49475. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49476. /**
  49477. * Update the texture with new data
  49478. * @param data defines the data to store in the texture
  49479. */
  49480. update(data: ArrayBufferView): void;
  49481. }
  49482. }
  49483. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49484. import { Scene } from "babylonjs/scene";
  49485. import { Plane } from "babylonjs/Maths/math";
  49486. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49487. /**
  49488. * Creates a refraction texture used by refraction channel of the standard material.
  49489. * It is like a mirror but to see through a material.
  49490. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49491. */
  49492. export class RefractionTexture extends RenderTargetTexture {
  49493. /**
  49494. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49495. * 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.
  49496. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49497. */
  49498. refractionPlane: Plane;
  49499. /**
  49500. * Define how deep under the surface we should see.
  49501. */
  49502. depth: number;
  49503. /**
  49504. * Creates a refraction texture used by refraction channel of the standard material.
  49505. * It is like a mirror but to see through a material.
  49506. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49507. * @param name Define the texture name
  49508. * @param size Define the size of the underlying texture
  49509. * @param scene Define the scene the refraction belongs to
  49510. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49511. */
  49512. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49513. /**
  49514. * Clone the refraction texture.
  49515. * @returns the cloned texture
  49516. */
  49517. clone(): RefractionTexture;
  49518. /**
  49519. * Serialize the texture to a JSON representation you could use in Parse later on
  49520. * @returns the serialized JSON representation
  49521. */
  49522. serialize(): any;
  49523. }
  49524. }
  49525. declare module "babylonjs/Materials/Textures/index" {
  49526. export * from "babylonjs/Materials/Textures/baseTexture";
  49527. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  49528. export * from "babylonjs/Materials/Textures/cubeTexture";
  49529. export * from "babylonjs/Materials/Textures/dynamicTexture";
  49530. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  49531. export * from "babylonjs/Materials/Textures/internalTexture";
  49532. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  49533. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  49534. export * from "babylonjs/Materials/Textures/Loaders/index";
  49535. export * from "babylonjs/Materials/Textures/mirrorTexture";
  49536. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  49537. export * from "babylonjs/Materials/Textures/Procedurals/index";
  49538. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  49539. export * from "babylonjs/Materials/Textures/rawTexture";
  49540. export * from "babylonjs/Materials/Textures/rawTexture3D";
  49541. export * from "babylonjs/Materials/Textures/refractionTexture";
  49542. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  49543. export * from "babylonjs/Materials/Textures/texture";
  49544. export * from "babylonjs/Materials/Textures/videoTexture";
  49545. }
  49546. declare module "babylonjs/Materials/index" {
  49547. export * from "babylonjs/Materials/Background/index";
  49548. export * from "babylonjs/Materials/colorCurves";
  49549. export * from "babylonjs/Materials/effect";
  49550. export * from "babylonjs/Materials/fresnelParameters";
  49551. export * from "babylonjs/Materials/imageProcessingConfiguration";
  49552. export * from "babylonjs/Materials/material";
  49553. export * from "babylonjs/Materials/materialDefines";
  49554. export * from "babylonjs/Materials/materialHelper";
  49555. export * from "babylonjs/Materials/multiMaterial";
  49556. export * from "babylonjs/Materials/PBR/index";
  49557. export * from "babylonjs/Materials/pushMaterial";
  49558. export * from "babylonjs/Materials/shaderMaterial";
  49559. export * from "babylonjs/Materials/standardMaterial";
  49560. export * from "babylonjs/Materials/Textures/index";
  49561. export * from "babylonjs/Materials/uniformBuffer";
  49562. export * from "babylonjs/Materials/materialFlags";
  49563. }
  49564. declare module "babylonjs/Maths/index" {
  49565. export * from "babylonjs/Maths/math.scalar";
  49566. export * from "babylonjs/Maths/math";
  49567. export * from "babylonjs/Maths/sphericalPolynomial";
  49568. }
  49569. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  49570. import { IDisposable } from "babylonjs/scene";
  49571. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  49572. /**
  49573. * Configuration for Draco compression
  49574. */
  49575. export interface IDracoCompressionConfiguration {
  49576. /**
  49577. * Configuration for the decoder.
  49578. */
  49579. decoder?: {
  49580. /**
  49581. * The url to the WebAssembly module.
  49582. */
  49583. wasmUrl?: string;
  49584. /**
  49585. * The url to the WebAssembly binary.
  49586. */
  49587. wasmBinaryUrl?: string;
  49588. /**
  49589. * The url to the fallback JavaScript module.
  49590. */
  49591. fallbackUrl?: string;
  49592. };
  49593. }
  49594. /**
  49595. * Draco compression (https://google.github.io/draco/)
  49596. *
  49597. * This class wraps the Draco module.
  49598. *
  49599. * **Encoder**
  49600. *
  49601. * The encoder is not currently implemented.
  49602. *
  49603. * **Decoder**
  49604. *
  49605. * 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.
  49606. *
  49607. * To update the configuration, use the following code:
  49608. * ```javascript
  49609. * DracoCompression.Configuration = {
  49610. * decoder: {
  49611. * wasmUrl: "<url to the WebAssembly library>",
  49612. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49613. * fallbackUrl: "<url to the fallback JavaScript library>",
  49614. * }
  49615. * };
  49616. * ```
  49617. *
  49618. * 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.
  49619. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49620. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  49621. *
  49622. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  49623. * ```javascript
  49624. * var dracoCompression = new DracoCompression();
  49625. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  49626. * [VertexBuffer.PositionKind]: 0
  49627. * });
  49628. * ```
  49629. *
  49630. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49631. */
  49632. export class DracoCompression implements IDisposable {
  49633. private static _DecoderModulePromise;
  49634. /**
  49635. * The configuration. Defaults to the following urls:
  49636. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49637. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49638. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49639. */
  49640. static Configuration: IDracoCompressionConfiguration;
  49641. /**
  49642. * Returns true if the decoder is available.
  49643. */
  49644. static readonly DecoderAvailable: boolean;
  49645. /**
  49646. * Constructor
  49647. */
  49648. constructor();
  49649. /**
  49650. * Stop all async operations and release resources.
  49651. */
  49652. dispose(): void;
  49653. /**
  49654. * Decode Draco compressed mesh data to vertex data.
  49655. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49656. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49657. * @returns A promise that resolves with the decoded vertex data
  49658. */
  49659. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  49660. [kind: string]: number;
  49661. }): Promise<VertexData>;
  49662. private static _GetDecoderModule;
  49663. private static _LoadScriptAsync;
  49664. private static _LoadFileAsync;
  49665. }
  49666. }
  49667. declare module "babylonjs/Meshes/Compression/index" {
  49668. export * from "babylonjs/Meshes/Compression/dracoCompression";
  49669. }
  49670. declare module "babylonjs/Meshes/csg" {
  49671. import { Nullable } from "babylonjs/types";
  49672. import { Scene } from "babylonjs/scene";
  49673. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  49674. import { Mesh } from "babylonjs/Meshes/mesh";
  49675. import { Material } from "babylonjs/Materials/material";
  49676. /**
  49677. * Class for building Constructive Solid Geometry
  49678. */
  49679. export class CSG {
  49680. private polygons;
  49681. /**
  49682. * The world matrix
  49683. */
  49684. matrix: Matrix;
  49685. /**
  49686. * Stores the position
  49687. */
  49688. position: Vector3;
  49689. /**
  49690. * Stores the rotation
  49691. */
  49692. rotation: Vector3;
  49693. /**
  49694. * Stores the rotation quaternion
  49695. */
  49696. rotationQuaternion: Nullable<Quaternion>;
  49697. /**
  49698. * Stores the scaling vector
  49699. */
  49700. scaling: Vector3;
  49701. /**
  49702. * Convert the Mesh to CSG
  49703. * @param mesh The Mesh to convert to CSG
  49704. * @returns A new CSG from the Mesh
  49705. */
  49706. static FromMesh(mesh: Mesh): CSG;
  49707. /**
  49708. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49709. * @param polygons Polygons used to construct a CSG solid
  49710. */
  49711. private static FromPolygons;
  49712. /**
  49713. * Clones, or makes a deep copy, of the CSG
  49714. * @returns A new CSG
  49715. */
  49716. clone(): CSG;
  49717. /**
  49718. * Unions this CSG with another CSG
  49719. * @param csg The CSG to union against this CSG
  49720. * @returns The unioned CSG
  49721. */
  49722. union(csg: CSG): CSG;
  49723. /**
  49724. * Unions this CSG with another CSG in place
  49725. * @param csg The CSG to union against this CSG
  49726. */
  49727. unionInPlace(csg: CSG): void;
  49728. /**
  49729. * Subtracts this CSG with another CSG
  49730. * @param csg The CSG to subtract against this CSG
  49731. * @returns A new CSG
  49732. */
  49733. subtract(csg: CSG): CSG;
  49734. /**
  49735. * Subtracts this CSG with another CSG in place
  49736. * @param csg The CSG to subtact against this CSG
  49737. */
  49738. subtractInPlace(csg: CSG): void;
  49739. /**
  49740. * Intersect this CSG with another CSG
  49741. * @param csg The CSG to intersect against this CSG
  49742. * @returns A new CSG
  49743. */
  49744. intersect(csg: CSG): CSG;
  49745. /**
  49746. * Intersects this CSG with another CSG in place
  49747. * @param csg The CSG to intersect against this CSG
  49748. */
  49749. intersectInPlace(csg: CSG): void;
  49750. /**
  49751. * Return a new CSG solid with solid and empty space switched. This solid is
  49752. * not modified.
  49753. * @returns A new CSG solid with solid and empty space switched
  49754. */
  49755. inverse(): CSG;
  49756. /**
  49757. * Inverses the CSG in place
  49758. */
  49759. inverseInPlace(): void;
  49760. /**
  49761. * This is used to keep meshes transformations so they can be restored
  49762. * when we build back a Babylon Mesh
  49763. * NB : All CSG operations are performed in world coordinates
  49764. * @param csg The CSG to copy the transform attributes from
  49765. * @returns This CSG
  49766. */
  49767. copyTransformAttributes(csg: CSG): CSG;
  49768. /**
  49769. * Build Raw mesh from CSG
  49770. * Coordinates here are in world space
  49771. * @param name The name of the mesh geometry
  49772. * @param scene The Scene
  49773. * @param keepSubMeshes Specifies if the submeshes should be kept
  49774. * @returns A new Mesh
  49775. */
  49776. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49777. /**
  49778. * Build Mesh from CSG taking material and transforms into account
  49779. * @param name The name of the Mesh
  49780. * @param material The material of the Mesh
  49781. * @param scene The Scene
  49782. * @param keepSubMeshes Specifies if submeshes should be kept
  49783. * @returns The new Mesh
  49784. */
  49785. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49786. }
  49787. }
  49788. declare module "babylonjs/Meshes/trailMesh" {
  49789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49790. import { Mesh } from "babylonjs/Meshes/mesh";
  49791. import { Scene } from "babylonjs/scene";
  49792. /**
  49793. * Class used to create a trail following a mesh
  49794. */
  49795. export class TrailMesh extends Mesh {
  49796. private _generator;
  49797. private _autoStart;
  49798. private _running;
  49799. private _diameter;
  49800. private _length;
  49801. private _sectionPolygonPointsCount;
  49802. private _sectionVectors;
  49803. private _sectionNormalVectors;
  49804. private _beforeRenderObserver;
  49805. /**
  49806. * @constructor
  49807. * @param name The value used by scene.getMeshByName() to do a lookup.
  49808. * @param generator The mesh to generate a trail.
  49809. * @param scene The scene to add this mesh to.
  49810. * @param diameter Diameter of trailing mesh. Default is 1.
  49811. * @param length Length of trailing mesh. Default is 60.
  49812. * @param autoStart Automatically start trailing mesh. Default true.
  49813. */
  49814. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49815. /**
  49816. * "TrailMesh"
  49817. * @returns "TrailMesh"
  49818. */
  49819. getClassName(): string;
  49820. private _createMesh;
  49821. /**
  49822. * Start trailing mesh.
  49823. */
  49824. start(): void;
  49825. /**
  49826. * Stop trailing mesh.
  49827. */
  49828. stop(): void;
  49829. /**
  49830. * Update trailing mesh geometry.
  49831. */
  49832. update(): void;
  49833. /**
  49834. * Returns a new TrailMesh object.
  49835. * @param name is a string, the name given to the new mesh
  49836. * @param newGenerator use new generator object for cloned trail mesh
  49837. * @returns a new mesh
  49838. */
  49839. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49840. /**
  49841. * Serializes this trail mesh
  49842. * @param serializationObject object to write serialization to
  49843. */
  49844. serialize(serializationObject: any): void;
  49845. /**
  49846. * Parses a serialized trail mesh
  49847. * @param parsedMesh the serialized mesh
  49848. * @param scene the scene to create the trail mesh in
  49849. * @returns the created trail mesh
  49850. */
  49851. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49852. }
  49853. }
  49854. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  49855. import { Nullable } from "babylonjs/types";
  49856. import { Scene } from "babylonjs/scene";
  49857. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  49858. import { Mesh } from "babylonjs/Meshes/mesh";
  49859. /**
  49860. * Class containing static functions to help procedurally build meshes
  49861. */
  49862. export class RibbonBuilder {
  49863. /**
  49864. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49865. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49866. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49867. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49868. * * 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
  49869. * * 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
  49870. * * 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
  49871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49873. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49874. * * 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
  49875. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49876. * * 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
  49877. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49879. * @param name defines the name of the mesh
  49880. * @param options defines the options used to create the mesh
  49881. * @param scene defines the hosting scene
  49882. * @returns the ribbon mesh
  49883. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49884. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49885. */
  49886. static CreateRibbon(name: string, options: {
  49887. pathArray: Vector3[][];
  49888. closeArray?: boolean;
  49889. closePath?: boolean;
  49890. offset?: number;
  49891. updatable?: boolean;
  49892. sideOrientation?: number;
  49893. frontUVs?: Vector4;
  49894. backUVs?: Vector4;
  49895. instance?: Mesh;
  49896. invertUV?: boolean;
  49897. uvs?: Vector2[];
  49898. colors?: Color4[];
  49899. }, scene?: Nullable<Scene>): Mesh;
  49900. }
  49901. }
  49902. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  49903. import { Vector4 } from "babylonjs/Maths/math";
  49904. import { Mesh } from "babylonjs/Meshes/mesh";
  49905. /**
  49906. * Class containing static functions to help procedurally build meshes
  49907. */
  49908. export class TorusKnotBuilder {
  49909. /**
  49910. * Creates a torus knot mesh
  49911. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49912. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49913. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49914. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49918. * @param name defines the name of the mesh
  49919. * @param options defines the options used to create the mesh
  49920. * @param scene defines the hosting scene
  49921. * @returns the torus knot mesh
  49922. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49923. */
  49924. static CreateTorusKnot(name: string, options: {
  49925. radius?: number;
  49926. tube?: number;
  49927. radialSegments?: number;
  49928. tubularSegments?: number;
  49929. p?: number;
  49930. q?: number;
  49931. updatable?: boolean;
  49932. sideOrientation?: number;
  49933. frontUVs?: Vector4;
  49934. backUVs?: Vector4;
  49935. }, scene: any): Mesh;
  49936. }
  49937. }
  49938. declare module "babylonjs/Meshes/polygonMesh" {
  49939. import { Scene } from "babylonjs/scene";
  49940. import { Vector2, Path2 } from "babylonjs/Maths/math";
  49941. import { Mesh } from "babylonjs/Meshes/mesh";
  49942. /**
  49943. * Polygon
  49944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49945. */
  49946. export class Polygon {
  49947. /**
  49948. * Creates a rectangle
  49949. * @param xmin bottom X coord
  49950. * @param ymin bottom Y coord
  49951. * @param xmax top X coord
  49952. * @param ymax top Y coord
  49953. * @returns points that make the resulting rectation
  49954. */
  49955. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49956. /**
  49957. * Creates a circle
  49958. * @param radius radius of circle
  49959. * @param cx scale in x
  49960. * @param cy scale in y
  49961. * @param numberOfSides number of sides that make up the circle
  49962. * @returns points that make the resulting circle
  49963. */
  49964. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49965. /**
  49966. * Creates a polygon from input string
  49967. * @param input Input polygon data
  49968. * @returns the parsed points
  49969. */
  49970. static Parse(input: string): Vector2[];
  49971. /**
  49972. * Starts building a polygon from x and y coordinates
  49973. * @param x x coordinate
  49974. * @param y y coordinate
  49975. * @returns the started path2
  49976. */
  49977. static StartingAt(x: number, y: number): Path2;
  49978. }
  49979. /**
  49980. * Builds a polygon
  49981. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49982. */
  49983. export class PolygonMeshBuilder {
  49984. private _points;
  49985. private _outlinepoints;
  49986. private _holes;
  49987. private _name;
  49988. private _scene;
  49989. private _epoints;
  49990. private _eholes;
  49991. private _addToepoint;
  49992. /**
  49993. * Babylon reference to the earcut plugin.
  49994. */
  49995. bjsEarcut: any;
  49996. /**
  49997. * Creates a PolygonMeshBuilder
  49998. * @param name name of the builder
  49999. * @param contours Path of the polygon
  50000. * @param scene scene to add to
  50001. * @param earcutInjection can be used to inject your own earcut reference
  50002. */
  50003. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  50004. /**
  50005. * Adds a whole within the polygon
  50006. * @param hole Array of points defining the hole
  50007. * @returns this
  50008. */
  50009. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50010. /**
  50011. * Creates the polygon
  50012. * @param updatable If the mesh should be updatable
  50013. * @param depth The depth of the mesh created
  50014. * @returns the created mesh
  50015. */
  50016. build(updatable?: boolean, depth?: number): Mesh;
  50017. /**
  50018. * Adds a side to the polygon
  50019. * @param positions points that make the polygon
  50020. * @param normals normals of the polygon
  50021. * @param uvs uvs of the polygon
  50022. * @param indices indices of the polygon
  50023. * @param bounds bounds of the polygon
  50024. * @param points points of the polygon
  50025. * @param depth depth of the polygon
  50026. * @param flip flip of the polygon
  50027. */
  50028. private addSide;
  50029. }
  50030. }
  50031. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50032. import { Scene } from "babylonjs/scene";
  50033. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50034. import { Mesh } from "babylonjs/Meshes/mesh";
  50035. /**
  50036. * Class containing static functions to help procedurally build meshes
  50037. */
  50038. export class PolygonBuilder {
  50039. /**
  50040. * Creates a polygon mesh
  50041. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50042. * * 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
  50043. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50046. * * Remember you can only change the shape positions, not their number when updating a polygon
  50047. * @param name defines the name of the mesh
  50048. * @param options defines the options used to create the mesh
  50049. * @param scene defines the hosting scene
  50050. * @param earcutInjection can be used to inject your own earcut reference
  50051. * @returns the polygon mesh
  50052. */
  50053. static CreatePolygon(name: string, options: {
  50054. shape: Vector3[];
  50055. holes?: Vector3[][];
  50056. depth?: number;
  50057. faceUV?: Vector4[];
  50058. faceColors?: Color4[];
  50059. updatable?: boolean;
  50060. sideOrientation?: number;
  50061. frontUVs?: Vector4;
  50062. backUVs?: Vector4;
  50063. }, scene: Scene, earcutInjection?: any): Mesh;
  50064. /**
  50065. * Creates an extruded polygon mesh, with depth in the Y direction.
  50066. * * 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)
  50067. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50068. * @param name defines the name of the mesh
  50069. * @param options defines the options used to create the mesh
  50070. * @param scene defines the hosting scene
  50071. * @param earcutInjection can be used to inject your own earcut reference
  50072. * @returns the polygon mesh
  50073. */
  50074. static ExtrudePolygon(name: string, options: {
  50075. shape: Vector3[];
  50076. holes?: Vector3[][];
  50077. depth?: number;
  50078. faceUV?: Vector4[];
  50079. faceColors?: Color4[];
  50080. updatable?: boolean;
  50081. sideOrientation?: number;
  50082. frontUVs?: Vector4;
  50083. backUVs?: Vector4;
  50084. }, scene: Scene, earcutInjection?: any): Mesh;
  50085. }
  50086. }
  50087. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50088. import { Nullable } from "babylonjs/types";
  50089. import { Scene } from "babylonjs/scene";
  50090. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50091. import { Mesh } from "babylonjs/Meshes/mesh";
  50092. /**
  50093. * Class containing static functions to help procedurally build meshes
  50094. */
  50095. export class ShapeBuilder {
  50096. /**
  50097. * 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.
  50098. * * 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.
  50099. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50100. * * 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.
  50101. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50102. * * 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
  50103. * * 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
  50104. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50107. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50109. * @param name defines the name of the mesh
  50110. * @param options defines the options used to create the mesh
  50111. * @param scene defines the hosting scene
  50112. * @returns the extruded shape mesh
  50113. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50114. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50115. */
  50116. static ExtrudeShape(name: string, options: {
  50117. shape: Vector3[];
  50118. path: Vector3[];
  50119. scale?: number;
  50120. rotation?: number;
  50121. cap?: number;
  50122. updatable?: boolean;
  50123. sideOrientation?: number;
  50124. frontUVs?: Vector4;
  50125. backUVs?: Vector4;
  50126. instance?: Mesh;
  50127. invertUV?: boolean;
  50128. }, scene?: Nullable<Scene>): Mesh;
  50129. /**
  50130. * Creates an custom extruded shape mesh.
  50131. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50132. * * 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.
  50133. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50134. * * 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
  50135. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50136. * * 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
  50137. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50138. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50139. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50140. * * 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
  50141. * * 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
  50142. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50145. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50147. * @param name defines the name of the mesh
  50148. * @param options defines the options used to create the mesh
  50149. * @param scene defines the hosting scene
  50150. * @returns the custom extruded shape mesh
  50151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50152. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50153. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50154. */
  50155. static ExtrudeShapeCustom(name: string, options: {
  50156. shape: Vector3[];
  50157. path: Vector3[];
  50158. scaleFunction?: any;
  50159. rotationFunction?: any;
  50160. ribbonCloseArray?: boolean;
  50161. ribbonClosePath?: boolean;
  50162. cap?: number;
  50163. updatable?: boolean;
  50164. sideOrientation?: number;
  50165. frontUVs?: Vector4;
  50166. backUVs?: Vector4;
  50167. instance?: Mesh;
  50168. invertUV?: boolean;
  50169. }, scene: Scene): Mesh;
  50170. private static _ExtrudeShapeGeneric;
  50171. }
  50172. }
  50173. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50174. import { Scene } from "babylonjs/scene";
  50175. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50176. import { Mesh } from "babylonjs/Meshes/mesh";
  50177. /**
  50178. * Class containing static functions to help procedurally build meshes
  50179. */
  50180. export class LatheBuilder {
  50181. /**
  50182. * Creates lathe mesh.
  50183. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50184. * * 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
  50185. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50186. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50187. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50188. * * 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
  50189. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50190. * * 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
  50191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50192. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50193. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50195. * @param name defines the name of the mesh
  50196. * @param options defines the options used to create the mesh
  50197. * @param scene defines the hosting scene
  50198. * @returns the lathe mesh
  50199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50200. */
  50201. static CreateLathe(name: string, options: {
  50202. shape: Vector3[];
  50203. radius?: number;
  50204. tessellation?: number;
  50205. clip?: number;
  50206. arc?: number;
  50207. closed?: boolean;
  50208. updatable?: boolean;
  50209. sideOrientation?: number;
  50210. frontUVs?: Vector4;
  50211. backUVs?: Vector4;
  50212. cap?: number;
  50213. invertUV?: boolean;
  50214. }, scene: Scene): Mesh;
  50215. }
  50216. }
  50217. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50218. import { Scene } from "babylonjs/scene";
  50219. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50220. import { Mesh } from "babylonjs/Meshes/mesh";
  50221. /**
  50222. * Class containing static functions to help procedurally build meshes
  50223. */
  50224. export class TubeBuilder {
  50225. /**
  50226. * Creates a tube mesh.
  50227. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50228. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50229. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50230. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50231. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50232. * * 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)
  50233. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50234. * * 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
  50235. * * 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
  50236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50237. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50238. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50240. * @param name defines the name of the mesh
  50241. * @param options defines the options used to create the mesh
  50242. * @param scene defines the hosting scene
  50243. * @returns the tube mesh
  50244. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50245. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50246. */
  50247. static CreateTube(name: string, options: {
  50248. path: Vector3[];
  50249. radius?: number;
  50250. tessellation?: number;
  50251. radiusFunction?: {
  50252. (i: number, distance: number): number;
  50253. };
  50254. cap?: number;
  50255. arc?: number;
  50256. updatable?: boolean;
  50257. sideOrientation?: number;
  50258. frontUVs?: Vector4;
  50259. backUVs?: Vector4;
  50260. instance?: Mesh;
  50261. invertUV?: boolean;
  50262. }, scene: Scene): Mesh;
  50263. }
  50264. }
  50265. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50266. import { Scene } from "babylonjs/scene";
  50267. import { Vector4 } from "babylonjs/Maths/math";
  50268. import { Mesh } from "babylonjs/Meshes/mesh";
  50269. /**
  50270. * Class containing static functions to help procedurally build meshes
  50271. */
  50272. export class IcoSphereBuilder {
  50273. /**
  50274. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50275. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50276. * * 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`)
  50277. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50278. * * 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
  50279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50282. * @param name defines the name of the mesh
  50283. * @param options defines the options used to create the mesh
  50284. * @param scene defines the hosting scene
  50285. * @returns the icosahedron mesh
  50286. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50287. */
  50288. static CreateIcoSphere(name: string, options: {
  50289. radius?: number;
  50290. radiusX?: number;
  50291. radiusY?: number;
  50292. radiusZ?: number;
  50293. flat?: boolean;
  50294. subdivisions?: number;
  50295. sideOrientation?: number;
  50296. frontUVs?: Vector4;
  50297. backUVs?: Vector4;
  50298. updatable?: boolean;
  50299. }, scene: Scene): Mesh;
  50300. }
  50301. }
  50302. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50303. import { Vector3 } from "babylonjs/Maths/math";
  50304. import { Mesh } from "babylonjs/Meshes/mesh";
  50305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50306. /**
  50307. * Class containing static functions to help procedurally build meshes
  50308. */
  50309. export class DecalBuilder {
  50310. /**
  50311. * Creates a decal mesh.
  50312. * 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
  50313. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50314. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50315. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50316. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50317. * @param name defines the name of the mesh
  50318. * @param sourceMesh defines the mesh where the decal must be applied
  50319. * @param options defines the options used to create the mesh
  50320. * @param scene defines the hosting scene
  50321. * @returns the decal mesh
  50322. * @see https://doc.babylonjs.com/how_to/decals
  50323. */
  50324. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50325. position?: Vector3;
  50326. normal?: Vector3;
  50327. size?: Vector3;
  50328. angle?: number;
  50329. }): Mesh;
  50330. }
  50331. }
  50332. declare module "babylonjs/Meshes/meshBuilder" {
  50333. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50334. import { Nullable } from "babylonjs/types";
  50335. import { Scene } from "babylonjs/scene";
  50336. import { Mesh } from "babylonjs/Meshes/mesh";
  50337. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50338. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50340. /**
  50341. * Class containing static functions to help procedurally build meshes
  50342. */
  50343. export class MeshBuilder {
  50344. /**
  50345. * Creates a box mesh
  50346. * * The parameter `size` sets the size (float) of each box side (default 1)
  50347. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50348. * * 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)
  50349. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50353. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50354. * @param name defines the name of the mesh
  50355. * @param options defines the options used to create the mesh
  50356. * @param scene defines the hosting scene
  50357. * @returns the box mesh
  50358. */
  50359. static CreateBox(name: string, options: {
  50360. size?: number;
  50361. width?: number;
  50362. height?: number;
  50363. depth?: number;
  50364. faceUV?: Vector4[];
  50365. faceColors?: Color4[];
  50366. sideOrientation?: number;
  50367. frontUVs?: Vector4;
  50368. backUVs?: Vector4;
  50369. updatable?: boolean;
  50370. }, scene?: Nullable<Scene>): Mesh;
  50371. /**
  50372. * Creates a sphere mesh
  50373. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50374. * * 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`)
  50375. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50376. * * 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
  50377. * * 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)
  50378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50381. * @param name defines the name of the mesh
  50382. * @param options defines the options used to create the mesh
  50383. * @param scene defines the hosting scene
  50384. * @returns the sphere mesh
  50385. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50386. */
  50387. static CreateSphere(name: string, options: {
  50388. segments?: number;
  50389. diameter?: number;
  50390. diameterX?: number;
  50391. diameterY?: number;
  50392. diameterZ?: number;
  50393. arc?: number;
  50394. slice?: number;
  50395. sideOrientation?: number;
  50396. frontUVs?: Vector4;
  50397. backUVs?: Vector4;
  50398. updatable?: boolean;
  50399. }, scene: any): Mesh;
  50400. /**
  50401. * Creates a plane polygonal mesh. By default, this is a disc
  50402. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50403. * * 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
  50404. * * 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
  50405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50408. * @param name defines the name of the mesh
  50409. * @param options defines the options used to create the mesh
  50410. * @param scene defines the hosting scene
  50411. * @returns the plane polygonal mesh
  50412. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50413. */
  50414. static CreateDisc(name: string, options: {
  50415. radius?: number;
  50416. tessellation?: number;
  50417. arc?: number;
  50418. updatable?: boolean;
  50419. sideOrientation?: number;
  50420. frontUVs?: Vector4;
  50421. backUVs?: Vector4;
  50422. }, scene?: Nullable<Scene>): Mesh;
  50423. /**
  50424. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50425. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50426. * * 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`)
  50427. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50428. * * 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
  50429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50432. * @param name defines the name of the mesh
  50433. * @param options defines the options used to create the mesh
  50434. * @param scene defines the hosting scene
  50435. * @returns the icosahedron mesh
  50436. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50437. */
  50438. static CreateIcoSphere(name: string, options: {
  50439. radius?: number;
  50440. radiusX?: number;
  50441. radiusY?: number;
  50442. radiusZ?: number;
  50443. flat?: boolean;
  50444. subdivisions?: number;
  50445. sideOrientation?: number;
  50446. frontUVs?: Vector4;
  50447. backUVs?: Vector4;
  50448. updatable?: boolean;
  50449. }, scene: Scene): Mesh;
  50450. /**
  50451. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50452. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50453. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50454. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50455. * * 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
  50456. * * 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
  50457. * * 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
  50458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50461. * * 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
  50462. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50463. * * 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
  50464. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50466. * @param name defines the name of the mesh
  50467. * @param options defines the options used to create the mesh
  50468. * @param scene defines the hosting scene
  50469. * @returns the ribbon mesh
  50470. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50471. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50472. */
  50473. static CreateRibbon(name: string, options: {
  50474. pathArray: Vector3[][];
  50475. closeArray?: boolean;
  50476. closePath?: boolean;
  50477. offset?: number;
  50478. updatable?: boolean;
  50479. sideOrientation?: number;
  50480. frontUVs?: Vector4;
  50481. backUVs?: Vector4;
  50482. instance?: Mesh;
  50483. invertUV?: boolean;
  50484. uvs?: Vector2[];
  50485. colors?: Color4[];
  50486. }, scene?: Nullable<Scene>): Mesh;
  50487. /**
  50488. * Creates a cylinder or a cone mesh
  50489. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50490. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50491. * * 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.
  50492. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50493. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50494. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50495. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50496. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50497. * * 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).
  50498. * * 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
  50499. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50500. * * 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
  50501. * * 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.
  50502. * * If `enclose` is false, a ring surface is one element.
  50503. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50504. * * 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
  50505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50508. * @param name defines the name of the mesh
  50509. * @param options defines the options used to create the mesh
  50510. * @param scene defines the hosting scene
  50511. * @returns the cylinder mesh
  50512. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50513. */
  50514. static CreateCylinder(name: string, options: {
  50515. height?: number;
  50516. diameterTop?: number;
  50517. diameterBottom?: number;
  50518. diameter?: number;
  50519. tessellation?: number;
  50520. subdivisions?: number;
  50521. arc?: number;
  50522. faceColors?: Color4[];
  50523. faceUV?: Vector4[];
  50524. updatable?: boolean;
  50525. hasRings?: boolean;
  50526. enclose?: boolean;
  50527. sideOrientation?: number;
  50528. frontUVs?: Vector4;
  50529. backUVs?: Vector4;
  50530. }, scene: any): Mesh;
  50531. /**
  50532. * Creates a torus mesh
  50533. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50534. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50535. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50539. * @param name defines the name of the mesh
  50540. * @param options defines the options used to create the mesh
  50541. * @param scene defines the hosting scene
  50542. * @returns the torus mesh
  50543. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50544. */
  50545. static CreateTorus(name: string, options: {
  50546. diameter?: number;
  50547. thickness?: number;
  50548. tessellation?: number;
  50549. updatable?: boolean;
  50550. sideOrientation?: number;
  50551. frontUVs?: Vector4;
  50552. backUVs?: Vector4;
  50553. }, scene: any): Mesh;
  50554. /**
  50555. * Creates a torus knot mesh
  50556. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50557. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50558. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50559. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50561. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50563. * @param name defines the name of the mesh
  50564. * @param options defines the options used to create the mesh
  50565. * @param scene defines the hosting scene
  50566. * @returns the torus knot mesh
  50567. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50568. */
  50569. static CreateTorusKnot(name: string, options: {
  50570. radius?: number;
  50571. tube?: number;
  50572. radialSegments?: number;
  50573. tubularSegments?: number;
  50574. p?: number;
  50575. q?: number;
  50576. updatable?: boolean;
  50577. sideOrientation?: number;
  50578. frontUVs?: Vector4;
  50579. backUVs?: Vector4;
  50580. }, scene: any): Mesh;
  50581. /**
  50582. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50583. * * 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
  50584. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50585. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50586. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50587. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50588. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50589. * * 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
  50590. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50593. * @param name defines the name of the new line system
  50594. * @param options defines the options used to create the line system
  50595. * @param scene defines the hosting scene
  50596. * @returns a new line system mesh
  50597. */
  50598. static CreateLineSystem(name: string, options: {
  50599. lines: Vector3[][];
  50600. updatable?: boolean;
  50601. instance?: Nullable<LinesMesh>;
  50602. colors?: Nullable<Color4[][]>;
  50603. useVertexAlpha?: boolean;
  50604. }, scene: Nullable<Scene>): LinesMesh;
  50605. /**
  50606. * Creates a line mesh
  50607. * 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
  50608. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50609. * * The parameter `points` is an array successive Vector3
  50610. * * 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
  50611. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50612. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50613. * * When updating an instance, remember that only point positions can change, not the number of points
  50614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50616. * @param name defines the name of the new line system
  50617. * @param options defines the options used to create the line system
  50618. * @param scene defines the hosting scene
  50619. * @returns a new line mesh
  50620. */
  50621. static CreateLines(name: string, options: {
  50622. points: Vector3[];
  50623. updatable?: boolean;
  50624. instance?: Nullable<LinesMesh>;
  50625. colors?: Color4[];
  50626. useVertexAlpha?: boolean;
  50627. }, scene?: Nullable<Scene>): LinesMesh;
  50628. /**
  50629. * Creates a dashed line mesh
  50630. * * 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
  50631. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50632. * * The parameter `points` is an array successive Vector3
  50633. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50634. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50635. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50636. * * 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
  50637. * * When updating an instance, remember that only point positions can change, not the number of points
  50638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50639. * @param name defines the name of the mesh
  50640. * @param options defines the options used to create the mesh
  50641. * @param scene defines the hosting scene
  50642. * @returns the dashed line mesh
  50643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50644. */
  50645. static CreateDashedLines(name: string, options: {
  50646. points: Vector3[];
  50647. dashSize?: number;
  50648. gapSize?: number;
  50649. dashNb?: number;
  50650. updatable?: boolean;
  50651. instance?: LinesMesh;
  50652. }, scene?: Nullable<Scene>): LinesMesh;
  50653. /**
  50654. * 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.
  50655. * * 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.
  50656. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50657. * * 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.
  50658. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50659. * * 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
  50660. * * 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
  50661. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50666. * @param name defines the name of the mesh
  50667. * @param options defines the options used to create the mesh
  50668. * @param scene defines the hosting scene
  50669. * @returns the extruded shape mesh
  50670. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50672. */
  50673. static ExtrudeShape(name: string, options: {
  50674. shape: Vector3[];
  50675. path: Vector3[];
  50676. scale?: number;
  50677. rotation?: number;
  50678. cap?: number;
  50679. updatable?: boolean;
  50680. sideOrientation?: number;
  50681. frontUVs?: Vector4;
  50682. backUVs?: Vector4;
  50683. instance?: Mesh;
  50684. invertUV?: boolean;
  50685. }, scene?: Nullable<Scene>): Mesh;
  50686. /**
  50687. * Creates an custom extruded shape mesh.
  50688. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50689. * * 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.
  50690. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50691. * * 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
  50692. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50693. * * 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
  50694. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50695. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50696. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50697. * * 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
  50698. * * 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
  50699. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50702. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50704. * @param name defines the name of the mesh
  50705. * @param options defines the options used to create the mesh
  50706. * @param scene defines the hosting scene
  50707. * @returns the custom extruded shape mesh
  50708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50709. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50710. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50711. */
  50712. static ExtrudeShapeCustom(name: string, options: {
  50713. shape: Vector3[];
  50714. path: Vector3[];
  50715. scaleFunction?: any;
  50716. rotationFunction?: any;
  50717. ribbonCloseArray?: boolean;
  50718. ribbonClosePath?: boolean;
  50719. cap?: number;
  50720. updatable?: boolean;
  50721. sideOrientation?: number;
  50722. frontUVs?: Vector4;
  50723. backUVs?: Vector4;
  50724. instance?: Mesh;
  50725. invertUV?: boolean;
  50726. }, scene: Scene): Mesh;
  50727. /**
  50728. * Creates lathe mesh.
  50729. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50730. * * 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
  50731. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50732. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50733. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50734. * * 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
  50735. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50736. * * 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
  50737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50741. * @param name defines the name of the mesh
  50742. * @param options defines the options used to create the mesh
  50743. * @param scene defines the hosting scene
  50744. * @returns the lathe mesh
  50745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50746. */
  50747. static CreateLathe(name: string, options: {
  50748. shape: Vector3[];
  50749. radius?: number;
  50750. tessellation?: number;
  50751. clip?: number;
  50752. arc?: number;
  50753. closed?: boolean;
  50754. updatable?: boolean;
  50755. sideOrientation?: number;
  50756. frontUVs?: Vector4;
  50757. backUVs?: Vector4;
  50758. cap?: number;
  50759. invertUV?: boolean;
  50760. }, scene: Scene): Mesh;
  50761. /**
  50762. * Creates a plane mesh
  50763. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50764. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50765. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50769. * @param name defines the name of the mesh
  50770. * @param options defines the options used to create the mesh
  50771. * @param scene defines the hosting scene
  50772. * @returns the plane mesh
  50773. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50774. */
  50775. static CreatePlane(name: string, options: {
  50776. size?: number;
  50777. width?: number;
  50778. height?: number;
  50779. sideOrientation?: number;
  50780. frontUVs?: Vector4;
  50781. backUVs?: Vector4;
  50782. updatable?: boolean;
  50783. sourcePlane?: Plane;
  50784. }, scene: Scene): Mesh;
  50785. /**
  50786. * Creates a ground mesh
  50787. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50788. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50790. * @param name defines the name of the mesh
  50791. * @param options defines the options used to create the mesh
  50792. * @param scene defines the hosting scene
  50793. * @returns the ground mesh
  50794. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50795. */
  50796. static CreateGround(name: string, options: {
  50797. width?: number;
  50798. height?: number;
  50799. subdivisions?: number;
  50800. subdivisionsX?: number;
  50801. subdivisionsY?: number;
  50802. updatable?: boolean;
  50803. }, scene: any): Mesh;
  50804. /**
  50805. * Creates a tiled ground mesh
  50806. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50807. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50808. * * 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
  50809. * * 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
  50810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50811. * @param name defines the name of the mesh
  50812. * @param options defines the options used to create the mesh
  50813. * @param scene defines the hosting scene
  50814. * @returns the tiled ground mesh
  50815. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50816. */
  50817. static CreateTiledGround(name: string, options: {
  50818. xmin: number;
  50819. zmin: number;
  50820. xmax: number;
  50821. zmax: number;
  50822. subdivisions?: {
  50823. w: number;
  50824. h: number;
  50825. };
  50826. precision?: {
  50827. w: number;
  50828. h: number;
  50829. };
  50830. updatable?: boolean;
  50831. }, scene: Scene): Mesh;
  50832. /**
  50833. * Creates a ground mesh from a height map
  50834. * * The parameter `url` sets the URL of the height map image resource.
  50835. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50836. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50837. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50838. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50839. * * 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.
  50840. * * 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).
  50841. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50843. * @param name defines the name of the mesh
  50844. * @param url defines the url to the height map
  50845. * @param options defines the options used to create the mesh
  50846. * @param scene defines the hosting scene
  50847. * @returns the ground mesh
  50848. * @see https://doc.babylonjs.com/babylon101/height_map
  50849. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50850. */
  50851. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50852. width?: number;
  50853. height?: number;
  50854. subdivisions?: number;
  50855. minHeight?: number;
  50856. maxHeight?: number;
  50857. colorFilter?: Color3;
  50858. alphaFilter?: number;
  50859. updatable?: boolean;
  50860. onReady?: (mesh: GroundMesh) => void;
  50861. }, scene: Scene): GroundMesh;
  50862. /**
  50863. * Creates a polygon mesh
  50864. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50865. * * 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
  50866. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50869. * * Remember you can only change the shape positions, not their number when updating a polygon
  50870. * @param name defines the name of the mesh
  50871. * @param options defines the options used to create the mesh
  50872. * @param scene defines the hosting scene
  50873. * @param earcutInjection can be used to inject your own earcut reference
  50874. * @returns the polygon mesh
  50875. */
  50876. static CreatePolygon(name: string, options: {
  50877. shape: Vector3[];
  50878. holes?: Vector3[][];
  50879. depth?: number;
  50880. faceUV?: Vector4[];
  50881. faceColors?: Color4[];
  50882. updatable?: boolean;
  50883. sideOrientation?: number;
  50884. frontUVs?: Vector4;
  50885. backUVs?: Vector4;
  50886. }, scene: Scene, earcutInjection?: any): Mesh;
  50887. /**
  50888. * Creates an extruded polygon mesh, with depth in the Y direction.
  50889. * * 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)
  50890. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50891. * @param name defines the name of the mesh
  50892. * @param options defines the options used to create the mesh
  50893. * @param scene defines the hosting scene
  50894. * @param earcutInjection can be used to inject your own earcut reference
  50895. * @returns the polygon mesh
  50896. */
  50897. static ExtrudePolygon(name: string, options: {
  50898. shape: Vector3[];
  50899. holes?: Vector3[][];
  50900. depth?: number;
  50901. faceUV?: Vector4[];
  50902. faceColors?: Color4[];
  50903. updatable?: boolean;
  50904. sideOrientation?: number;
  50905. frontUVs?: Vector4;
  50906. backUVs?: Vector4;
  50907. }, scene: Scene, earcutInjection?: any): Mesh;
  50908. /**
  50909. * Creates a tube mesh.
  50910. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50911. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50912. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50913. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50914. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50915. * * 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)
  50916. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50917. * * 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
  50918. * * 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
  50919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50923. * @param name defines the name of the mesh
  50924. * @param options defines the options used to create the mesh
  50925. * @param scene defines the hosting scene
  50926. * @returns the tube mesh
  50927. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50928. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50929. */
  50930. static CreateTube(name: string, options: {
  50931. path: Vector3[];
  50932. radius?: number;
  50933. tessellation?: number;
  50934. radiusFunction?: {
  50935. (i: number, distance: number): number;
  50936. };
  50937. cap?: number;
  50938. arc?: number;
  50939. updatable?: boolean;
  50940. sideOrientation?: number;
  50941. frontUVs?: Vector4;
  50942. backUVs?: Vector4;
  50943. instance?: Mesh;
  50944. invertUV?: boolean;
  50945. }, scene: Scene): Mesh;
  50946. /**
  50947. * Creates a polyhedron mesh
  50948. * * 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
  50949. * * The parameter `size` (positive float, default 1) sets the polygon size
  50950. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50951. * * 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`
  50952. * * 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
  50953. * * 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)`)
  50954. * * 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
  50955. * * 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
  50956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50959. * @param name defines the name of the mesh
  50960. * @param options defines the options used to create the mesh
  50961. * @param scene defines the hosting scene
  50962. * @returns the polyhedron mesh
  50963. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50964. */
  50965. static CreatePolyhedron(name: string, options: {
  50966. type?: number;
  50967. size?: number;
  50968. sizeX?: number;
  50969. sizeY?: number;
  50970. sizeZ?: number;
  50971. custom?: any;
  50972. faceUV?: Vector4[];
  50973. faceColors?: Color4[];
  50974. flat?: boolean;
  50975. updatable?: boolean;
  50976. sideOrientation?: number;
  50977. frontUVs?: Vector4;
  50978. backUVs?: Vector4;
  50979. }, scene: Scene): Mesh;
  50980. /**
  50981. * Creates a decal mesh.
  50982. * 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
  50983. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50984. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50985. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50986. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50987. * @param name defines the name of the mesh
  50988. * @param sourceMesh defines the mesh where the decal must be applied
  50989. * @param options defines the options used to create the mesh
  50990. * @param scene defines the hosting scene
  50991. * @returns the decal mesh
  50992. * @see https://doc.babylonjs.com/how_to/decals
  50993. */
  50994. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50995. position?: Vector3;
  50996. normal?: Vector3;
  50997. size?: Vector3;
  50998. angle?: number;
  50999. }): Mesh;
  51000. }
  51001. }
  51002. declare module "babylonjs/Meshes/meshSimplification" {
  51003. import { Mesh } from "babylonjs/Meshes/mesh";
  51004. /**
  51005. * A simplifier interface for future simplification implementations
  51006. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51007. */
  51008. export interface ISimplifier {
  51009. /**
  51010. * Simplification of a given mesh according to the given settings.
  51011. * Since this requires computation, it is assumed that the function runs async.
  51012. * @param settings The settings of the simplification, including quality and distance
  51013. * @param successCallback A callback that will be called after the mesh was simplified.
  51014. * @param errorCallback in case of an error, this callback will be called. optional.
  51015. */
  51016. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51017. }
  51018. /**
  51019. * Expected simplification settings.
  51020. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51021. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51022. */
  51023. export interface ISimplificationSettings {
  51024. /**
  51025. * Gets or sets the expected quality
  51026. */
  51027. quality: number;
  51028. /**
  51029. * Gets or sets the distance when this optimized version should be used
  51030. */
  51031. distance: number;
  51032. /**
  51033. * Gets an already optimized mesh
  51034. */
  51035. optimizeMesh?: boolean;
  51036. }
  51037. /**
  51038. * Class used to specify simplification options
  51039. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51040. */
  51041. export class SimplificationSettings implements ISimplificationSettings {
  51042. /** expected quality */
  51043. quality: number;
  51044. /** distance when this optimized version should be used */
  51045. distance: number;
  51046. /** already optimized mesh */
  51047. optimizeMesh?: boolean | undefined;
  51048. /**
  51049. * Creates a SimplificationSettings
  51050. * @param quality expected quality
  51051. * @param distance distance when this optimized version should be used
  51052. * @param optimizeMesh already optimized mesh
  51053. */
  51054. constructor(
  51055. /** expected quality */
  51056. quality: number,
  51057. /** distance when this optimized version should be used */
  51058. distance: number,
  51059. /** already optimized mesh */
  51060. optimizeMesh?: boolean | undefined);
  51061. }
  51062. /**
  51063. * Interface used to define a simplification task
  51064. */
  51065. export interface ISimplificationTask {
  51066. /**
  51067. * Array of settings
  51068. */
  51069. settings: Array<ISimplificationSettings>;
  51070. /**
  51071. * Simplification type
  51072. */
  51073. simplificationType: SimplificationType;
  51074. /**
  51075. * Mesh to simplify
  51076. */
  51077. mesh: Mesh;
  51078. /**
  51079. * Callback called on success
  51080. */
  51081. successCallback?: () => void;
  51082. /**
  51083. * Defines if parallel processing can be used
  51084. */
  51085. parallelProcessing: boolean;
  51086. }
  51087. /**
  51088. * Queue used to order the simplification tasks
  51089. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51090. */
  51091. export class SimplificationQueue {
  51092. private _simplificationArray;
  51093. /**
  51094. * Gets a boolean indicating that the process is still running
  51095. */
  51096. running: boolean;
  51097. /**
  51098. * Creates a new queue
  51099. */
  51100. constructor();
  51101. /**
  51102. * Adds a new simplification task
  51103. * @param task defines a task to add
  51104. */
  51105. addTask(task: ISimplificationTask): void;
  51106. /**
  51107. * Execute next task
  51108. */
  51109. executeNext(): void;
  51110. /**
  51111. * Execute a simplification task
  51112. * @param task defines the task to run
  51113. */
  51114. runSimplification(task: ISimplificationTask): void;
  51115. private getSimplifier;
  51116. }
  51117. /**
  51118. * The implemented types of simplification
  51119. * At the moment only Quadratic Error Decimation is implemented
  51120. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51121. */
  51122. export enum SimplificationType {
  51123. /** Quadratic error decimation */
  51124. QUADRATIC = 0
  51125. }
  51126. }
  51127. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51128. import { Scene } from "babylonjs/scene";
  51129. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51130. import { ISceneComponent } from "babylonjs/sceneComponent";
  51131. module "babylonjs/scene" {
  51132. interface Scene {
  51133. /** @hidden (Backing field) */
  51134. _simplificationQueue: SimplificationQueue;
  51135. /**
  51136. * Gets or sets the simplification queue attached to the scene
  51137. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51138. */
  51139. simplificationQueue: SimplificationQueue;
  51140. }
  51141. }
  51142. module "babylonjs/Meshes/mesh" {
  51143. interface Mesh {
  51144. /**
  51145. * Simplify the mesh according to the given array of settings.
  51146. * Function will return immediately and will simplify async
  51147. * @param settings a collection of simplification settings
  51148. * @param parallelProcessing should all levels calculate parallel or one after the other
  51149. * @param simplificationType the type of simplification to run
  51150. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51151. * @returns the current mesh
  51152. */
  51153. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51154. }
  51155. }
  51156. /**
  51157. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51158. * created in a scene
  51159. */
  51160. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51161. /**
  51162. * The component name helpfull to identify the component in the list of scene components.
  51163. */
  51164. readonly name: string;
  51165. /**
  51166. * The scene the component belongs to.
  51167. */
  51168. scene: Scene;
  51169. /**
  51170. * Creates a new instance of the component for the given scene
  51171. * @param scene Defines the scene to register the component in
  51172. */
  51173. constructor(scene: Scene);
  51174. /**
  51175. * Registers the component in a given scene
  51176. */
  51177. register(): void;
  51178. /**
  51179. * Rebuilds the elements related to this component in case of
  51180. * context lost for instance.
  51181. */
  51182. rebuild(): void;
  51183. /**
  51184. * Disposes the component and the associated ressources
  51185. */
  51186. dispose(): void;
  51187. private _beforeCameraUpdate;
  51188. }
  51189. }
  51190. declare module "babylonjs/Meshes/Builders/index" {
  51191. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51192. export * from "babylonjs/Meshes/Builders/discBuilder";
  51193. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51194. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51195. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51196. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51197. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51198. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51199. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51200. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51201. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51202. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51203. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51204. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51205. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51206. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51207. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51208. }
  51209. declare module "babylonjs/Meshes/index" {
  51210. export * from "babylonjs/Meshes/abstractMesh";
  51211. export * from "babylonjs/Meshes/buffer";
  51212. export * from "babylonjs/Meshes/Compression/index";
  51213. export * from "babylonjs/Meshes/csg";
  51214. export * from "babylonjs/Meshes/geometry";
  51215. export * from "babylonjs/Meshes/groundMesh";
  51216. export * from "babylonjs/Meshes/trailMesh";
  51217. export * from "babylonjs/Meshes/instancedMesh";
  51218. export * from "babylonjs/Meshes/linesMesh";
  51219. export * from "babylonjs/Meshes/mesh";
  51220. export * from "babylonjs/Meshes/mesh.vertexData";
  51221. export * from "babylonjs/Meshes/meshBuilder";
  51222. export * from "babylonjs/Meshes/meshSimplification";
  51223. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51224. export * from "babylonjs/Meshes/polygonMesh";
  51225. export * from "babylonjs/Meshes/subMesh";
  51226. export * from "babylonjs/Meshes/transformNode";
  51227. export * from "babylonjs/Meshes/Builders/index";
  51228. }
  51229. declare module "babylonjs/Morph/index" {
  51230. export * from "babylonjs/Morph/morphTarget";
  51231. export * from "babylonjs/Morph/morphTargetManager";
  51232. }
  51233. declare module "babylonjs/Offline/database" {
  51234. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51235. /**
  51236. * Class used to enable access to IndexedDB
  51237. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51238. */
  51239. export class Database implements IOfflineProvider {
  51240. private _callbackManifestChecked;
  51241. private _currentSceneUrl;
  51242. private _db;
  51243. private _enableSceneOffline;
  51244. private _enableTexturesOffline;
  51245. private _manifestVersionFound;
  51246. private _mustUpdateRessources;
  51247. private _hasReachedQuota;
  51248. private _isSupported;
  51249. private _idbFactory;
  51250. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51251. private static IsUASupportingBlobStorage;
  51252. /**
  51253. * Gets a boolean indicating if Database storate is enabled (off by default)
  51254. */
  51255. static IDBStorageEnabled: boolean;
  51256. /**
  51257. * Gets a boolean indicating if scene must be saved in the database
  51258. */
  51259. readonly enableSceneOffline: boolean;
  51260. /**
  51261. * Gets a boolean indicating if textures must be saved in the database
  51262. */
  51263. readonly enableTexturesOffline: boolean;
  51264. /**
  51265. * Creates a new Database
  51266. * @param urlToScene defines the url to load the scene
  51267. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51268. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51269. */
  51270. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51271. private static _ParseURL;
  51272. private static _ReturnFullUrlLocation;
  51273. private _checkManifestFile;
  51274. /**
  51275. * Open the database and make it available
  51276. * @param successCallback defines the callback to call on success
  51277. * @param errorCallback defines the callback to call on error
  51278. */
  51279. open(successCallback: () => void, errorCallback: () => void): void;
  51280. /**
  51281. * Loads an image from the database
  51282. * @param url defines the url to load from
  51283. * @param image defines the target DOM image
  51284. */
  51285. loadImage(url: string, image: HTMLImageElement): void;
  51286. private _loadImageFromDBAsync;
  51287. private _saveImageIntoDBAsync;
  51288. private _checkVersionFromDB;
  51289. private _loadVersionFromDBAsync;
  51290. private _saveVersionIntoDBAsync;
  51291. /**
  51292. * Loads a file from database
  51293. * @param url defines the URL to load from
  51294. * @param sceneLoaded defines a callback to call on success
  51295. * @param progressCallBack defines a callback to call when progress changed
  51296. * @param errorCallback defines a callback to call on error
  51297. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51298. */
  51299. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51300. private _loadFileAsync;
  51301. private _saveFileAsync;
  51302. /**
  51303. * Validates if xhr data is correct
  51304. * @param xhr defines the request to validate
  51305. * @param dataType defines the expected data type
  51306. * @returns true if data is correct
  51307. */
  51308. private static _ValidateXHRData;
  51309. }
  51310. }
  51311. declare module "babylonjs/Offline/index" {
  51312. export * from "babylonjs/Offline/database";
  51313. export * from "babylonjs/Offline/IOfflineProvider";
  51314. }
  51315. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51316. /** @hidden */
  51317. export var gpuUpdateParticlesPixelShader: {
  51318. name: string;
  51319. shader: string;
  51320. };
  51321. }
  51322. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51323. /** @hidden */
  51324. export var gpuUpdateParticlesVertexShader: {
  51325. name: string;
  51326. shader: string;
  51327. };
  51328. }
  51329. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51330. /** @hidden */
  51331. export var clipPlaneFragmentDeclaration2: {
  51332. name: string;
  51333. shader: string;
  51334. };
  51335. }
  51336. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51337. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51338. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51339. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51340. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51341. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51342. /** @hidden */
  51343. export var gpuRenderParticlesPixelShader: {
  51344. name: string;
  51345. shader: string;
  51346. };
  51347. }
  51348. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51349. /** @hidden */
  51350. export var clipPlaneVertexDeclaration2: {
  51351. name: string;
  51352. shader: string;
  51353. };
  51354. }
  51355. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51356. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51357. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51358. /** @hidden */
  51359. export var gpuRenderParticlesVertexShader: {
  51360. name: string;
  51361. shader: string;
  51362. };
  51363. }
  51364. declare module "babylonjs/Particles/gpuParticleSystem" {
  51365. import { Nullable } from "babylonjs/types";
  51366. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51367. import { Observable } from "babylonjs/Misc/observable";
  51368. import { Color4, Color3 } from "babylonjs/Maths/math";
  51369. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51370. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51371. import { Scene, IDisposable } from "babylonjs/scene";
  51372. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51373. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51374. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51375. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51376. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51377. /**
  51378. * This represents a GPU particle system in Babylon
  51379. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51380. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51381. */
  51382. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51383. /**
  51384. * The layer mask we are rendering the particles through.
  51385. */
  51386. layerMask: number;
  51387. private _capacity;
  51388. private _activeCount;
  51389. private _currentActiveCount;
  51390. private _accumulatedCount;
  51391. private _renderEffect;
  51392. private _updateEffect;
  51393. private _buffer0;
  51394. private _buffer1;
  51395. private _spriteBuffer;
  51396. private _updateVAO;
  51397. private _renderVAO;
  51398. private _targetIndex;
  51399. private _sourceBuffer;
  51400. private _targetBuffer;
  51401. private _engine;
  51402. private _currentRenderId;
  51403. private _started;
  51404. private _stopped;
  51405. private _timeDelta;
  51406. private _randomTexture;
  51407. private _randomTexture2;
  51408. private _attributesStrideSize;
  51409. private _updateEffectOptions;
  51410. private _randomTextureSize;
  51411. private _actualFrame;
  51412. private readonly _rawTextureWidth;
  51413. /**
  51414. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51415. */
  51416. static readonly IsSupported: boolean;
  51417. /**
  51418. * An event triggered when the system is disposed.
  51419. */
  51420. onDisposeObservable: Observable<GPUParticleSystem>;
  51421. /**
  51422. * Gets the maximum number of particles active at the same time.
  51423. * @returns The max number of active particles.
  51424. */
  51425. getCapacity(): number;
  51426. /**
  51427. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51428. * to override the particles.
  51429. */
  51430. forceDepthWrite: boolean;
  51431. /**
  51432. * Gets or set the number of active particles
  51433. */
  51434. activeParticleCount: number;
  51435. private _preWarmDone;
  51436. /**
  51437. * Is this system ready to be used/rendered
  51438. * @return true if the system is ready
  51439. */
  51440. isReady(): boolean;
  51441. /**
  51442. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51443. * @returns True if it has been started, otherwise false.
  51444. */
  51445. isStarted(): boolean;
  51446. /**
  51447. * Starts the particle system and begins to emit
  51448. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51449. */
  51450. start(delay?: number): void;
  51451. /**
  51452. * Stops the particle system.
  51453. */
  51454. stop(): void;
  51455. /**
  51456. * Remove all active particles
  51457. */
  51458. reset(): void;
  51459. /**
  51460. * Returns the string "GPUParticleSystem"
  51461. * @returns a string containing the class name
  51462. */
  51463. getClassName(): string;
  51464. private _colorGradientsTexture;
  51465. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51466. /**
  51467. * Adds a new color gradient
  51468. * @param gradient defines the gradient to use (between 0 and 1)
  51469. * @param color1 defines the color to affect to the specified gradient
  51470. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51471. * @returns the current particle system
  51472. */
  51473. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51474. /**
  51475. * Remove a specific color gradient
  51476. * @param gradient defines the gradient to remove
  51477. * @returns the current particle system
  51478. */
  51479. removeColorGradient(gradient: number): GPUParticleSystem;
  51480. private _angularSpeedGradientsTexture;
  51481. private _sizeGradientsTexture;
  51482. private _velocityGradientsTexture;
  51483. private _limitVelocityGradientsTexture;
  51484. private _dragGradientsTexture;
  51485. private _addFactorGradient;
  51486. /**
  51487. * Adds a new size gradient
  51488. * @param gradient defines the gradient to use (between 0 and 1)
  51489. * @param factor defines the size factor to affect to the specified gradient
  51490. * @returns the current particle system
  51491. */
  51492. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51493. /**
  51494. * Remove a specific size gradient
  51495. * @param gradient defines the gradient to remove
  51496. * @returns the current particle system
  51497. */
  51498. removeSizeGradient(gradient: number): GPUParticleSystem;
  51499. /**
  51500. * Adds a new angular speed gradient
  51501. * @param gradient defines the gradient to use (between 0 and 1)
  51502. * @param factor defines the angular speed to affect to the specified gradient
  51503. * @returns the current particle system
  51504. */
  51505. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51506. /**
  51507. * Remove a specific angular speed gradient
  51508. * @param gradient defines the gradient to remove
  51509. * @returns the current particle system
  51510. */
  51511. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51512. /**
  51513. * Adds a new velocity gradient
  51514. * @param gradient defines the gradient to use (between 0 and 1)
  51515. * @param factor defines the velocity to affect to the specified gradient
  51516. * @returns the current particle system
  51517. */
  51518. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51519. /**
  51520. * Remove a specific velocity gradient
  51521. * @param gradient defines the gradient to remove
  51522. * @returns the current particle system
  51523. */
  51524. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51525. /**
  51526. * Adds a new limit velocity gradient
  51527. * @param gradient defines the gradient to use (between 0 and 1)
  51528. * @param factor defines the limit velocity value to affect to the specified gradient
  51529. * @returns the current particle system
  51530. */
  51531. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51532. /**
  51533. * Remove a specific limit velocity gradient
  51534. * @param gradient defines the gradient to remove
  51535. * @returns the current particle system
  51536. */
  51537. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51538. /**
  51539. * Adds a new drag gradient
  51540. * @param gradient defines the gradient to use (between 0 and 1)
  51541. * @param factor defines the drag value to affect to the specified gradient
  51542. * @returns the current particle system
  51543. */
  51544. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51545. /**
  51546. * Remove a specific drag gradient
  51547. * @param gradient defines the gradient to remove
  51548. * @returns the current particle system
  51549. */
  51550. removeDragGradient(gradient: number): GPUParticleSystem;
  51551. /**
  51552. * Not supported by GPUParticleSystem
  51553. * @param gradient defines the gradient to use (between 0 and 1)
  51554. * @param factor defines the emit rate value to affect to the specified gradient
  51555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51556. * @returns the current particle system
  51557. */
  51558. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51559. /**
  51560. * Not supported by GPUParticleSystem
  51561. * @param gradient defines the gradient to remove
  51562. * @returns the current particle system
  51563. */
  51564. removeEmitRateGradient(gradient: number): IParticleSystem;
  51565. /**
  51566. * Not supported by GPUParticleSystem
  51567. * @param gradient defines the gradient to use (between 0 and 1)
  51568. * @param factor defines the start size value to affect to the specified gradient
  51569. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51570. * @returns the current particle system
  51571. */
  51572. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51573. /**
  51574. * Not supported by GPUParticleSystem
  51575. * @param gradient defines the gradient to remove
  51576. * @returns the current particle system
  51577. */
  51578. removeStartSizeGradient(gradient: number): IParticleSystem;
  51579. /**
  51580. * Not supported by GPUParticleSystem
  51581. * @param gradient defines the gradient to use (between 0 and 1)
  51582. * @param min defines the color remap minimal range
  51583. * @param max defines the color remap maximal range
  51584. * @returns the current particle system
  51585. */
  51586. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51587. /**
  51588. * Not supported by GPUParticleSystem
  51589. * @param gradient defines the gradient to remove
  51590. * @returns the current particle system
  51591. */
  51592. removeColorRemapGradient(): IParticleSystem;
  51593. /**
  51594. * Not supported by GPUParticleSystem
  51595. * @param gradient defines the gradient to use (between 0 and 1)
  51596. * @param min defines the alpha remap minimal range
  51597. * @param max defines the alpha remap maximal range
  51598. * @returns the current particle system
  51599. */
  51600. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51601. /**
  51602. * Not supported by GPUParticleSystem
  51603. * @param gradient defines the gradient to remove
  51604. * @returns the current particle system
  51605. */
  51606. removeAlphaRemapGradient(): IParticleSystem;
  51607. /**
  51608. * Not supported by GPUParticleSystem
  51609. * @param gradient defines the gradient to use (between 0 and 1)
  51610. * @param color defines the color to affect to the specified gradient
  51611. * @returns the current particle system
  51612. */
  51613. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51614. /**
  51615. * Not supported by GPUParticleSystem
  51616. * @param gradient defines the gradient to remove
  51617. * @returns the current particle system
  51618. */
  51619. removeRampGradient(): IParticleSystem;
  51620. /**
  51621. * Not supported by GPUParticleSystem
  51622. * @returns the list of ramp gradients
  51623. */
  51624. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51625. /**
  51626. * Not supported by GPUParticleSystem
  51627. * Gets or sets a boolean indicating that ramp gradients must be used
  51628. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51629. */
  51630. useRampGradients: boolean;
  51631. /**
  51632. * Not supported by GPUParticleSystem
  51633. * @param gradient defines the gradient to use (between 0 and 1)
  51634. * @param factor defines the life time factor to affect to the specified gradient
  51635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51636. * @returns the current particle system
  51637. */
  51638. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51639. /**
  51640. * Not supported by GPUParticleSystem
  51641. * @param gradient defines the gradient to remove
  51642. * @returns the current particle system
  51643. */
  51644. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51645. /**
  51646. * Instantiates a GPU particle system.
  51647. * 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.
  51648. * @param name The name of the particle system
  51649. * @param options The options used to create the system
  51650. * @param scene The scene the particle system belongs to
  51651. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51652. */
  51653. constructor(name: string, options: Partial<{
  51654. capacity: number;
  51655. randomTextureSize: number;
  51656. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51657. protected _reset(): void;
  51658. private _createUpdateVAO;
  51659. private _createRenderVAO;
  51660. private _initialize;
  51661. /** @hidden */
  51662. _recreateUpdateEffect(): void;
  51663. /** @hidden */
  51664. _recreateRenderEffect(): void;
  51665. /**
  51666. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51667. * @param preWarm defines if we are in the pre-warmimg phase
  51668. */
  51669. animate(preWarm?: boolean): void;
  51670. private _createFactorGradientTexture;
  51671. private _createSizeGradientTexture;
  51672. private _createAngularSpeedGradientTexture;
  51673. private _createVelocityGradientTexture;
  51674. private _createLimitVelocityGradientTexture;
  51675. private _createDragGradientTexture;
  51676. private _createColorGradientTexture;
  51677. /**
  51678. * Renders the particle system in its current state
  51679. * @param preWarm defines if the system should only update the particles but not render them
  51680. * @returns the current number of particles
  51681. */
  51682. render(preWarm?: boolean): number;
  51683. /**
  51684. * Rebuilds the particle system
  51685. */
  51686. rebuild(): void;
  51687. private _releaseBuffers;
  51688. private _releaseVAOs;
  51689. /**
  51690. * Disposes the particle system and free the associated resources
  51691. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51692. */
  51693. dispose(disposeTexture?: boolean): void;
  51694. /**
  51695. * Clones the particle system.
  51696. * @param name The name of the cloned object
  51697. * @param newEmitter The new emitter to use
  51698. * @returns the cloned particle system
  51699. */
  51700. clone(name: string, newEmitter: any): GPUParticleSystem;
  51701. /**
  51702. * Serializes the particle system to a JSON object.
  51703. * @returns the JSON object
  51704. */
  51705. serialize(): any;
  51706. /**
  51707. * Parses a JSON object to create a GPU particle system.
  51708. * @param parsedParticleSystem The JSON object to parse
  51709. * @param scene The scene to create the particle system in
  51710. * @param rootUrl The root url to use to load external dependencies like texture
  51711. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51712. * @returns the parsed GPU particle system
  51713. */
  51714. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51715. }
  51716. }
  51717. declare module "babylonjs/Particles/particleSystemSet" {
  51718. import { Nullable } from "babylonjs/types";
  51719. import { Color3 } from "babylonjs/Maths/math";
  51720. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51722. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51723. import { Scene, IDisposable } from "babylonjs/scene";
  51724. /**
  51725. * Represents a set of particle systems working together to create a specific effect
  51726. */
  51727. export class ParticleSystemSet implements IDisposable {
  51728. private _emitterCreationOptions;
  51729. private _emitterNode;
  51730. /**
  51731. * Gets the particle system list
  51732. */
  51733. systems: IParticleSystem[];
  51734. /**
  51735. * Gets the emitter node used with this set
  51736. */
  51737. readonly emitterNode: Nullable<TransformNode>;
  51738. /**
  51739. * Creates a new emitter mesh as a sphere
  51740. * @param options defines the options used to create the sphere
  51741. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51742. * @param scene defines the hosting scene
  51743. */
  51744. setEmitterAsSphere(options: {
  51745. diameter: number;
  51746. segments: number;
  51747. color: Color3;
  51748. }, renderingGroupId: number, scene: Scene): void;
  51749. /**
  51750. * Starts all particle systems of the set
  51751. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51752. */
  51753. start(emitter?: AbstractMesh): void;
  51754. /**
  51755. * Release all associated resources
  51756. */
  51757. dispose(): void;
  51758. /**
  51759. * Serialize the set into a JSON compatible object
  51760. * @returns a JSON compatible representation of the set
  51761. */
  51762. serialize(): any;
  51763. /**
  51764. * Parse a new ParticleSystemSet from a serialized source
  51765. * @param data defines a JSON compatible representation of the set
  51766. * @param scene defines the hosting scene
  51767. * @param gpu defines if we want GPU particles or CPU particles
  51768. * @returns a new ParticleSystemSet
  51769. */
  51770. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51771. }
  51772. }
  51773. declare module "babylonjs/Particles/particleHelper" {
  51774. import { Nullable } from "babylonjs/types";
  51775. import { Scene } from "babylonjs/scene";
  51776. import { Vector3 } from "babylonjs/Maths/math";
  51777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51778. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51779. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  51780. /**
  51781. * This class is made for on one-liner static method to help creating particle system set.
  51782. */
  51783. export class ParticleHelper {
  51784. /**
  51785. * Gets or sets base Assets URL
  51786. */
  51787. static BaseAssetsUrl: string;
  51788. /**
  51789. * Create a default particle system that you can tweak
  51790. * @param emitter defines the emitter to use
  51791. * @param capacity defines the system capacity (default is 500 particles)
  51792. * @param scene defines the hosting scene
  51793. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51794. * @returns the new Particle system
  51795. */
  51796. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51797. /**
  51798. * This is the main static method (one-liner) of this helper to create different particle systems
  51799. * @param type This string represents the type to the particle system to create
  51800. * @param scene The scene where the particle system should live
  51801. * @param gpu If the system will use gpu
  51802. * @returns the ParticleSystemSet created
  51803. */
  51804. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51805. /**
  51806. * Static function used to export a particle system to a ParticleSystemSet variable.
  51807. * Please note that the emitter shape is not exported
  51808. * @param systems defines the particle systems to export
  51809. * @returns the created particle system set
  51810. */
  51811. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51812. }
  51813. }
  51814. declare module "babylonjs/Particles/particleSystemComponent" {
  51815. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51816. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  51817. import "babylonjs/Shaders/particles.vertex";
  51818. module "babylonjs/Engines/engine" {
  51819. interface Engine {
  51820. /**
  51821. * Create an effect to use with particle systems.
  51822. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51823. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51824. * @param uniformsNames defines a list of attribute names
  51825. * @param samplers defines an array of string used to represent textures
  51826. * @param defines defines the string containing the defines to use to compile the shaders
  51827. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51828. * @param onCompiled defines a function to call when the effect creation is successful
  51829. * @param onError defines a function to call when the effect creation has failed
  51830. * @returns the new Effect
  51831. */
  51832. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51833. }
  51834. }
  51835. module "babylonjs/Meshes/mesh" {
  51836. interface Mesh {
  51837. /**
  51838. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51839. * @returns an array of IParticleSystem
  51840. */
  51841. getEmittedParticleSystems(): IParticleSystem[];
  51842. /**
  51843. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51844. * @returns an array of IParticleSystem
  51845. */
  51846. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51847. }
  51848. }
  51849. /**
  51850. * @hidden
  51851. */
  51852. export var _IDoNeedToBeInTheBuild: number;
  51853. }
  51854. declare module "babylonjs/Particles/index" {
  51855. export * from "babylonjs/Particles/baseParticleSystem";
  51856. export * from "babylonjs/Particles/EmitterTypes/index";
  51857. export * from "babylonjs/Particles/gpuParticleSystem";
  51858. export * from "babylonjs/Particles/IParticleSystem";
  51859. export * from "babylonjs/Particles/particle";
  51860. export * from "babylonjs/Particles/particleHelper";
  51861. export * from "babylonjs/Particles/particleSystem";
  51862. export * from "babylonjs/Particles/particleSystemComponent";
  51863. export * from "babylonjs/Particles/particleSystemSet";
  51864. export * from "babylonjs/Particles/solidParticle";
  51865. export * from "babylonjs/Particles/solidParticleSystem";
  51866. export * from "babylonjs/Particles/subEmitter";
  51867. }
  51868. declare module "babylonjs/Physics/physicsEngineComponent" {
  51869. import { Nullable } from "babylonjs/types";
  51870. import { Observable, Observer } from "babylonjs/Misc/observable";
  51871. import { Vector3 } from "babylonjs/Maths/math";
  51872. import { Mesh } from "babylonjs/Meshes/mesh";
  51873. import { ISceneComponent } from "babylonjs/sceneComponent";
  51874. import { Scene } from "babylonjs/scene";
  51875. import { Node } from "babylonjs/node";
  51876. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51877. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51878. module "babylonjs/scene" {
  51879. interface Scene {
  51880. /** @hidden (Backing field) */
  51881. _physicsEngine: Nullable<IPhysicsEngine>;
  51882. /**
  51883. * Gets the current physics engine
  51884. * @returns a IPhysicsEngine or null if none attached
  51885. */
  51886. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51887. /**
  51888. * Enables physics to the current scene
  51889. * @param gravity defines the scene's gravity for the physics engine
  51890. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51891. * @return a boolean indicating if the physics engine was initialized
  51892. */
  51893. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51894. /**
  51895. * Disables and disposes the physics engine associated with the scene
  51896. */
  51897. disablePhysicsEngine(): void;
  51898. /**
  51899. * Gets a boolean indicating if there is an active physics engine
  51900. * @returns a boolean indicating if there is an active physics engine
  51901. */
  51902. isPhysicsEnabled(): boolean;
  51903. /**
  51904. * Deletes a physics compound impostor
  51905. * @param compound defines the compound to delete
  51906. */
  51907. deleteCompoundImpostor(compound: any): void;
  51908. /**
  51909. * An event triggered when physic simulation is about to be run
  51910. */
  51911. onBeforePhysicsObservable: Observable<Scene>;
  51912. /**
  51913. * An event triggered when physic simulation has been done
  51914. */
  51915. onAfterPhysicsObservable: Observable<Scene>;
  51916. }
  51917. }
  51918. module "babylonjs/Meshes/abstractMesh" {
  51919. interface AbstractMesh {
  51920. /** @hidden */
  51921. _physicsImpostor: Nullable<PhysicsImpostor>;
  51922. /**
  51923. * Gets or sets impostor used for physic simulation
  51924. * @see http://doc.babylonjs.com/features/physics_engine
  51925. */
  51926. physicsImpostor: Nullable<PhysicsImpostor>;
  51927. /**
  51928. * Gets the current physics impostor
  51929. * @see http://doc.babylonjs.com/features/physics_engine
  51930. * @returns a physics impostor or null
  51931. */
  51932. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51933. /** Apply a physic impulse to the mesh
  51934. * @param force defines the force to apply
  51935. * @param contactPoint defines where to apply the force
  51936. * @returns the current mesh
  51937. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51938. */
  51939. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51940. /**
  51941. * Creates a physic joint between two meshes
  51942. * @param otherMesh defines the other mesh to use
  51943. * @param pivot1 defines the pivot to use on this mesh
  51944. * @param pivot2 defines the pivot to use on the other mesh
  51945. * @param options defines additional options (can be plugin dependent)
  51946. * @returns the current mesh
  51947. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51948. */
  51949. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51950. /** @hidden */
  51951. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51952. }
  51953. }
  51954. /**
  51955. * Defines the physics engine scene component responsible to manage a physics engine
  51956. */
  51957. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51958. /**
  51959. * The component name helpful to identify the component in the list of scene components.
  51960. */
  51961. readonly name: string;
  51962. /**
  51963. * The scene the component belongs to.
  51964. */
  51965. scene: Scene;
  51966. /**
  51967. * Creates a new instance of the component for the given scene
  51968. * @param scene Defines the scene to register the component in
  51969. */
  51970. constructor(scene: Scene);
  51971. /**
  51972. * Registers the component in a given scene
  51973. */
  51974. register(): void;
  51975. /**
  51976. * Rebuilds the elements related to this component in case of
  51977. * context lost for instance.
  51978. */
  51979. rebuild(): void;
  51980. /**
  51981. * Disposes the component and the associated ressources
  51982. */
  51983. dispose(): void;
  51984. }
  51985. }
  51986. declare module "babylonjs/Physics/physicsHelper" {
  51987. import { Nullable } from "babylonjs/types";
  51988. import { Vector3 } from "babylonjs/Maths/math";
  51989. import { Mesh } from "babylonjs/Meshes/mesh";
  51990. import { Ray } from "babylonjs/Culling/ray";
  51991. import { Scene } from "babylonjs/scene";
  51992. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51993. /**
  51994. * A helper for physics simulations
  51995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51996. */
  51997. export class PhysicsHelper {
  51998. private _scene;
  51999. private _physicsEngine;
  52000. /**
  52001. * Initializes the Physics helper
  52002. * @param scene Babylon.js scene
  52003. */
  52004. constructor(scene: Scene);
  52005. /**
  52006. * Applies a radial explosion impulse
  52007. * @param origin the origin of the explosion
  52008. * @param radius the explosion radius
  52009. * @param strength the explosion strength
  52010. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52011. * @returns A physics radial explosion event, or null
  52012. */
  52013. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52014. /**
  52015. * Applies a radial explosion force
  52016. * @param origin the origin of the explosion
  52017. * @param radius the explosion radius
  52018. * @param strength the explosion strength
  52019. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52020. * @returns A physics radial explosion event, or null
  52021. */
  52022. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52023. /**
  52024. * Creates a gravitational field
  52025. * @param origin the origin of the explosion
  52026. * @param radius the explosion radius
  52027. * @param strength the explosion strength
  52028. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52029. * @returns A physics gravitational field event, or null
  52030. */
  52031. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52032. /**
  52033. * Creates a physics updraft event
  52034. * @param origin the origin of the updraft
  52035. * @param radius the radius of the updraft
  52036. * @param strength the strength of the updraft
  52037. * @param height the height of the updraft
  52038. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52039. * @returns A physics updraft event, or null
  52040. */
  52041. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52042. /**
  52043. * Creates a physics vortex event
  52044. * @param origin the of the vortex
  52045. * @param radius the radius of the vortex
  52046. * @param strength the strength of the vortex
  52047. * @param height the height of the vortex
  52048. * @returns a Physics vortex event, or null
  52049. * A physics vortex event or null
  52050. */
  52051. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  52052. }
  52053. /**
  52054. * Represents a physics radial explosion event
  52055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52056. */
  52057. export class PhysicsRadialExplosionEvent {
  52058. private _scene;
  52059. private _sphere;
  52060. private _sphereOptions;
  52061. private _rays;
  52062. private _dataFetched;
  52063. /**
  52064. * Initializes a radial explosioin event
  52065. * @param scene BabylonJS scene
  52066. */
  52067. constructor(scene: Scene);
  52068. /**
  52069. * Returns the data related to the radial explosion event (sphere & rays).
  52070. * @returns The radial explosion event data
  52071. */
  52072. getData(): PhysicsRadialExplosionEventData;
  52073. /**
  52074. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52075. * @param impostor A physics imposter
  52076. * @param origin the origin of the explosion
  52077. * @param radius the explosion radius
  52078. * @param strength the explosion strength
  52079. * @param falloff possible options: Constant & Linear
  52080. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52081. */
  52082. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  52083. /**
  52084. * Disposes the sphere.
  52085. * @param force Specifies if the sphere should be disposed by force
  52086. */
  52087. dispose(force?: boolean): void;
  52088. /*** Helpers ***/
  52089. private _prepareSphere;
  52090. private _intersectsWithSphere;
  52091. }
  52092. /**
  52093. * Represents a gravitational field event
  52094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52095. */
  52096. export class PhysicsGravitationalFieldEvent {
  52097. private _physicsHelper;
  52098. private _scene;
  52099. private _origin;
  52100. private _radius;
  52101. private _strength;
  52102. private _falloff;
  52103. private _tickCallback;
  52104. private _sphere;
  52105. private _dataFetched;
  52106. /**
  52107. * Initializes the physics gravitational field event
  52108. * @param physicsHelper A physics helper
  52109. * @param scene BabylonJS scene
  52110. * @param origin The origin position of the gravitational field event
  52111. * @param radius The radius of the gravitational field event
  52112. * @param strength The strength of the gravitational field event
  52113. * @param falloff The falloff for the gravitational field event
  52114. */
  52115. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  52116. /**
  52117. * Returns the data related to the gravitational field event (sphere).
  52118. * @returns A gravitational field event
  52119. */
  52120. getData(): PhysicsGravitationalFieldEventData;
  52121. /**
  52122. * Enables the gravitational field.
  52123. */
  52124. enable(): void;
  52125. /**
  52126. * Disables the gravitational field.
  52127. */
  52128. disable(): void;
  52129. /**
  52130. * Disposes the sphere.
  52131. * @param force The force to dispose from the gravitational field event
  52132. */
  52133. dispose(force?: boolean): void;
  52134. private _tick;
  52135. }
  52136. /**
  52137. * Represents a physics updraft event
  52138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52139. */
  52140. export class PhysicsUpdraftEvent {
  52141. private _scene;
  52142. private _origin;
  52143. private _radius;
  52144. private _strength;
  52145. private _height;
  52146. private _updraftMode;
  52147. private _physicsEngine;
  52148. private _originTop;
  52149. private _originDirection;
  52150. private _tickCallback;
  52151. private _cylinder;
  52152. private _cylinderPosition;
  52153. private _dataFetched;
  52154. /**
  52155. * Initializes the physics updraft event
  52156. * @param _scene BabylonJS scene
  52157. * @param _origin The origin position of the updraft
  52158. * @param _radius The radius of the updraft
  52159. * @param _strength The strength of the updraft
  52160. * @param _height The height of the updraft
  52161. * @param _updraftMode The mode of the updraft
  52162. */
  52163. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  52164. /**
  52165. * Returns the data related to the updraft event (cylinder).
  52166. * @returns A physics updraft event
  52167. */
  52168. getData(): PhysicsUpdraftEventData;
  52169. /**
  52170. * Enables the updraft.
  52171. */
  52172. enable(): void;
  52173. /**
  52174. * Disables the cortex.
  52175. */
  52176. disable(): void;
  52177. /**
  52178. * Disposes the sphere.
  52179. * @param force Specifies if the updraft should be disposed by force
  52180. */
  52181. dispose(force?: boolean): void;
  52182. private getImpostorForceAndContactPoint;
  52183. private _tick;
  52184. /*** Helpers ***/
  52185. private _prepareCylinder;
  52186. private _intersectsWithCylinder;
  52187. }
  52188. /**
  52189. * Represents a physics vortex event
  52190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52191. */
  52192. export class PhysicsVortexEvent {
  52193. private _scene;
  52194. private _origin;
  52195. private _radius;
  52196. private _strength;
  52197. private _height;
  52198. private _physicsEngine;
  52199. private _originTop;
  52200. private _centripetalForceThreshold;
  52201. private _updraftMultiplier;
  52202. private _tickCallback;
  52203. private _cylinder;
  52204. private _cylinderPosition;
  52205. private _dataFetched;
  52206. /**
  52207. * Initializes the physics vortex event
  52208. * @param _scene The BabylonJS scene
  52209. * @param _origin The origin position of the vortex
  52210. * @param _radius The radius of the vortex
  52211. * @param _strength The strength of the vortex
  52212. * @param _height The height of the vortex
  52213. */
  52214. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  52215. /**
  52216. * Returns the data related to the vortex event (cylinder).
  52217. * @returns The physics vortex event data
  52218. */
  52219. getData(): PhysicsVortexEventData;
  52220. /**
  52221. * Enables the vortex.
  52222. */
  52223. enable(): void;
  52224. /**
  52225. * Disables the cortex.
  52226. */
  52227. disable(): void;
  52228. /**
  52229. * Disposes the sphere.
  52230. * @param force
  52231. */
  52232. dispose(force?: boolean): void;
  52233. private getImpostorForceAndContactPoint;
  52234. private _tick;
  52235. /*** Helpers ***/
  52236. private _prepareCylinder;
  52237. private _intersectsWithCylinder;
  52238. }
  52239. /**
  52240. * The strenght of the force in correspondence to the distance of the affected object
  52241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52242. */
  52243. export enum PhysicsRadialImpulseFalloff {
  52244. /** Defines that impulse is constant in strength across it's whole radius */
  52245. Constant = 0,
  52246. /** DEfines that impulse gets weaker if it's further from the origin */
  52247. Linear = 1
  52248. }
  52249. /**
  52250. * The strength of the force in correspondence to the distance of the affected object
  52251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52252. */
  52253. export enum PhysicsUpdraftMode {
  52254. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52255. Center = 0,
  52256. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52257. Perpendicular = 1
  52258. }
  52259. /**
  52260. * Interface for a physics force and contact point
  52261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52262. */
  52263. export interface PhysicsForceAndContactPoint {
  52264. /**
  52265. * The force applied at the contact point
  52266. */
  52267. force: Vector3;
  52268. /**
  52269. * The contact point
  52270. */
  52271. contactPoint: Vector3;
  52272. }
  52273. /**
  52274. * Interface for radial explosion event data
  52275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52276. */
  52277. export interface PhysicsRadialExplosionEventData {
  52278. /**
  52279. * A sphere used for the radial explosion event
  52280. */
  52281. sphere: Mesh;
  52282. /**
  52283. * An array of rays for the radial explosion event
  52284. */
  52285. rays: Array<Ray>;
  52286. }
  52287. /**
  52288. * Interface for gravitational field event data
  52289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52290. */
  52291. export interface PhysicsGravitationalFieldEventData {
  52292. /**
  52293. * A sphere mesh used for the gravitational field event
  52294. */
  52295. sphere: Mesh;
  52296. }
  52297. /**
  52298. * Interface for updraft event data
  52299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52300. */
  52301. export interface PhysicsUpdraftEventData {
  52302. /**
  52303. * A cylinder used for the updraft event
  52304. */
  52305. cylinder: Mesh;
  52306. }
  52307. /**
  52308. * Interface for vortex event data
  52309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52310. */
  52311. export interface PhysicsVortexEventData {
  52312. /**
  52313. * A cylinder used for the vortex event
  52314. */
  52315. cylinder: Mesh;
  52316. }
  52317. }
  52318. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52319. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52320. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52321. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52322. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52323. import { Nullable } from "babylonjs/types";
  52324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52325. /**
  52326. * AmmoJS Physics plugin
  52327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52328. * @see https://github.com/kripken/ammo.js/
  52329. */
  52330. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52331. private _useDeltaForWorldStep;
  52332. /**
  52333. * Reference to the Ammo library
  52334. */
  52335. bjsAMMO: any;
  52336. /**
  52337. * Created ammoJS world which physics bodies are added to
  52338. */
  52339. world: any;
  52340. /**
  52341. * Name of the plugin
  52342. */
  52343. name: string;
  52344. private _timeStep;
  52345. private _fixedTimeStep;
  52346. private _maxSteps;
  52347. private _tmpQuaternion;
  52348. private _tmpAmmoTransform;
  52349. private _tmpAmmoQuaternion;
  52350. private _tmpAmmoConcreteContactResultCallback;
  52351. private _collisionConfiguration;
  52352. private _dispatcher;
  52353. private _overlappingPairCache;
  52354. private _solver;
  52355. private _tmpAmmoVectorA;
  52356. private _tmpAmmoVectorB;
  52357. private _tmpAmmoVectorC;
  52358. private _tmpContactCallbackResult;
  52359. private static readonly DISABLE_COLLISION_FLAG;
  52360. private static readonly KINEMATIC_FLAG;
  52361. private static readonly DISABLE_DEACTIVATION_FLAG;
  52362. /**
  52363. * Initializes the ammoJS plugin
  52364. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52365. * @param ammoInjection can be used to inject your own ammo reference
  52366. */
  52367. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52368. /**
  52369. * Sets the gravity of the physics world (m/(s^2))
  52370. * @param gravity Gravity to set
  52371. */
  52372. setGravity(gravity: Vector3): void;
  52373. /**
  52374. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52375. * @param timeStep timestep to use in seconds
  52376. */
  52377. setTimeStep(timeStep: number): void;
  52378. /**
  52379. * 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)
  52380. * @param fixedTimeStep fixedTimeStep to use in seconds
  52381. */
  52382. setFixedTimeStep(fixedTimeStep: number): void;
  52383. /**
  52384. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52385. * @param maxSteps the maximum number of steps by the physics engine per frame
  52386. */
  52387. setMaxSteps(maxSteps: number): void;
  52388. /**
  52389. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52390. * @returns the current timestep in seconds
  52391. */
  52392. getTimeStep(): number;
  52393. private _isImpostorInContact;
  52394. private _isImpostorPairInContact;
  52395. private _stepSimulation;
  52396. /**
  52397. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52398. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52399. * After the step the babylon meshes are set to the position of the physics imposters
  52400. * @param delta amount of time to step forward
  52401. * @param impostors array of imposters to update before/after the step
  52402. */
  52403. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52404. private _tmpVector;
  52405. private _tmpMatrix;
  52406. /**
  52407. * Applies an implulse on the imposter
  52408. * @param impostor imposter to apply impulse
  52409. * @param force amount of force to be applied to the imposter
  52410. * @param contactPoint the location to apply the impulse on the imposter
  52411. */
  52412. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52413. /**
  52414. * Applies a force on the imposter
  52415. * @param impostor imposter to apply force
  52416. * @param force amount of force to be applied to the imposter
  52417. * @param contactPoint the location to apply the force on the imposter
  52418. */
  52419. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52420. /**
  52421. * Creates a physics body using the plugin
  52422. * @param impostor the imposter to create the physics body on
  52423. */
  52424. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52425. /**
  52426. * Removes the physics body from the imposter and disposes of the body's memory
  52427. * @param impostor imposter to remove the physics body from
  52428. */
  52429. removePhysicsBody(impostor: PhysicsImpostor): void;
  52430. /**
  52431. * Generates a joint
  52432. * @param impostorJoint the imposter joint to create the joint with
  52433. */
  52434. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52435. /**
  52436. * Removes a joint
  52437. * @param impostorJoint the imposter joint to remove the joint from
  52438. */
  52439. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52440. private _addMeshVerts;
  52441. private _createShape;
  52442. /**
  52443. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52444. * @param impostor imposter containing the physics body and babylon object
  52445. */
  52446. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52447. /**
  52448. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52449. * @param impostor imposter containing the physics body and babylon object
  52450. * @param newPosition new position
  52451. * @param newRotation new rotation
  52452. */
  52453. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52454. /**
  52455. * If this plugin is supported
  52456. * @returns true if its supported
  52457. */
  52458. isSupported(): boolean;
  52459. /**
  52460. * Sets the linear velocity of the physics body
  52461. * @param impostor imposter to set the velocity on
  52462. * @param velocity velocity to set
  52463. */
  52464. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52465. /**
  52466. * Sets the angular velocity of the physics body
  52467. * @param impostor imposter to set the velocity on
  52468. * @param velocity velocity to set
  52469. */
  52470. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52471. /**
  52472. * gets the linear velocity
  52473. * @param impostor imposter to get linear velocity from
  52474. * @returns linear velocity
  52475. */
  52476. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52477. /**
  52478. * gets the angular velocity
  52479. * @param impostor imposter to get angular velocity from
  52480. * @returns angular velocity
  52481. */
  52482. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52483. /**
  52484. * Sets the mass of physics body
  52485. * @param impostor imposter to set the mass on
  52486. * @param mass mass to set
  52487. */
  52488. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52489. /**
  52490. * Gets the mass of the physics body
  52491. * @param impostor imposter to get the mass from
  52492. * @returns mass
  52493. */
  52494. getBodyMass(impostor: PhysicsImpostor): number;
  52495. /**
  52496. * Gets friction of the impostor
  52497. * @param impostor impostor to get friction from
  52498. * @returns friction value
  52499. */
  52500. getBodyFriction(impostor: PhysicsImpostor): number;
  52501. /**
  52502. * Sets friction of the impostor
  52503. * @param impostor impostor to set friction on
  52504. * @param friction friction value
  52505. */
  52506. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52507. /**
  52508. * Gets restitution of the impostor
  52509. * @param impostor impostor to get restitution from
  52510. * @returns restitution value
  52511. */
  52512. getBodyRestitution(impostor: PhysicsImpostor): number;
  52513. /**
  52514. * Sets resitution of the impostor
  52515. * @param impostor impostor to set resitution on
  52516. * @param restitution resitution value
  52517. */
  52518. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52519. /**
  52520. * Sleeps the physics body and stops it from being active
  52521. * @param impostor impostor to sleep
  52522. */
  52523. sleepBody(impostor: PhysicsImpostor): void;
  52524. /**
  52525. * Activates the physics body
  52526. * @param impostor impostor to activate
  52527. */
  52528. wakeUpBody(impostor: PhysicsImpostor): void;
  52529. /**
  52530. * Updates the distance parameters of the joint
  52531. * @param joint joint to update
  52532. * @param maxDistance maximum distance of the joint
  52533. * @param minDistance minimum distance of the joint
  52534. */
  52535. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52536. /**
  52537. * Sets a motor on the joint
  52538. * @param joint joint to set motor on
  52539. * @param speed speed of the motor
  52540. * @param maxForce maximum force of the motor
  52541. * @param motorIndex index of the motor
  52542. */
  52543. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52544. /**
  52545. * Sets the motors limit
  52546. * @param joint joint to set limit on
  52547. * @param upperLimit upper limit
  52548. * @param lowerLimit lower limit
  52549. */
  52550. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52551. /**
  52552. * Syncs the position and rotation of a mesh with the impostor
  52553. * @param mesh mesh to sync
  52554. * @param impostor impostor to update the mesh with
  52555. */
  52556. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52557. /**
  52558. * Gets the radius of the impostor
  52559. * @param impostor impostor to get radius from
  52560. * @returns the radius
  52561. */
  52562. getRadius(impostor: PhysicsImpostor): number;
  52563. /**
  52564. * Gets the box size of the impostor
  52565. * @param impostor impostor to get box size from
  52566. * @param result the resulting box size
  52567. */
  52568. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52569. /**
  52570. * Disposes of the impostor
  52571. */
  52572. dispose(): void;
  52573. }
  52574. }
  52575. declare module "babylonjs/Physics/Plugins/index" {
  52576. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  52577. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  52578. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  52579. }
  52580. declare module "babylonjs/Physics/index" {
  52581. export * from "babylonjs/Physics/IPhysicsEngine";
  52582. export * from "babylonjs/Physics/physicsEngine";
  52583. export * from "babylonjs/Physics/physicsEngineComponent";
  52584. export * from "babylonjs/Physics/physicsHelper";
  52585. export * from "babylonjs/Physics/physicsImpostor";
  52586. export * from "babylonjs/Physics/physicsJoint";
  52587. export * from "babylonjs/Physics/Plugins/index";
  52588. }
  52589. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  52590. /** @hidden */
  52591. export var blackAndWhitePixelShader: {
  52592. name: string;
  52593. shader: string;
  52594. };
  52595. }
  52596. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  52597. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52598. import { Camera } from "babylonjs/Cameras/camera";
  52599. import { Engine } from "babylonjs/Engines/engine";
  52600. import "babylonjs/Shaders/blackAndWhite.fragment";
  52601. /**
  52602. * Post process used to render in black and white
  52603. */
  52604. export class BlackAndWhitePostProcess extends PostProcess {
  52605. /**
  52606. * Linear about to convert he result to black and white (default: 1)
  52607. */
  52608. degree: number;
  52609. /**
  52610. * Creates a black and white post process
  52611. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52612. * @param name The name of the effect.
  52613. * @param options The required width/height ratio to downsize to before computing the render pass.
  52614. * @param camera The camera to apply the render pass to.
  52615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52616. * @param engine The engine which the post process will be applied. (default: current engine)
  52617. * @param reusable If the post process can be reused on the same frame. (default: false)
  52618. */
  52619. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52620. }
  52621. }
  52622. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  52623. import { Nullable } from "babylonjs/types";
  52624. import { Camera } from "babylonjs/Cameras/camera";
  52625. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52626. import { Engine } from "babylonjs/Engines/engine";
  52627. /**
  52628. * This represents a set of one or more post processes in Babylon.
  52629. * A post process can be used to apply a shader to a texture after it is rendered.
  52630. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52631. */
  52632. export class PostProcessRenderEffect {
  52633. private _postProcesses;
  52634. private _getPostProcesses;
  52635. private _singleInstance;
  52636. private _cameras;
  52637. private _indicesForCamera;
  52638. /**
  52639. * Name of the effect
  52640. * @hidden
  52641. */
  52642. _name: string;
  52643. /**
  52644. * Instantiates a post process render effect.
  52645. * A post process can be used to apply a shader to a texture after it is rendered.
  52646. * @param engine The engine the effect is tied to
  52647. * @param name The name of the effect
  52648. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52649. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52650. */
  52651. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52652. /**
  52653. * Checks if all the post processes in the effect are supported.
  52654. */
  52655. readonly isSupported: boolean;
  52656. /**
  52657. * Updates the current state of the effect
  52658. * @hidden
  52659. */
  52660. _update(): void;
  52661. /**
  52662. * Attaches the effect on cameras
  52663. * @param cameras The camera to attach to.
  52664. * @hidden
  52665. */
  52666. _attachCameras(cameras: Camera): void;
  52667. /**
  52668. * Attaches the effect on cameras
  52669. * @param cameras The camera to attach to.
  52670. * @hidden
  52671. */
  52672. _attachCameras(cameras: Camera[]): void;
  52673. /**
  52674. * Detatches the effect on cameras
  52675. * @param cameras The camera to detatch from.
  52676. * @hidden
  52677. */
  52678. _detachCameras(cameras: Camera): void;
  52679. /**
  52680. * Detatches the effect on cameras
  52681. * @param cameras The camera to detatch from.
  52682. * @hidden
  52683. */
  52684. _detachCameras(cameras: Camera[]): void;
  52685. /**
  52686. * Enables the effect on given cameras
  52687. * @param cameras The camera to enable.
  52688. * @hidden
  52689. */
  52690. _enable(cameras: Camera): void;
  52691. /**
  52692. * Enables the effect on given cameras
  52693. * @param cameras The camera to enable.
  52694. * @hidden
  52695. */
  52696. _enable(cameras: Nullable<Camera[]>): void;
  52697. /**
  52698. * Disables the effect on the given cameras
  52699. * @param cameras The camera to disable.
  52700. * @hidden
  52701. */
  52702. _disable(cameras: Camera): void;
  52703. /**
  52704. * Disables the effect on the given cameras
  52705. * @param cameras The camera to disable.
  52706. * @hidden
  52707. */
  52708. _disable(cameras: Nullable<Camera[]>): void;
  52709. /**
  52710. * Gets a list of the post processes contained in the effect.
  52711. * @param camera The camera to get the post processes on.
  52712. * @returns The list of the post processes in the effect.
  52713. */
  52714. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52715. }
  52716. }
  52717. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  52718. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52719. /** @hidden */
  52720. export var extractHighlightsPixelShader: {
  52721. name: string;
  52722. shader: string;
  52723. };
  52724. }
  52725. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  52726. import { Nullable } from "babylonjs/types";
  52727. import { Camera } from "babylonjs/Cameras/camera";
  52728. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52729. import { Engine } from "babylonjs/Engines/engine";
  52730. import "babylonjs/Shaders/extractHighlights.fragment";
  52731. /**
  52732. * 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.
  52733. */
  52734. export class ExtractHighlightsPostProcess extends PostProcess {
  52735. /**
  52736. * The luminance threshold, pixels below this value will be set to black.
  52737. */
  52738. threshold: number;
  52739. /** @hidden */
  52740. _exposure: number;
  52741. /**
  52742. * Post process which has the input texture to be used when performing highlight extraction
  52743. * @hidden
  52744. */
  52745. _inputPostProcess: Nullable<PostProcess>;
  52746. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52747. }
  52748. }
  52749. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  52750. /** @hidden */
  52751. export var bloomMergePixelShader: {
  52752. name: string;
  52753. shader: string;
  52754. };
  52755. }
  52756. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  52757. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52758. import { Nullable } from "babylonjs/types";
  52759. import { Engine } from "babylonjs/Engines/engine";
  52760. import { Camera } from "babylonjs/Cameras/camera";
  52761. import "babylonjs/Shaders/bloomMerge.fragment";
  52762. /**
  52763. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52764. */
  52765. export class BloomMergePostProcess extends PostProcess {
  52766. /** Weight of the bloom to be added to the original input. */
  52767. weight: number;
  52768. /**
  52769. * Creates a new instance of @see BloomMergePostProcess
  52770. * @param name The name of the effect.
  52771. * @param originalFromInput Post process which's input will be used for the merge.
  52772. * @param blurred Blurred highlights post process which's output will be used.
  52773. * @param weight Weight of the bloom to be added to the original input.
  52774. * @param options The required width/height ratio to downsize to before computing the render pass.
  52775. * @param camera The camera to apply the render pass to.
  52776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52777. * @param engine The engine which the post process will be applied. (default: current engine)
  52778. * @param reusable If the post process can be reused on the same frame. (default: false)
  52779. * @param textureType Type of textures used when performing the post process. (default: 0)
  52780. * @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)
  52781. */
  52782. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52783. /** Weight of the bloom to be added to the original input. */
  52784. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52785. }
  52786. }
  52787. declare module "babylonjs/PostProcesses/bloomEffect" {
  52788. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52789. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52790. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  52791. import { Camera } from "babylonjs/Cameras/camera";
  52792. import { Scene } from "babylonjs/scene";
  52793. /**
  52794. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52795. */
  52796. export class BloomEffect extends PostProcessRenderEffect {
  52797. private bloomScale;
  52798. /**
  52799. * @hidden Internal
  52800. */
  52801. _effects: Array<PostProcess>;
  52802. /**
  52803. * @hidden Internal
  52804. */
  52805. _downscale: ExtractHighlightsPostProcess;
  52806. private _blurX;
  52807. private _blurY;
  52808. private _merge;
  52809. /**
  52810. * The luminance threshold to find bright areas of the image to bloom.
  52811. */
  52812. threshold: number;
  52813. /**
  52814. * The strength of the bloom.
  52815. */
  52816. weight: number;
  52817. /**
  52818. * Specifies the size of the bloom blur kernel, relative to the final output size
  52819. */
  52820. kernel: number;
  52821. /**
  52822. * Creates a new instance of @see BloomEffect
  52823. * @param scene The scene the effect belongs to.
  52824. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52825. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52826. * @param bloomWeight The the strength of bloom.
  52827. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52828. * @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)
  52829. */
  52830. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52831. /**
  52832. * Disposes each of the internal effects for a given camera.
  52833. * @param camera The camera to dispose the effect on.
  52834. */
  52835. disposeEffects(camera: Camera): void;
  52836. /**
  52837. * @hidden Internal
  52838. */
  52839. _updateEffects(): void;
  52840. /**
  52841. * Internal
  52842. * @returns if all the contained post processes are ready.
  52843. * @hidden
  52844. */
  52845. _isReady(): boolean;
  52846. }
  52847. }
  52848. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  52849. /** @hidden */
  52850. export var chromaticAberrationPixelShader: {
  52851. name: string;
  52852. shader: string;
  52853. };
  52854. }
  52855. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  52856. import { Vector2 } from "babylonjs/Maths/math";
  52857. import { Nullable } from "babylonjs/types";
  52858. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52859. import { Camera } from "babylonjs/Cameras/camera";
  52860. import { Engine } from "babylonjs/Engines/engine";
  52861. import "babylonjs/Shaders/chromaticAberration.fragment";
  52862. /**
  52863. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52864. */
  52865. export class ChromaticAberrationPostProcess extends PostProcess {
  52866. /**
  52867. * The amount of seperation of rgb channels (default: 30)
  52868. */
  52869. aberrationAmount: number;
  52870. /**
  52871. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52872. */
  52873. radialIntensity: number;
  52874. /**
  52875. * 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))
  52876. */
  52877. direction: Vector2;
  52878. /**
  52879. * 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))
  52880. */
  52881. centerPosition: Vector2;
  52882. /**
  52883. * Creates a new instance ChromaticAberrationPostProcess
  52884. * @param name The name of the effect.
  52885. * @param screenWidth The width of the screen to apply the effect on.
  52886. * @param screenHeight The height of the screen to apply the effect on.
  52887. * @param options The required width/height ratio to downsize to before computing the render pass.
  52888. * @param camera The camera to apply the render pass to.
  52889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52890. * @param engine The engine which the post process will be applied. (default: current engine)
  52891. * @param reusable If the post process can be reused on the same frame. (default: false)
  52892. * @param textureType Type of textures used when performing the post process. (default: 0)
  52893. * @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)
  52894. */
  52895. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52896. }
  52897. }
  52898. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  52899. /** @hidden */
  52900. export var circleOfConfusionPixelShader: {
  52901. name: string;
  52902. shader: string;
  52903. };
  52904. }
  52905. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  52906. import { Nullable } from "babylonjs/types";
  52907. import { Engine } from "babylonjs/Engines/engine";
  52908. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52909. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52910. import { Camera } from "babylonjs/Cameras/camera";
  52911. import "babylonjs/Shaders/circleOfConfusion.fragment";
  52912. /**
  52913. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52914. */
  52915. export class CircleOfConfusionPostProcess extends PostProcess {
  52916. /**
  52917. * 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.
  52918. */
  52919. lensSize: number;
  52920. /**
  52921. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52922. */
  52923. fStop: number;
  52924. /**
  52925. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52926. */
  52927. focusDistance: number;
  52928. /**
  52929. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52930. */
  52931. focalLength: number;
  52932. private _depthTexture;
  52933. /**
  52934. * Creates a new instance CircleOfConfusionPostProcess
  52935. * @param name The name of the effect.
  52936. * @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.
  52937. * @param options The required width/height ratio to downsize to before computing the render pass.
  52938. * @param camera The camera to apply the render pass to.
  52939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52940. * @param engine The engine which the post process will be applied. (default: current engine)
  52941. * @param reusable If the post process can be reused on the same frame. (default: false)
  52942. * @param textureType Type of textures used when performing the post process. (default: 0)
  52943. * @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)
  52944. */
  52945. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52946. /**
  52947. * 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.
  52948. */
  52949. depthTexture: RenderTargetTexture;
  52950. }
  52951. }
  52952. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  52953. /** @hidden */
  52954. export var colorCorrectionPixelShader: {
  52955. name: string;
  52956. shader: string;
  52957. };
  52958. }
  52959. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  52960. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52961. import { Engine } from "babylonjs/Engines/engine";
  52962. import { Camera } from "babylonjs/Cameras/camera";
  52963. import "babylonjs/Shaders/colorCorrection.fragment";
  52964. /**
  52965. *
  52966. * This post-process allows the modification of rendered colors by using
  52967. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52968. *
  52969. * The object needs to be provided an url to a texture containing the color
  52970. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52971. * Use an image editing software to tweak the LUT to match your needs.
  52972. *
  52973. * For an example of a color LUT, see here:
  52974. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52975. * For explanations on color grading, see here:
  52976. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52977. *
  52978. */
  52979. export class ColorCorrectionPostProcess extends PostProcess {
  52980. private _colorTableTexture;
  52981. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52982. }
  52983. }
  52984. declare module "babylonjs/Shaders/convolution.fragment" {
  52985. /** @hidden */
  52986. export var convolutionPixelShader: {
  52987. name: string;
  52988. shader: string;
  52989. };
  52990. }
  52991. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  52992. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52993. import { Nullable } from "babylonjs/types";
  52994. import { Camera } from "babylonjs/Cameras/camera";
  52995. import { Engine } from "babylonjs/Engines/engine";
  52996. import "babylonjs/Shaders/convolution.fragment";
  52997. /**
  52998. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52999. * input texture to perform effects such as edge detection or sharpening
  53000. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53001. */
  53002. export class ConvolutionPostProcess extends PostProcess {
  53003. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53004. kernel: number[];
  53005. /**
  53006. * Creates a new instance ConvolutionPostProcess
  53007. * @param name The name of the effect.
  53008. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53009. * @param options The required width/height ratio to downsize to before computing the render pass.
  53010. * @param camera The camera to apply the render pass to.
  53011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53012. * @param engine The engine which the post process will be applied. (default: current engine)
  53013. * @param reusable If the post process can be reused on the same frame. (default: false)
  53014. * @param textureType Type of textures used when performing the post process. (default: 0)
  53015. */
  53016. constructor(name: string,
  53017. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53018. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53019. /**
  53020. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53021. */
  53022. static EdgeDetect0Kernel: number[];
  53023. /**
  53024. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53025. */
  53026. static EdgeDetect1Kernel: number[];
  53027. /**
  53028. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53029. */
  53030. static EdgeDetect2Kernel: number[];
  53031. /**
  53032. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53033. */
  53034. static SharpenKernel: number[];
  53035. /**
  53036. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53037. */
  53038. static EmbossKernel: number[];
  53039. /**
  53040. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53041. */
  53042. static GaussianKernel: number[];
  53043. }
  53044. }
  53045. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53046. import { Nullable } from "babylonjs/types";
  53047. import { Vector2 } from "babylonjs/Maths/math";
  53048. import { Camera } from "babylonjs/Cameras/camera";
  53049. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53050. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53051. import { Engine } from "babylonjs/Engines/engine";
  53052. import { Scene } from "babylonjs/scene";
  53053. /**
  53054. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53055. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53056. * based on samples that have a large difference in distance than the center pixel.
  53057. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53058. */
  53059. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53060. direction: Vector2;
  53061. /**
  53062. * Creates a new instance CircleOfConfusionPostProcess
  53063. * @param name The name of the effect.
  53064. * @param scene The scene the effect belongs to.
  53065. * @param direction The direction the blur should be applied.
  53066. * @param kernel The size of the kernel used to blur.
  53067. * @param options The required width/height ratio to downsize to before computing the render pass.
  53068. * @param camera The camera to apply the render pass to.
  53069. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53070. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53072. * @param engine The engine which the post process will be applied. (default: current engine)
  53073. * @param reusable If the post process can be reused on the same frame. (default: false)
  53074. * @param textureType Type of textures used when performing the post process. (default: 0)
  53075. * @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)
  53076. */
  53077. 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);
  53078. }
  53079. }
  53080. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53081. /** @hidden */
  53082. export var depthOfFieldMergePixelShader: {
  53083. name: string;
  53084. shader: string;
  53085. };
  53086. }
  53087. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53088. import { Nullable } from "babylonjs/types";
  53089. import { Camera } from "babylonjs/Cameras/camera";
  53090. import { Effect } from "babylonjs/Materials/effect";
  53091. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53092. import { Engine } from "babylonjs/Engines/engine";
  53093. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53094. /**
  53095. * Options to be set when merging outputs from the default pipeline.
  53096. */
  53097. export class DepthOfFieldMergePostProcessOptions {
  53098. /**
  53099. * The original image to merge on top of
  53100. */
  53101. originalFromInput: PostProcess;
  53102. /**
  53103. * Parameters to perform the merge of the depth of field effect
  53104. */
  53105. depthOfField?: {
  53106. circleOfConfusion: PostProcess;
  53107. blurSteps: Array<PostProcess>;
  53108. };
  53109. /**
  53110. * Parameters to perform the merge of bloom effect
  53111. */
  53112. bloom?: {
  53113. blurred: PostProcess;
  53114. weight: number;
  53115. };
  53116. }
  53117. /**
  53118. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53119. */
  53120. export class DepthOfFieldMergePostProcess extends PostProcess {
  53121. private blurSteps;
  53122. /**
  53123. * Creates a new instance of DepthOfFieldMergePostProcess
  53124. * @param name The name of the effect.
  53125. * @param originalFromInput Post process which's input will be used for the merge.
  53126. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53127. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53128. * @param options The required width/height ratio to downsize to before computing the render pass.
  53129. * @param camera The camera to apply the render pass to.
  53130. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53131. * @param engine The engine which the post process will be applied. (default: current engine)
  53132. * @param reusable If the post process can be reused on the same frame. (default: false)
  53133. * @param textureType Type of textures used when performing the post process. (default: 0)
  53134. * @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)
  53135. */
  53136. 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);
  53137. /**
  53138. * Updates the effect with the current post process compile time values and recompiles the shader.
  53139. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53140. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53141. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53142. * @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
  53143. * @param onCompiled Called when the shader has been compiled.
  53144. * @param onError Called if there is an error when compiling a shader.
  53145. */
  53146. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53147. }
  53148. }
  53149. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53150. import { Nullable } from "babylonjs/types";
  53151. import { Camera } from "babylonjs/Cameras/camera";
  53152. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53153. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53154. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53155. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53156. import { Scene } from "babylonjs/scene";
  53157. /**
  53158. * Specifies the level of max blur that should be applied when using the depth of field effect
  53159. */
  53160. export enum DepthOfFieldEffectBlurLevel {
  53161. /**
  53162. * Subtle blur
  53163. */
  53164. Low = 0,
  53165. /**
  53166. * Medium blur
  53167. */
  53168. Medium = 1,
  53169. /**
  53170. * Large blur
  53171. */
  53172. High = 2
  53173. }
  53174. /**
  53175. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53176. */
  53177. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53178. private _circleOfConfusion;
  53179. /**
  53180. * @hidden Internal, blurs from high to low
  53181. */
  53182. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53183. private _depthOfFieldBlurY;
  53184. private _dofMerge;
  53185. /**
  53186. * @hidden Internal post processes in depth of field effect
  53187. */
  53188. _effects: Array<PostProcess>;
  53189. /**
  53190. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53191. */
  53192. focalLength: number;
  53193. /**
  53194. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53195. */
  53196. fStop: number;
  53197. /**
  53198. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53199. */
  53200. focusDistance: number;
  53201. /**
  53202. * 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.
  53203. */
  53204. lensSize: number;
  53205. /**
  53206. * Creates a new instance DepthOfFieldEffect
  53207. * @param scene The scene the effect belongs to.
  53208. * @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.
  53209. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53210. * @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)
  53211. */
  53212. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53213. /**
  53214. * 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.
  53215. */
  53216. depthTexture: RenderTargetTexture;
  53217. /**
  53218. * Disposes each of the internal effects for a given camera.
  53219. * @param camera The camera to dispose the effect on.
  53220. */
  53221. disposeEffects(camera: Camera): void;
  53222. /**
  53223. * @hidden Internal
  53224. */
  53225. _updateEffects(): void;
  53226. /**
  53227. * Internal
  53228. * @returns if all the contained post processes are ready.
  53229. * @hidden
  53230. */
  53231. _isReady(): boolean;
  53232. }
  53233. }
  53234. declare module "babylonjs/Shaders/displayPass.fragment" {
  53235. /** @hidden */
  53236. export var displayPassPixelShader: {
  53237. name: string;
  53238. shader: string;
  53239. };
  53240. }
  53241. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53242. import { Nullable } from "babylonjs/types";
  53243. import { Camera } from "babylonjs/Cameras/camera";
  53244. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53245. import { Engine } from "babylonjs/Engines/engine";
  53246. import "babylonjs/Shaders/displayPass.fragment";
  53247. /**
  53248. * DisplayPassPostProcess which produces an output the same as it's input
  53249. */
  53250. export class DisplayPassPostProcess extends PostProcess {
  53251. /**
  53252. * Creates the DisplayPassPostProcess
  53253. * @param name The name of the effect.
  53254. * @param options The required width/height ratio to downsize to before computing the render pass.
  53255. * @param camera The camera to apply the render pass to.
  53256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53257. * @param engine The engine which the post process will be applied. (default: current engine)
  53258. * @param reusable If the post process can be reused on the same frame. (default: false)
  53259. */
  53260. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53261. }
  53262. }
  53263. declare module "babylonjs/Shaders/filter.fragment" {
  53264. /** @hidden */
  53265. export var filterPixelShader: {
  53266. name: string;
  53267. shader: string;
  53268. };
  53269. }
  53270. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53271. import { Nullable } from "babylonjs/types";
  53272. import { Matrix } from "babylonjs/Maths/math";
  53273. import { Camera } from "babylonjs/Cameras/camera";
  53274. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53275. import { Engine } from "babylonjs/Engines/engine";
  53276. import "babylonjs/Shaders/filter.fragment";
  53277. /**
  53278. * Applies a kernel filter to the image
  53279. */
  53280. export class FilterPostProcess extends PostProcess {
  53281. /** The matrix to be applied to the image */
  53282. kernelMatrix: Matrix;
  53283. /**
  53284. *
  53285. * @param name The name of the effect.
  53286. * @param kernelMatrix The matrix to be applied to the image
  53287. * @param options The required width/height ratio to downsize to before computing the render pass.
  53288. * @param camera The camera to apply the render pass to.
  53289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53290. * @param engine The engine which the post process will be applied. (default: current engine)
  53291. * @param reusable If the post process can be reused on the same frame. (default: false)
  53292. */
  53293. constructor(name: string,
  53294. /** The matrix to be applied to the image */
  53295. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53296. }
  53297. }
  53298. declare module "babylonjs/Shaders/fxaa.fragment" {
  53299. /** @hidden */
  53300. export var fxaaPixelShader: {
  53301. name: string;
  53302. shader: string;
  53303. };
  53304. }
  53305. declare module "babylonjs/Shaders/fxaa.vertex" {
  53306. /** @hidden */
  53307. export var fxaaVertexShader: {
  53308. name: string;
  53309. shader: string;
  53310. };
  53311. }
  53312. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53313. import { Nullable } from "babylonjs/types";
  53314. import { Camera } from "babylonjs/Cameras/camera";
  53315. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53316. import { Engine } from "babylonjs/Engines/engine";
  53317. import "babylonjs/Shaders/fxaa.fragment";
  53318. import "babylonjs/Shaders/fxaa.vertex";
  53319. /**
  53320. * Fxaa post process
  53321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53322. */
  53323. export class FxaaPostProcess extends PostProcess {
  53324. /** @hidden */
  53325. texelWidth: number;
  53326. /** @hidden */
  53327. texelHeight: number;
  53328. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53329. private _getDefines;
  53330. }
  53331. }
  53332. declare module "babylonjs/Shaders/grain.fragment" {
  53333. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53334. /** @hidden */
  53335. export var grainPixelShader: {
  53336. name: string;
  53337. shader: string;
  53338. };
  53339. }
  53340. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53341. import { Nullable } from "babylonjs/types";
  53342. import { Camera } from "babylonjs/Cameras/camera";
  53343. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53344. import { Engine } from "babylonjs/Engines/engine";
  53345. import "babylonjs/Shaders/grain.fragment";
  53346. /**
  53347. * The GrainPostProcess adds noise to the image at mid luminance levels
  53348. */
  53349. export class GrainPostProcess extends PostProcess {
  53350. /**
  53351. * The intensity of the grain added (default: 30)
  53352. */
  53353. intensity: number;
  53354. /**
  53355. * If the grain should be randomized on every frame
  53356. */
  53357. animated: boolean;
  53358. /**
  53359. * Creates a new instance of @see GrainPostProcess
  53360. * @param name The name of the effect.
  53361. * @param options The required width/height ratio to downsize to before computing the render pass.
  53362. * @param camera The camera to apply the render pass to.
  53363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53364. * @param engine The engine which the post process will be applied. (default: current engine)
  53365. * @param reusable If the post process can be reused on the same frame. (default: false)
  53366. * @param textureType Type of textures used when performing the post process. (default: 0)
  53367. * @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)
  53368. */
  53369. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53370. }
  53371. }
  53372. declare module "babylonjs/Shaders/highlights.fragment" {
  53373. /** @hidden */
  53374. export var highlightsPixelShader: {
  53375. name: string;
  53376. shader: string;
  53377. };
  53378. }
  53379. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  53380. import { Nullable } from "babylonjs/types";
  53381. import { Camera } from "babylonjs/Cameras/camera";
  53382. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53383. import { Engine } from "babylonjs/Engines/engine";
  53384. import "babylonjs/Shaders/highlights.fragment";
  53385. /**
  53386. * Extracts highlights from the image
  53387. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53388. */
  53389. export class HighlightsPostProcess extends PostProcess {
  53390. /**
  53391. * Extracts highlights from the image
  53392. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53393. * @param name The name of the effect.
  53394. * @param options The required width/height ratio to downsize to before computing the render pass.
  53395. * @param camera The camera to apply the render pass to.
  53396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53397. * @param engine The engine which the post process will be applied. (default: current engine)
  53398. * @param reusable If the post process can be reused on the same frame. (default: false)
  53399. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53400. */
  53401. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53402. }
  53403. }
  53404. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  53405. /** @hidden */
  53406. export var mrtFragmentDeclaration: {
  53407. name: string;
  53408. shader: string;
  53409. };
  53410. }
  53411. declare module "babylonjs/Shaders/geometry.fragment" {
  53412. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  53413. /** @hidden */
  53414. export var geometryPixelShader: {
  53415. name: string;
  53416. shader: string;
  53417. };
  53418. }
  53419. declare module "babylonjs/Shaders/geometry.vertex" {
  53420. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53421. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53422. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53423. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53424. /** @hidden */
  53425. export var geometryVertexShader: {
  53426. name: string;
  53427. shader: string;
  53428. };
  53429. }
  53430. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  53431. import { Matrix } from "babylonjs/Maths/math";
  53432. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53433. import { Mesh } from "babylonjs/Meshes/mesh";
  53434. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  53435. import { Effect } from "babylonjs/Materials/effect";
  53436. import { Scene } from "babylonjs/scene";
  53437. import "babylonjs/Shaders/geometry.fragment";
  53438. import "babylonjs/Shaders/geometry.vertex";
  53439. /**
  53440. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53441. */
  53442. export class GeometryBufferRenderer {
  53443. /**
  53444. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53445. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53446. */
  53447. static readonly POSITION_TEXTURE_TYPE: number;
  53448. /**
  53449. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53450. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53451. */
  53452. static readonly VELOCITY_TEXTURE_TYPE: number;
  53453. /**
  53454. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53455. * in order to compute objects velocities when enableVelocity is set to "true"
  53456. * @hidden
  53457. */
  53458. _previousTransformationMatrices: {
  53459. [index: number]: Matrix;
  53460. };
  53461. private _scene;
  53462. private _multiRenderTarget;
  53463. private _ratio;
  53464. private _enablePosition;
  53465. private _enableVelocity;
  53466. private _positionIndex;
  53467. private _velocityIndex;
  53468. protected _effect: Effect;
  53469. protected _cachedDefines: string;
  53470. /**
  53471. * Set the render list (meshes to be rendered) used in the G buffer.
  53472. */
  53473. renderList: Mesh[];
  53474. /**
  53475. * Gets wether or not G buffer are supported by the running hardware.
  53476. * This requires draw buffer supports
  53477. */
  53478. readonly isSupported: boolean;
  53479. /**
  53480. * Returns the index of the given texture type in the G-Buffer textures array
  53481. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53482. * @returns the index of the given texture type in the G-Buffer textures array
  53483. */
  53484. getTextureIndex(textureType: number): number;
  53485. /**
  53486. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53487. */
  53488. /**
  53489. * Sets whether or not objects positions are enabled for the G buffer.
  53490. */
  53491. enablePosition: boolean;
  53492. /**
  53493. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53494. */
  53495. /**
  53496. * Sets wether or not objects velocities are enabled for the G buffer.
  53497. */
  53498. enableVelocity: boolean;
  53499. /**
  53500. * Gets the scene associated with the buffer.
  53501. */
  53502. readonly scene: Scene;
  53503. /**
  53504. * Gets the ratio used by the buffer during its creation.
  53505. * How big is the buffer related to the main canvas.
  53506. */
  53507. readonly ratio: number;
  53508. /** @hidden */
  53509. static _SceneComponentInitialization: (scene: Scene) => void;
  53510. /**
  53511. * Creates a new G Buffer for the scene
  53512. * @param scene The scene the buffer belongs to
  53513. * @param ratio How big is the buffer related to the main canvas.
  53514. */
  53515. constructor(scene: Scene, ratio?: number);
  53516. /**
  53517. * Checks wether everything is ready to render a submesh to the G buffer.
  53518. * @param subMesh the submesh to check readiness for
  53519. * @param useInstances is the mesh drawn using instance or not
  53520. * @returns true if ready otherwise false
  53521. */
  53522. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53523. /**
  53524. * Gets the current underlying G Buffer.
  53525. * @returns the buffer
  53526. */
  53527. getGBuffer(): MultiRenderTarget;
  53528. /**
  53529. * Gets the number of samples used to render the buffer (anti aliasing).
  53530. */
  53531. /**
  53532. * Sets the number of samples used to render the buffer (anti aliasing).
  53533. */
  53534. samples: number;
  53535. /**
  53536. * Disposes the renderer and frees up associated resources.
  53537. */
  53538. dispose(): void;
  53539. protected _createRenderTargets(): void;
  53540. }
  53541. }
  53542. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  53543. import { Nullable } from "babylonjs/types";
  53544. import { Scene } from "babylonjs/scene";
  53545. import { ISceneComponent } from "babylonjs/sceneComponent";
  53546. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  53547. module "babylonjs/scene" {
  53548. interface Scene {
  53549. /** @hidden (Backing field) */
  53550. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53551. /**
  53552. * Gets or Sets the current geometry buffer associated to the scene.
  53553. */
  53554. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53555. /**
  53556. * Enables a GeometryBufferRender and associates it with the scene
  53557. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53558. * @returns the GeometryBufferRenderer
  53559. */
  53560. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53561. /**
  53562. * Disables the GeometryBufferRender associated with the scene
  53563. */
  53564. disableGeometryBufferRenderer(): void;
  53565. }
  53566. }
  53567. /**
  53568. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53569. * in several rendering techniques.
  53570. */
  53571. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53572. /**
  53573. * The component name helpful to identify the component in the list of scene components.
  53574. */
  53575. readonly name: string;
  53576. /**
  53577. * The scene the component belongs to.
  53578. */
  53579. scene: Scene;
  53580. /**
  53581. * Creates a new instance of the component for the given scene
  53582. * @param scene Defines the scene to register the component in
  53583. */
  53584. constructor(scene: Scene);
  53585. /**
  53586. * Registers the component in a given scene
  53587. */
  53588. register(): void;
  53589. /**
  53590. * Rebuilds the elements related to this component in case of
  53591. * context lost for instance.
  53592. */
  53593. rebuild(): void;
  53594. /**
  53595. * Disposes the component and the associated ressources
  53596. */
  53597. dispose(): void;
  53598. private _gatherRenderTargets;
  53599. }
  53600. }
  53601. declare module "babylonjs/Shaders/motionBlur.fragment" {
  53602. /** @hidden */
  53603. export var motionBlurPixelShader: {
  53604. name: string;
  53605. shader: string;
  53606. };
  53607. }
  53608. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  53609. import { Nullable } from "babylonjs/types";
  53610. import { Camera } from "babylonjs/Cameras/camera";
  53611. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53612. import { Scene } from "babylonjs/scene";
  53613. import "babylonjs/Animations/animatable";
  53614. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  53615. import "babylonjs/Shaders/motionBlur.fragment";
  53616. import { Engine } from "babylonjs/Engines/engine";
  53617. /**
  53618. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53619. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53620. * As an example, all you have to do is to create the post-process:
  53621. * var mb = new BABYLON.MotionBlurPostProcess(
  53622. * 'mb', // The name of the effect.
  53623. * scene, // The scene containing the objects to blur according to their velocity.
  53624. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53625. * camera // The camera to apply the render pass to.
  53626. * );
  53627. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53628. */
  53629. export class MotionBlurPostProcess extends PostProcess {
  53630. /**
  53631. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53632. */
  53633. motionStrength: number;
  53634. /**
  53635. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53636. */
  53637. /**
  53638. * Sets the number of iterations to be used for motion blur quality
  53639. */
  53640. motionBlurSamples: number;
  53641. private _motionBlurSamples;
  53642. private _geometryBufferRenderer;
  53643. /**
  53644. * Creates a new instance MotionBlurPostProcess
  53645. * @param name The name of the effect.
  53646. * @param scene The scene containing the objects to blur according to their velocity.
  53647. * @param options The required width/height ratio to downsize to before computing the render pass.
  53648. * @param camera The camera to apply the render pass to.
  53649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53650. * @param engine The engine which the post process will be applied. (default: current engine)
  53651. * @param reusable If the post process can be reused on the same frame. (default: false)
  53652. * @param textureType Type of textures used when performing the post process. (default: 0)
  53653. * @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)
  53654. */
  53655. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53656. /**
  53657. * Disposes the post process.
  53658. * @param camera The camera to dispose the post process on.
  53659. */
  53660. dispose(camera?: Camera): void;
  53661. }
  53662. }
  53663. declare module "babylonjs/Shaders/refraction.fragment" {
  53664. /** @hidden */
  53665. export var refractionPixelShader: {
  53666. name: string;
  53667. shader: string;
  53668. };
  53669. }
  53670. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  53671. import { Color3 } from "babylonjs/Maths/math";
  53672. import { Camera } from "babylonjs/Cameras/camera";
  53673. import { Texture } from "babylonjs/Materials/Textures/texture";
  53674. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53675. import { Engine } from "babylonjs/Engines/engine";
  53676. import "babylonjs/Shaders/refraction.fragment";
  53677. /**
  53678. * Post process which applies a refractin texture
  53679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53680. */
  53681. export class RefractionPostProcess extends PostProcess {
  53682. /** the base color of the refraction (used to taint the rendering) */
  53683. color: Color3;
  53684. /** simulated refraction depth */
  53685. depth: number;
  53686. /** the coefficient of the base color (0 to remove base color tainting) */
  53687. colorLevel: number;
  53688. private _refTexture;
  53689. private _ownRefractionTexture;
  53690. /**
  53691. * Gets or sets the refraction texture
  53692. * Please note that you are responsible for disposing the texture if you set it manually
  53693. */
  53694. refractionTexture: Texture;
  53695. /**
  53696. * Initializes the RefractionPostProcess
  53697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53698. * @param name The name of the effect.
  53699. * @param refractionTextureUrl Url of the refraction texture to use
  53700. * @param color the base color of the refraction (used to taint the rendering)
  53701. * @param depth simulated refraction depth
  53702. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53703. * @param camera The camera to apply the render pass to.
  53704. * @param options The required width/height ratio to downsize to before computing the render pass.
  53705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53706. * @param engine The engine which the post process will be applied. (default: current engine)
  53707. * @param reusable If the post process can be reused on the same frame. (default: false)
  53708. */
  53709. constructor(name: string, refractionTextureUrl: string,
  53710. /** the base color of the refraction (used to taint the rendering) */
  53711. color: Color3,
  53712. /** simulated refraction depth */
  53713. depth: number,
  53714. /** the coefficient of the base color (0 to remove base color tainting) */
  53715. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53716. /**
  53717. * Disposes of the post process
  53718. * @param camera Camera to dispose post process on
  53719. */
  53720. dispose(camera: Camera): void;
  53721. }
  53722. }
  53723. declare module "babylonjs/Shaders/sharpen.fragment" {
  53724. /** @hidden */
  53725. export var sharpenPixelShader: {
  53726. name: string;
  53727. shader: string;
  53728. };
  53729. }
  53730. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  53731. import { Nullable } from "babylonjs/types";
  53732. import { Camera } from "babylonjs/Cameras/camera";
  53733. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53734. import "babylonjs/Shaders/sharpen.fragment";
  53735. import { Engine } from "babylonjs/Engines/engine";
  53736. /**
  53737. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53738. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53739. */
  53740. export class SharpenPostProcess extends PostProcess {
  53741. /**
  53742. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53743. */
  53744. colorAmount: number;
  53745. /**
  53746. * How much sharpness should be applied (default: 0.3)
  53747. */
  53748. edgeAmount: number;
  53749. /**
  53750. * Creates a new instance ConvolutionPostProcess
  53751. * @param name The name of the effect.
  53752. * @param options The required width/height ratio to downsize to before computing the render pass.
  53753. * @param camera The camera to apply the render pass to.
  53754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53755. * @param engine The engine which the post process will be applied. (default: current engine)
  53756. * @param reusable If the post process can be reused on the same frame. (default: false)
  53757. * @param textureType Type of textures used when performing the post process. (default: 0)
  53758. * @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)
  53759. */
  53760. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53761. }
  53762. }
  53763. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  53764. import { Nullable } from "babylonjs/types";
  53765. import { Camera } from "babylonjs/Cameras/camera";
  53766. import { Engine } from "babylonjs/Engines/engine";
  53767. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53768. /**
  53769. * PostProcessRenderPipeline
  53770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53771. */
  53772. export class PostProcessRenderPipeline {
  53773. private engine;
  53774. private _renderEffects;
  53775. private _renderEffectsForIsolatedPass;
  53776. /**
  53777. * @hidden
  53778. */
  53779. protected _cameras: Camera[];
  53780. /** @hidden */
  53781. _name: string;
  53782. /**
  53783. * Gets pipeline name
  53784. */
  53785. readonly name: string;
  53786. /**
  53787. * Initializes a PostProcessRenderPipeline
  53788. * @param engine engine to add the pipeline to
  53789. * @param name name of the pipeline
  53790. */
  53791. constructor(engine: Engine, name: string);
  53792. /**
  53793. * Gets the class name
  53794. * @returns "PostProcessRenderPipeline"
  53795. */
  53796. getClassName(): string;
  53797. /**
  53798. * If all the render effects in the pipeline are supported
  53799. */
  53800. readonly isSupported: boolean;
  53801. /**
  53802. * Adds an effect to the pipeline
  53803. * @param renderEffect the effect to add
  53804. */
  53805. addEffect(renderEffect: PostProcessRenderEffect): void;
  53806. /** @hidden */
  53807. _rebuild(): void;
  53808. /** @hidden */
  53809. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53810. /** @hidden */
  53811. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53812. /** @hidden */
  53813. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53814. /** @hidden */
  53815. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53816. /** @hidden */
  53817. _attachCameras(cameras: Camera, unique: boolean): void;
  53818. /** @hidden */
  53819. _attachCameras(cameras: Camera[], unique: boolean): void;
  53820. /** @hidden */
  53821. _detachCameras(cameras: Camera): void;
  53822. /** @hidden */
  53823. _detachCameras(cameras: Nullable<Camera[]>): void;
  53824. /** @hidden */
  53825. _update(): void;
  53826. /** @hidden */
  53827. _reset(): void;
  53828. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53829. /**
  53830. * Disposes of the pipeline
  53831. */
  53832. dispose(): void;
  53833. }
  53834. }
  53835. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53836. import { Camera } from "babylonjs/Cameras/camera";
  53837. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53838. /**
  53839. * PostProcessRenderPipelineManager class
  53840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53841. */
  53842. export class PostProcessRenderPipelineManager {
  53843. private _renderPipelines;
  53844. /**
  53845. * Initializes a PostProcessRenderPipelineManager
  53846. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53847. */
  53848. constructor();
  53849. /**
  53850. * Gets the list of supported render pipelines
  53851. */
  53852. readonly supportedPipelines: PostProcessRenderPipeline[];
  53853. /**
  53854. * Adds a pipeline to the manager
  53855. * @param renderPipeline The pipeline to add
  53856. */
  53857. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53858. /**
  53859. * Attaches a camera to the pipeline
  53860. * @param renderPipelineName The name of the pipeline to attach to
  53861. * @param cameras the camera to attach
  53862. * @param unique if the camera can be attached multiple times to the pipeline
  53863. */
  53864. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53865. /**
  53866. * Detaches a camera from the pipeline
  53867. * @param renderPipelineName The name of the pipeline to detach from
  53868. * @param cameras the camera to detach
  53869. */
  53870. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53871. /**
  53872. * Enables an effect by name on a pipeline
  53873. * @param renderPipelineName the name of the pipeline to enable the effect in
  53874. * @param renderEffectName the name of the effect to enable
  53875. * @param cameras the cameras that the effect should be enabled on
  53876. */
  53877. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53878. /**
  53879. * Disables an effect by name on a pipeline
  53880. * @param renderPipelineName the name of the pipeline to disable the effect in
  53881. * @param renderEffectName the name of the effect to disable
  53882. * @param cameras the cameras that the effect should be disabled on
  53883. */
  53884. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53885. /**
  53886. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53887. */
  53888. update(): void;
  53889. /** @hidden */
  53890. _rebuild(): void;
  53891. /**
  53892. * Disposes of the manager and pipelines
  53893. */
  53894. dispose(): void;
  53895. }
  53896. }
  53897. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53898. import { ISceneComponent } from "babylonjs/sceneComponent";
  53899. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53900. import { Scene } from "babylonjs/scene";
  53901. module "babylonjs/scene" {
  53902. interface Scene {
  53903. /** @hidden (Backing field) */
  53904. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53905. /**
  53906. * Gets the postprocess render pipeline manager
  53907. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53908. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53909. */
  53910. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53911. }
  53912. }
  53913. /**
  53914. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53915. */
  53916. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53917. /**
  53918. * The component name helpfull to identify the component in the list of scene components.
  53919. */
  53920. readonly name: string;
  53921. /**
  53922. * The scene the component belongs to.
  53923. */
  53924. scene: Scene;
  53925. /**
  53926. * Creates a new instance of the component for the given scene
  53927. * @param scene Defines the scene to register the component in
  53928. */
  53929. constructor(scene: Scene);
  53930. /**
  53931. * Registers the component in a given scene
  53932. */
  53933. register(): void;
  53934. /**
  53935. * Rebuilds the elements related to this component in case of
  53936. * context lost for instance.
  53937. */
  53938. rebuild(): void;
  53939. /**
  53940. * Disposes the component and the associated ressources
  53941. */
  53942. dispose(): void;
  53943. private _gatherRenderTargets;
  53944. }
  53945. }
  53946. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  53947. import { IAnimatable } from "babylonjs/Misc/tools";
  53948. import { Camera } from "babylonjs/Cameras/camera";
  53949. import { IDisposable } from "babylonjs/scene";
  53950. import { Scene } from "babylonjs/scene";
  53951. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  53952. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53953. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53954. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  53955. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53956. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53957. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  53958. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53959. import { Animation } from "babylonjs/Animations/animation";
  53960. /**
  53961. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53962. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53963. */
  53964. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53965. private _scene;
  53966. private _camerasToBeAttached;
  53967. /**
  53968. * ID of the sharpen post process,
  53969. */
  53970. private readonly SharpenPostProcessId;
  53971. /**
  53972. * @ignore
  53973. * ID of the image processing post process;
  53974. */
  53975. readonly ImageProcessingPostProcessId: string;
  53976. /**
  53977. * @ignore
  53978. * ID of the Fast Approximate Anti-Aliasing post process;
  53979. */
  53980. readonly FxaaPostProcessId: string;
  53981. /**
  53982. * ID of the chromatic aberration post process,
  53983. */
  53984. private readonly ChromaticAberrationPostProcessId;
  53985. /**
  53986. * ID of the grain post process
  53987. */
  53988. private readonly GrainPostProcessId;
  53989. /**
  53990. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53991. */
  53992. sharpen: SharpenPostProcess;
  53993. private _sharpenEffect;
  53994. private bloom;
  53995. /**
  53996. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53997. */
  53998. depthOfField: DepthOfFieldEffect;
  53999. /**
  54000. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54001. */
  54002. fxaa: FxaaPostProcess;
  54003. /**
  54004. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54005. */
  54006. imageProcessing: ImageProcessingPostProcess;
  54007. /**
  54008. * Chromatic aberration post process which will shift rgb colors in the image
  54009. */
  54010. chromaticAberration: ChromaticAberrationPostProcess;
  54011. private _chromaticAberrationEffect;
  54012. /**
  54013. * Grain post process which add noise to the image
  54014. */
  54015. grain: GrainPostProcess;
  54016. private _grainEffect;
  54017. /**
  54018. * Glow post process which adds a glow to emissive areas of the image
  54019. */
  54020. private _glowLayer;
  54021. /**
  54022. * Animations which can be used to tweak settings over a period of time
  54023. */
  54024. animations: Animation[];
  54025. private _imageProcessingConfigurationObserver;
  54026. private _sharpenEnabled;
  54027. private _bloomEnabled;
  54028. private _depthOfFieldEnabled;
  54029. private _depthOfFieldBlurLevel;
  54030. private _fxaaEnabled;
  54031. private _imageProcessingEnabled;
  54032. private _defaultPipelineTextureType;
  54033. private _bloomScale;
  54034. private _chromaticAberrationEnabled;
  54035. private _grainEnabled;
  54036. private _buildAllowed;
  54037. /**
  54038. * Gets active scene
  54039. */
  54040. readonly scene: Scene;
  54041. /**
  54042. * Enable or disable the sharpen process from the pipeline
  54043. */
  54044. sharpenEnabled: boolean;
  54045. private _resizeObserver;
  54046. private _hardwareScaleLevel;
  54047. private _bloomKernel;
  54048. /**
  54049. * Specifies the size of the bloom blur kernel, relative to the final output size
  54050. */
  54051. bloomKernel: number;
  54052. /**
  54053. * Specifies the weight of the bloom in the final rendering
  54054. */
  54055. private _bloomWeight;
  54056. /**
  54057. * Specifies the luma threshold for the area that will be blurred by the bloom
  54058. */
  54059. private _bloomThreshold;
  54060. private _hdr;
  54061. /**
  54062. * The strength of the bloom.
  54063. */
  54064. bloomWeight: number;
  54065. /**
  54066. * The strength of the bloom.
  54067. */
  54068. bloomThreshold: number;
  54069. /**
  54070. * The scale of the bloom, lower value will provide better performance.
  54071. */
  54072. bloomScale: number;
  54073. /**
  54074. * Enable or disable the bloom from the pipeline
  54075. */
  54076. bloomEnabled: boolean;
  54077. private _rebuildBloom;
  54078. /**
  54079. * If the depth of field is enabled.
  54080. */
  54081. depthOfFieldEnabled: boolean;
  54082. /**
  54083. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54084. */
  54085. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54086. /**
  54087. * If the anti aliasing is enabled.
  54088. */
  54089. fxaaEnabled: boolean;
  54090. private _samples;
  54091. /**
  54092. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54093. */
  54094. samples: number;
  54095. /**
  54096. * If image processing is enabled.
  54097. */
  54098. imageProcessingEnabled: boolean;
  54099. /**
  54100. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54101. */
  54102. glowLayerEnabled: boolean;
  54103. /**
  54104. * Enable or disable the chromaticAberration process from the pipeline
  54105. */
  54106. chromaticAberrationEnabled: boolean;
  54107. /**
  54108. * Enable or disable the grain process from the pipeline
  54109. */
  54110. grainEnabled: boolean;
  54111. /**
  54112. * @constructor
  54113. * @param name - The rendering pipeline name (default: "")
  54114. * @param hdr - If high dynamic range textures should be used (default: true)
  54115. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54116. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54117. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54118. */
  54119. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54120. /**
  54121. * Get the class name
  54122. * @returns "DefaultRenderingPipeline"
  54123. */
  54124. getClassName(): string;
  54125. /**
  54126. * Force the compilation of the entire pipeline.
  54127. */
  54128. prepare(): void;
  54129. private _hasCleared;
  54130. private _prevPostProcess;
  54131. private _prevPrevPostProcess;
  54132. private _setAutoClearAndTextureSharing;
  54133. private _depthOfFieldSceneObserver;
  54134. private _buildPipeline;
  54135. private _disposePostProcesses;
  54136. /**
  54137. * Adds a camera to the pipeline
  54138. * @param camera the camera to be added
  54139. */
  54140. addCamera(camera: Camera): void;
  54141. /**
  54142. * Removes a camera from the pipeline
  54143. * @param camera the camera to remove
  54144. */
  54145. removeCamera(camera: Camera): void;
  54146. /**
  54147. * Dispose of the pipeline and stop all post processes
  54148. */
  54149. dispose(): void;
  54150. /**
  54151. * Serialize the rendering pipeline (Used when exporting)
  54152. * @returns the serialized object
  54153. */
  54154. serialize(): any;
  54155. /**
  54156. * Parse the serialized pipeline
  54157. * @param source Source pipeline.
  54158. * @param scene The scene to load the pipeline to.
  54159. * @param rootUrl The URL of the serialized pipeline.
  54160. * @returns An instantiated pipeline from the serialized object.
  54161. */
  54162. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54163. }
  54164. }
  54165. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54166. /** @hidden */
  54167. export var lensHighlightsPixelShader: {
  54168. name: string;
  54169. shader: string;
  54170. };
  54171. }
  54172. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54173. /** @hidden */
  54174. export var depthOfFieldPixelShader: {
  54175. name: string;
  54176. shader: string;
  54177. };
  54178. }
  54179. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54180. import { Camera } from "babylonjs/Cameras/camera";
  54181. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54182. import { Scene } from "babylonjs/scene";
  54183. import "babylonjs/Shaders/chromaticAberration.fragment";
  54184. import "babylonjs/Shaders/lensHighlights.fragment";
  54185. import "babylonjs/Shaders/depthOfField.fragment";
  54186. /**
  54187. * BABYLON.JS Chromatic Aberration GLSL Shader
  54188. * Author: Olivier Guyot
  54189. * Separates very slightly R, G and B colors on the edges of the screen
  54190. * Inspired by Francois Tarlier & Martins Upitis
  54191. */
  54192. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54193. /**
  54194. * @ignore
  54195. * The chromatic aberration PostProcess id in the pipeline
  54196. */
  54197. LensChromaticAberrationEffect: string;
  54198. /**
  54199. * @ignore
  54200. * The highlights enhancing PostProcess id in the pipeline
  54201. */
  54202. HighlightsEnhancingEffect: string;
  54203. /**
  54204. * @ignore
  54205. * The depth-of-field PostProcess id in the pipeline
  54206. */
  54207. LensDepthOfFieldEffect: string;
  54208. private _scene;
  54209. private _depthTexture;
  54210. private _grainTexture;
  54211. private _chromaticAberrationPostProcess;
  54212. private _highlightsPostProcess;
  54213. private _depthOfFieldPostProcess;
  54214. private _edgeBlur;
  54215. private _grainAmount;
  54216. private _chromaticAberration;
  54217. private _distortion;
  54218. private _highlightsGain;
  54219. private _highlightsThreshold;
  54220. private _dofDistance;
  54221. private _dofAperture;
  54222. private _dofDarken;
  54223. private _dofPentagon;
  54224. private _blurNoise;
  54225. /**
  54226. * @constructor
  54227. *
  54228. * Effect parameters are as follow:
  54229. * {
  54230. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54231. * edge_blur: number; // from 0 to x (1 for realism)
  54232. * distortion: number; // from 0 to x (1 for realism)
  54233. * grain_amount: number; // from 0 to 1
  54234. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54235. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54236. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54237. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54238. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54239. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54240. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54241. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54242. * }
  54243. * Note: if an effect parameter is unset, effect is disabled
  54244. *
  54245. * @param name The rendering pipeline name
  54246. * @param parameters - An object containing all parameters (see above)
  54247. * @param scene The scene linked to this pipeline
  54248. * @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)
  54249. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54250. */
  54251. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54252. /**
  54253. * Sets the amount of blur at the edges
  54254. * @param amount blur amount
  54255. */
  54256. setEdgeBlur(amount: number): void;
  54257. /**
  54258. * Sets edge blur to 0
  54259. */
  54260. disableEdgeBlur(): void;
  54261. /**
  54262. * Sets the amout of grain
  54263. * @param amount Amount of grain
  54264. */
  54265. setGrainAmount(amount: number): void;
  54266. /**
  54267. * Set grain amount to 0
  54268. */
  54269. disableGrain(): void;
  54270. /**
  54271. * Sets the chromatic aberration amount
  54272. * @param amount amount of chromatic aberration
  54273. */
  54274. setChromaticAberration(amount: number): void;
  54275. /**
  54276. * Sets chromatic aberration amount to 0
  54277. */
  54278. disableChromaticAberration(): void;
  54279. /**
  54280. * Sets the EdgeDistortion amount
  54281. * @param amount amount of EdgeDistortion
  54282. */
  54283. setEdgeDistortion(amount: number): void;
  54284. /**
  54285. * Sets edge distortion to 0
  54286. */
  54287. disableEdgeDistortion(): void;
  54288. /**
  54289. * Sets the FocusDistance amount
  54290. * @param amount amount of FocusDistance
  54291. */
  54292. setFocusDistance(amount: number): void;
  54293. /**
  54294. * Disables depth of field
  54295. */
  54296. disableDepthOfField(): void;
  54297. /**
  54298. * Sets the Aperture amount
  54299. * @param amount amount of Aperture
  54300. */
  54301. setAperture(amount: number): void;
  54302. /**
  54303. * Sets the DarkenOutOfFocus amount
  54304. * @param amount amount of DarkenOutOfFocus
  54305. */
  54306. setDarkenOutOfFocus(amount: number): void;
  54307. /**
  54308. * Creates a pentagon bokeh effect
  54309. */
  54310. enablePentagonBokeh(): void;
  54311. /**
  54312. * Disables the pentagon bokeh effect
  54313. */
  54314. disablePentagonBokeh(): void;
  54315. /**
  54316. * Enables noise blur
  54317. */
  54318. enableNoiseBlur(): void;
  54319. /**
  54320. * Disables noise blur
  54321. */
  54322. disableNoiseBlur(): void;
  54323. /**
  54324. * Sets the HighlightsGain amount
  54325. * @param amount amount of HighlightsGain
  54326. */
  54327. setHighlightsGain(amount: number): void;
  54328. /**
  54329. * Sets the HighlightsThreshold amount
  54330. * @param amount amount of HighlightsThreshold
  54331. */
  54332. setHighlightsThreshold(amount: number): void;
  54333. /**
  54334. * Disables highlights
  54335. */
  54336. disableHighlights(): void;
  54337. /**
  54338. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54339. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54340. */
  54341. dispose(disableDepthRender?: boolean): void;
  54342. private _createChromaticAberrationPostProcess;
  54343. private _createHighlightsPostProcess;
  54344. private _createDepthOfFieldPostProcess;
  54345. private _createGrainTexture;
  54346. }
  54347. }
  54348. declare module "babylonjs/Shaders/ssao2.fragment" {
  54349. /** @hidden */
  54350. export var ssao2PixelShader: {
  54351. name: string;
  54352. shader: string;
  54353. };
  54354. }
  54355. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  54356. /** @hidden */
  54357. export var ssaoCombinePixelShader: {
  54358. name: string;
  54359. shader: string;
  54360. };
  54361. }
  54362. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  54363. import { Camera } from "babylonjs/Cameras/camera";
  54364. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54365. import { Scene } from "babylonjs/scene";
  54366. import "babylonjs/Shaders/ssao2.fragment";
  54367. import "babylonjs/Shaders/ssaoCombine.fragment";
  54368. /**
  54369. * Render pipeline to produce ssao effect
  54370. */
  54371. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54372. /**
  54373. * @ignore
  54374. * The PassPostProcess id in the pipeline that contains the original scene color
  54375. */
  54376. SSAOOriginalSceneColorEffect: string;
  54377. /**
  54378. * @ignore
  54379. * The SSAO PostProcess id in the pipeline
  54380. */
  54381. SSAORenderEffect: string;
  54382. /**
  54383. * @ignore
  54384. * The horizontal blur PostProcess id in the pipeline
  54385. */
  54386. SSAOBlurHRenderEffect: string;
  54387. /**
  54388. * @ignore
  54389. * The vertical blur PostProcess id in the pipeline
  54390. */
  54391. SSAOBlurVRenderEffect: string;
  54392. /**
  54393. * @ignore
  54394. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54395. */
  54396. SSAOCombineRenderEffect: string;
  54397. /**
  54398. * The output strength of the SSAO post-process. Default value is 1.0.
  54399. */
  54400. totalStrength: number;
  54401. /**
  54402. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54403. */
  54404. maxZ: number;
  54405. /**
  54406. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54407. */
  54408. minZAspect: number;
  54409. private _samples;
  54410. /**
  54411. * Number of samples used for the SSAO calculations. Default value is 8
  54412. */
  54413. samples: number;
  54414. private _textureSamples;
  54415. /**
  54416. * Number of samples to use for antialiasing
  54417. */
  54418. textureSamples: number;
  54419. /**
  54420. * Ratio object used for SSAO ratio and blur ratio
  54421. */
  54422. private _ratio;
  54423. /**
  54424. * Dynamically generated sphere sampler.
  54425. */
  54426. private _sampleSphere;
  54427. /**
  54428. * Blur filter offsets
  54429. */
  54430. private _samplerOffsets;
  54431. private _expensiveBlur;
  54432. /**
  54433. * If bilateral blur should be used
  54434. */
  54435. expensiveBlur: boolean;
  54436. /**
  54437. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54438. */
  54439. radius: number;
  54440. /**
  54441. * The base color of the SSAO post-process
  54442. * The final result is "base + ssao" between [0, 1]
  54443. */
  54444. base: number;
  54445. /**
  54446. * Support test.
  54447. */
  54448. static readonly IsSupported: boolean;
  54449. private _scene;
  54450. private _depthTexture;
  54451. private _normalTexture;
  54452. private _randomTexture;
  54453. private _originalColorPostProcess;
  54454. private _ssaoPostProcess;
  54455. private _blurHPostProcess;
  54456. private _blurVPostProcess;
  54457. private _ssaoCombinePostProcess;
  54458. private _firstUpdate;
  54459. /**
  54460. * Gets active scene
  54461. */
  54462. readonly scene: Scene;
  54463. /**
  54464. * @constructor
  54465. * @param name The rendering pipeline name
  54466. * @param scene The scene linked to this pipeline
  54467. * @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 }
  54468. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54469. */
  54470. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54471. /**
  54472. * Get the class name
  54473. * @returns "SSAO2RenderingPipeline"
  54474. */
  54475. getClassName(): string;
  54476. /**
  54477. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54478. */
  54479. dispose(disableGeometryBufferRenderer?: boolean): void;
  54480. private _createBlurPostProcess;
  54481. /** @hidden */
  54482. _rebuild(): void;
  54483. private _bits;
  54484. private _radicalInverse_VdC;
  54485. private _hammersley;
  54486. private _hemisphereSample_uniform;
  54487. private _generateHemisphere;
  54488. private _createSSAOPostProcess;
  54489. private _createSSAOCombinePostProcess;
  54490. private _createRandomTexture;
  54491. /**
  54492. * Serialize the rendering pipeline (Used when exporting)
  54493. * @returns the serialized object
  54494. */
  54495. serialize(): any;
  54496. /**
  54497. * Parse the serialized pipeline
  54498. * @param source Source pipeline.
  54499. * @param scene The scene to load the pipeline to.
  54500. * @param rootUrl The URL of the serialized pipeline.
  54501. * @returns An instantiated pipeline from the serialized object.
  54502. */
  54503. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54504. }
  54505. }
  54506. declare module "babylonjs/Shaders/ssao.fragment" {
  54507. /** @hidden */
  54508. export var ssaoPixelShader: {
  54509. name: string;
  54510. shader: string;
  54511. };
  54512. }
  54513. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  54514. import { Camera } from "babylonjs/Cameras/camera";
  54515. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54516. import { Scene } from "babylonjs/scene";
  54517. import "babylonjs/Shaders/ssao.fragment";
  54518. import "babylonjs/Shaders/ssaoCombine.fragment";
  54519. /**
  54520. * Render pipeline to produce ssao effect
  54521. */
  54522. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54523. /**
  54524. * @ignore
  54525. * The PassPostProcess id in the pipeline that contains the original scene color
  54526. */
  54527. SSAOOriginalSceneColorEffect: string;
  54528. /**
  54529. * @ignore
  54530. * The SSAO PostProcess id in the pipeline
  54531. */
  54532. SSAORenderEffect: string;
  54533. /**
  54534. * @ignore
  54535. * The horizontal blur PostProcess id in the pipeline
  54536. */
  54537. SSAOBlurHRenderEffect: string;
  54538. /**
  54539. * @ignore
  54540. * The vertical blur PostProcess id in the pipeline
  54541. */
  54542. SSAOBlurVRenderEffect: string;
  54543. /**
  54544. * @ignore
  54545. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54546. */
  54547. SSAOCombineRenderEffect: string;
  54548. /**
  54549. * The output strength of the SSAO post-process. Default value is 1.0.
  54550. */
  54551. totalStrength: number;
  54552. /**
  54553. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54554. */
  54555. radius: number;
  54556. /**
  54557. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54558. * Must not be equal to fallOff and superior to fallOff.
  54559. * Default value is 0.0075
  54560. */
  54561. area: number;
  54562. /**
  54563. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54564. * Must not be equal to area and inferior to area.
  54565. * Default value is 0.000001
  54566. */
  54567. fallOff: number;
  54568. /**
  54569. * The base color of the SSAO post-process
  54570. * The final result is "base + ssao" between [0, 1]
  54571. */
  54572. base: number;
  54573. private _scene;
  54574. private _depthTexture;
  54575. private _randomTexture;
  54576. private _originalColorPostProcess;
  54577. private _ssaoPostProcess;
  54578. private _blurHPostProcess;
  54579. private _blurVPostProcess;
  54580. private _ssaoCombinePostProcess;
  54581. private _firstUpdate;
  54582. /**
  54583. * Gets active scene
  54584. */
  54585. readonly scene: Scene;
  54586. /**
  54587. * @constructor
  54588. * @param name - The rendering pipeline name
  54589. * @param scene - The scene linked to this pipeline
  54590. * @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 }
  54591. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54592. */
  54593. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54594. /**
  54595. * Get the class name
  54596. * @returns "SSAORenderingPipeline"
  54597. */
  54598. getClassName(): string;
  54599. /**
  54600. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54601. */
  54602. dispose(disableDepthRender?: boolean): void;
  54603. private _createBlurPostProcess;
  54604. /** @hidden */
  54605. _rebuild(): void;
  54606. private _createSSAOPostProcess;
  54607. private _createSSAOCombinePostProcess;
  54608. private _createRandomTexture;
  54609. }
  54610. }
  54611. declare module "babylonjs/Shaders/standard.fragment" {
  54612. /** @hidden */
  54613. export var standardPixelShader: {
  54614. name: string;
  54615. shader: string;
  54616. };
  54617. }
  54618. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  54619. import { Nullable } from "babylonjs/types";
  54620. import { IAnimatable } from "babylonjs/Misc/tools";
  54621. import { Camera } from "babylonjs/Cameras/camera";
  54622. import { Texture } from "babylonjs/Materials/Textures/texture";
  54623. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54624. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54625. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54626. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54627. import { IDisposable } from "babylonjs/scene";
  54628. import { SpotLight } from "babylonjs/Lights/spotLight";
  54629. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  54630. import { Scene } from "babylonjs/scene";
  54631. import { Animation } from "babylonjs/Animations/animation";
  54632. import "babylonjs/Shaders/standard.fragment";
  54633. /**
  54634. * Standard rendering pipeline
  54635. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54636. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54637. */
  54638. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54639. /**
  54640. * Public members
  54641. */
  54642. /**
  54643. * Post-process which contains the original scene color before the pipeline applies all the effects
  54644. */
  54645. originalPostProcess: Nullable<PostProcess>;
  54646. /**
  54647. * Post-process used to down scale an image x4
  54648. */
  54649. downSampleX4PostProcess: Nullable<PostProcess>;
  54650. /**
  54651. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54652. */
  54653. brightPassPostProcess: Nullable<PostProcess>;
  54654. /**
  54655. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54656. */
  54657. blurHPostProcesses: PostProcess[];
  54658. /**
  54659. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54660. */
  54661. blurVPostProcesses: PostProcess[];
  54662. /**
  54663. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54664. */
  54665. textureAdderPostProcess: Nullable<PostProcess>;
  54666. /**
  54667. * Post-process used to create volumetric lighting effect
  54668. */
  54669. volumetricLightPostProcess: Nullable<PostProcess>;
  54670. /**
  54671. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54672. */
  54673. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54674. /**
  54675. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54676. */
  54677. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54678. /**
  54679. * Post-process used to merge the volumetric light effect and the real scene color
  54680. */
  54681. volumetricLightMergePostProces: Nullable<PostProcess>;
  54682. /**
  54683. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54684. */
  54685. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54686. /**
  54687. * Base post-process used to calculate the average luminance of the final image for HDR
  54688. */
  54689. luminancePostProcess: Nullable<PostProcess>;
  54690. /**
  54691. * Post-processes used to create down sample post-processes in order to get
  54692. * the average luminance of the final image for HDR
  54693. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54694. */
  54695. luminanceDownSamplePostProcesses: PostProcess[];
  54696. /**
  54697. * Post-process used to create a HDR effect (light adaptation)
  54698. */
  54699. hdrPostProcess: Nullable<PostProcess>;
  54700. /**
  54701. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54702. */
  54703. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54704. /**
  54705. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54706. */
  54707. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54708. /**
  54709. * Post-process used to merge the final HDR post-process and the real scene color
  54710. */
  54711. hdrFinalPostProcess: Nullable<PostProcess>;
  54712. /**
  54713. * Post-process used to create a lens flare effect
  54714. */
  54715. lensFlarePostProcess: Nullable<PostProcess>;
  54716. /**
  54717. * Post-process that merges the result of the lens flare post-process and the real scene color
  54718. */
  54719. lensFlareComposePostProcess: Nullable<PostProcess>;
  54720. /**
  54721. * Post-process used to create a motion blur effect
  54722. */
  54723. motionBlurPostProcess: Nullable<PostProcess>;
  54724. /**
  54725. * Post-process used to create a depth of field effect
  54726. */
  54727. depthOfFieldPostProcess: Nullable<PostProcess>;
  54728. /**
  54729. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54730. */
  54731. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54732. /**
  54733. * Represents the brightness threshold in order to configure the illuminated surfaces
  54734. */
  54735. brightThreshold: number;
  54736. /**
  54737. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54738. */
  54739. blurWidth: number;
  54740. /**
  54741. * Sets if the blur for highlighted surfaces must be only horizontal
  54742. */
  54743. horizontalBlur: boolean;
  54744. /**
  54745. * Sets the overall exposure used by the pipeline
  54746. */
  54747. exposure: number;
  54748. /**
  54749. * Texture used typically to simulate "dirty" on camera lens
  54750. */
  54751. lensTexture: Nullable<Texture>;
  54752. /**
  54753. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54754. */
  54755. volumetricLightCoefficient: number;
  54756. /**
  54757. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54758. */
  54759. volumetricLightPower: number;
  54760. /**
  54761. * Used the set the blur intensity to smooth the volumetric lights
  54762. */
  54763. volumetricLightBlurScale: number;
  54764. /**
  54765. * Light (spot or directional) used to generate the volumetric lights rays
  54766. * The source light must have a shadow generate so the pipeline can get its
  54767. * depth map
  54768. */
  54769. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54770. /**
  54771. * For eye adaptation, represents the minimum luminance the eye can see
  54772. */
  54773. hdrMinimumLuminance: number;
  54774. /**
  54775. * For eye adaptation, represents the decrease luminance speed
  54776. */
  54777. hdrDecreaseRate: number;
  54778. /**
  54779. * For eye adaptation, represents the increase luminance speed
  54780. */
  54781. hdrIncreaseRate: number;
  54782. /**
  54783. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54784. */
  54785. lensColorTexture: Nullable<Texture>;
  54786. /**
  54787. * The overall strengh for the lens flare effect
  54788. */
  54789. lensFlareStrength: number;
  54790. /**
  54791. * Dispersion coefficient for lens flare ghosts
  54792. */
  54793. lensFlareGhostDispersal: number;
  54794. /**
  54795. * Main lens flare halo width
  54796. */
  54797. lensFlareHaloWidth: number;
  54798. /**
  54799. * Based on the lens distortion effect, defines how much the lens flare result
  54800. * is distorted
  54801. */
  54802. lensFlareDistortionStrength: number;
  54803. /**
  54804. * Lens star texture must be used to simulate rays on the flares and is available
  54805. * in the documentation
  54806. */
  54807. lensStarTexture: Nullable<Texture>;
  54808. /**
  54809. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54810. * flare effect by taking account of the dirt texture
  54811. */
  54812. lensFlareDirtTexture: Nullable<Texture>;
  54813. /**
  54814. * Represents the focal length for the depth of field effect
  54815. */
  54816. depthOfFieldDistance: number;
  54817. /**
  54818. * Represents the blur intensity for the blurred part of the depth of field effect
  54819. */
  54820. depthOfFieldBlurWidth: number;
  54821. /**
  54822. * For motion blur, defines how much the image is blurred by the movement
  54823. */
  54824. motionStrength: number;
  54825. /**
  54826. * List of animations for the pipeline (IAnimatable implementation)
  54827. */
  54828. animations: Animation[];
  54829. /**
  54830. * Private members
  54831. */
  54832. private _scene;
  54833. private _currentDepthOfFieldSource;
  54834. private _basePostProcess;
  54835. private _hdrCurrentLuminance;
  54836. private _floatTextureType;
  54837. private _ratio;
  54838. private _bloomEnabled;
  54839. private _depthOfFieldEnabled;
  54840. private _vlsEnabled;
  54841. private _lensFlareEnabled;
  54842. private _hdrEnabled;
  54843. private _motionBlurEnabled;
  54844. private _fxaaEnabled;
  54845. private _motionBlurSamples;
  54846. private _volumetricLightStepsCount;
  54847. private _samples;
  54848. /**
  54849. * @ignore
  54850. * Specifies if the bloom pipeline is enabled
  54851. */
  54852. BloomEnabled: boolean;
  54853. /**
  54854. * @ignore
  54855. * Specifies if the depth of field pipeline is enabed
  54856. */
  54857. DepthOfFieldEnabled: boolean;
  54858. /**
  54859. * @ignore
  54860. * Specifies if the lens flare pipeline is enabed
  54861. */
  54862. LensFlareEnabled: boolean;
  54863. /**
  54864. * @ignore
  54865. * Specifies if the HDR pipeline is enabled
  54866. */
  54867. HDREnabled: boolean;
  54868. /**
  54869. * @ignore
  54870. * Specifies if the volumetric lights scattering effect is enabled
  54871. */
  54872. VLSEnabled: boolean;
  54873. /**
  54874. * @ignore
  54875. * Specifies if the motion blur effect is enabled
  54876. */
  54877. MotionBlurEnabled: boolean;
  54878. /**
  54879. * Specifies if anti-aliasing is enabled
  54880. */
  54881. fxaaEnabled: boolean;
  54882. /**
  54883. * Specifies the number of steps used to calculate the volumetric lights
  54884. * Typically in interval [50, 200]
  54885. */
  54886. volumetricLightStepsCount: number;
  54887. /**
  54888. * Specifies the number of samples used for the motion blur effect
  54889. * Typically in interval [16, 64]
  54890. */
  54891. motionBlurSamples: number;
  54892. /**
  54893. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54894. */
  54895. samples: number;
  54896. /**
  54897. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54898. * @constructor
  54899. * @param name The rendering pipeline name
  54900. * @param scene The scene linked to this pipeline
  54901. * @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)
  54902. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54903. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54904. */
  54905. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54906. private _buildPipeline;
  54907. private _createDownSampleX4PostProcess;
  54908. private _createBrightPassPostProcess;
  54909. private _createBlurPostProcesses;
  54910. private _createTextureAdderPostProcess;
  54911. private _createVolumetricLightPostProcess;
  54912. private _createLuminancePostProcesses;
  54913. private _createHdrPostProcess;
  54914. private _createLensFlarePostProcess;
  54915. private _createDepthOfFieldPostProcess;
  54916. private _createMotionBlurPostProcess;
  54917. private _getDepthTexture;
  54918. private _disposePostProcesses;
  54919. /**
  54920. * Dispose of the pipeline and stop all post processes
  54921. */
  54922. dispose(): void;
  54923. /**
  54924. * Serialize the rendering pipeline (Used when exporting)
  54925. * @returns the serialized object
  54926. */
  54927. serialize(): any;
  54928. /**
  54929. * Parse the serialized pipeline
  54930. * @param source Source pipeline.
  54931. * @param scene The scene to load the pipeline to.
  54932. * @param rootUrl The URL of the serialized pipeline.
  54933. * @returns An instantiated pipeline from the serialized object.
  54934. */
  54935. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54936. /**
  54937. * Luminance steps
  54938. */
  54939. static LuminanceSteps: number;
  54940. }
  54941. }
  54942. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  54943. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  54944. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  54945. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  54946. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  54947. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  54948. }
  54949. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  54950. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  54951. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54952. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54953. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54954. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54955. }
  54956. declare module "babylonjs/Shaders/tonemap.fragment" {
  54957. /** @hidden */
  54958. export var tonemapPixelShader: {
  54959. name: string;
  54960. shader: string;
  54961. };
  54962. }
  54963. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  54964. import { Camera } from "babylonjs/Cameras/camera";
  54965. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54966. import "babylonjs/Shaders/tonemap.fragment";
  54967. import { Engine } from "babylonjs/Engines/engine";
  54968. /** Defines operator used for tonemapping */
  54969. export enum TonemappingOperator {
  54970. /** Hable */
  54971. Hable = 0,
  54972. /** Reinhard */
  54973. Reinhard = 1,
  54974. /** HejiDawson */
  54975. HejiDawson = 2,
  54976. /** Photographic */
  54977. Photographic = 3
  54978. }
  54979. /**
  54980. * Defines a post process to apply tone mapping
  54981. */
  54982. export class TonemapPostProcess extends PostProcess {
  54983. private _operator;
  54984. /** Defines the required exposure adjustement */
  54985. exposureAdjustment: number;
  54986. /**
  54987. * Creates a new TonemapPostProcess
  54988. * @param name defines the name of the postprocess
  54989. * @param _operator defines the operator to use
  54990. * @param exposureAdjustment defines the required exposure adjustement
  54991. * @param camera defines the camera to use (can be null)
  54992. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54993. * @param engine defines the hosting engine (can be ignore if camera is set)
  54994. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54995. */
  54996. constructor(name: string, _operator: TonemappingOperator,
  54997. /** Defines the required exposure adjustement */
  54998. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54999. }
  55000. }
  55001. declare module "babylonjs/Shaders/depth.vertex" {
  55002. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55003. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55004. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55005. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55006. /** @hidden */
  55007. export var depthVertexShader: {
  55008. name: string;
  55009. shader: string;
  55010. };
  55011. }
  55012. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55013. /** @hidden */
  55014. export var volumetricLightScatteringPixelShader: {
  55015. name: string;
  55016. shader: string;
  55017. };
  55018. }
  55019. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55020. /** @hidden */
  55021. export var volumetricLightScatteringPassPixelShader: {
  55022. name: string;
  55023. shader: string;
  55024. };
  55025. }
  55026. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55027. import { Vector3 } from "babylonjs/Maths/math";
  55028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55029. import { Mesh } from "babylonjs/Meshes/mesh";
  55030. import { Camera } from "babylonjs/Cameras/camera";
  55031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55032. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55033. import { Scene } from "babylonjs/scene";
  55034. import "babylonjs/Meshes/Builders/planeBuilder";
  55035. import "babylonjs/Shaders/depth.vertex";
  55036. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55037. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55038. import { Engine } from "babylonjs/Engines/engine";
  55039. /**
  55040. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55041. */
  55042. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55043. private _volumetricLightScatteringPass;
  55044. private _volumetricLightScatteringRTT;
  55045. private _viewPort;
  55046. private _screenCoordinates;
  55047. private _cachedDefines;
  55048. /**
  55049. * If not undefined, the mesh position is computed from the attached node position
  55050. */
  55051. attachedNode: {
  55052. position: Vector3;
  55053. };
  55054. /**
  55055. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55056. */
  55057. customMeshPosition: Vector3;
  55058. /**
  55059. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55060. */
  55061. useCustomMeshPosition: boolean;
  55062. /**
  55063. * If the post-process should inverse the light scattering direction
  55064. */
  55065. invert: boolean;
  55066. /**
  55067. * The internal mesh used by the post-process
  55068. */
  55069. mesh: Mesh;
  55070. /**
  55071. * @hidden
  55072. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55073. */
  55074. useDiffuseColor: boolean;
  55075. /**
  55076. * Array containing the excluded meshes not rendered in the internal pass
  55077. */
  55078. excludedMeshes: AbstractMesh[];
  55079. /**
  55080. * Controls the overall intensity of the post-process
  55081. */
  55082. exposure: number;
  55083. /**
  55084. * Dissipates each sample's contribution in range [0, 1]
  55085. */
  55086. decay: number;
  55087. /**
  55088. * Controls the overall intensity of each sample
  55089. */
  55090. weight: number;
  55091. /**
  55092. * Controls the density of each sample
  55093. */
  55094. density: number;
  55095. /**
  55096. * @constructor
  55097. * @param name The post-process name
  55098. * @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)
  55099. * @param camera The camera that the post-process will be attached to
  55100. * @param mesh The mesh used to create the light scattering
  55101. * @param samples The post-process quality, default 100
  55102. * @param samplingModeThe post-process filtering mode
  55103. * @param engine The babylon engine
  55104. * @param reusable If the post-process is reusable
  55105. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55106. */
  55107. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55108. /**
  55109. * Returns the string "VolumetricLightScatteringPostProcess"
  55110. * @returns "VolumetricLightScatteringPostProcess"
  55111. */
  55112. getClassName(): string;
  55113. private _isReady;
  55114. /**
  55115. * Sets the new light position for light scattering effect
  55116. * @param position The new custom light position
  55117. */
  55118. setCustomMeshPosition(position: Vector3): void;
  55119. /**
  55120. * Returns the light position for light scattering effect
  55121. * @return Vector3 The custom light position
  55122. */
  55123. getCustomMeshPosition(): Vector3;
  55124. /**
  55125. * Disposes the internal assets and detaches the post-process from the camera
  55126. */
  55127. dispose(camera: Camera): void;
  55128. /**
  55129. * Returns the render target texture used by the post-process
  55130. * @return the render target texture used by the post-process
  55131. */
  55132. getPass(): RenderTargetTexture;
  55133. private _meshExcluded;
  55134. private _createPass;
  55135. private _updateMeshScreenCoordinates;
  55136. /**
  55137. * Creates a default mesh for the Volumeric Light Scattering post-process
  55138. * @param name The mesh name
  55139. * @param scene The scene where to create the mesh
  55140. * @return the default mesh
  55141. */
  55142. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55143. }
  55144. }
  55145. declare module "babylonjs/PostProcesses/index" {
  55146. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55147. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55148. export * from "babylonjs/PostProcesses/bloomEffect";
  55149. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55150. export * from "babylonjs/PostProcesses/blurPostProcess";
  55151. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55152. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55153. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55154. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55155. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55156. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55157. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55158. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55159. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55160. export * from "babylonjs/PostProcesses/filterPostProcess";
  55161. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55162. export * from "babylonjs/PostProcesses/grainPostProcess";
  55163. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55164. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55165. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55166. export * from "babylonjs/PostProcesses/passPostProcess";
  55167. export * from "babylonjs/PostProcesses/postProcess";
  55168. export * from "babylonjs/PostProcesses/postProcessManager";
  55169. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55170. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55171. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55172. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55173. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55174. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55175. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55176. }
  55177. declare module "babylonjs/Probes/index" {
  55178. export * from "babylonjs/Probes/reflectionProbe";
  55179. }
  55180. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55181. import { Scene } from "babylonjs/scene";
  55182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55183. import { Color3 } from "babylonjs/Maths/math";
  55184. import { SmartArray } from "babylonjs/Misc/smartArray";
  55185. import { ISceneComponent } from "babylonjs/sceneComponent";
  55186. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55187. import "babylonjs/Meshes/Builders/boxBuilder";
  55188. import "babylonjs/Shaders/color.fragment";
  55189. import "babylonjs/Shaders/color.vertex";
  55190. module "babylonjs/scene" {
  55191. interface Scene {
  55192. /** @hidden (Backing field) */
  55193. _boundingBoxRenderer: BoundingBoxRenderer;
  55194. /** @hidden (Backing field) */
  55195. _forceShowBoundingBoxes: boolean;
  55196. /**
  55197. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55198. */
  55199. forceShowBoundingBoxes: boolean;
  55200. /**
  55201. * Gets the bounding box renderer associated with the scene
  55202. * @returns a BoundingBoxRenderer
  55203. */
  55204. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55205. }
  55206. }
  55207. module "babylonjs/Meshes/abstractMesh" {
  55208. interface AbstractMesh {
  55209. /** @hidden (Backing field) */
  55210. _showBoundingBox: boolean;
  55211. /**
  55212. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55213. */
  55214. showBoundingBox: boolean;
  55215. }
  55216. }
  55217. /**
  55218. * Component responsible of rendering the bounding box of the meshes in a scene.
  55219. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55220. */
  55221. export class BoundingBoxRenderer implements ISceneComponent {
  55222. /**
  55223. * The component name helpfull to identify the component in the list of scene components.
  55224. */
  55225. readonly name: string;
  55226. /**
  55227. * The scene the component belongs to.
  55228. */
  55229. scene: Scene;
  55230. /**
  55231. * Color of the bounding box lines placed in front of an object
  55232. */
  55233. frontColor: Color3;
  55234. /**
  55235. * Color of the bounding box lines placed behind an object
  55236. */
  55237. backColor: Color3;
  55238. /**
  55239. * Defines if the renderer should show the back lines or not
  55240. */
  55241. showBackLines: boolean;
  55242. /**
  55243. * @hidden
  55244. */
  55245. renderList: SmartArray<BoundingBox>;
  55246. private _colorShader;
  55247. private _vertexBuffers;
  55248. private _indexBuffer;
  55249. /**
  55250. * Instantiates a new bounding box renderer in a scene.
  55251. * @param scene the scene the renderer renders in
  55252. */
  55253. constructor(scene: Scene);
  55254. /**
  55255. * Registers the component in a given scene
  55256. */
  55257. register(): void;
  55258. private _evaluateSubMesh;
  55259. private _activeMesh;
  55260. private _prepareRessources;
  55261. private _createIndexBuffer;
  55262. /**
  55263. * Rebuilds the elements related to this component in case of
  55264. * context lost for instance.
  55265. */
  55266. rebuild(): void;
  55267. /**
  55268. * @hidden
  55269. */
  55270. reset(): void;
  55271. /**
  55272. * Render the bounding boxes of a specific rendering group
  55273. * @param renderingGroupId defines the rendering group to render
  55274. */
  55275. render(renderingGroupId: number): void;
  55276. /**
  55277. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55278. * @param mesh Define the mesh to render the occlusion bounding box for
  55279. */
  55280. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55281. /**
  55282. * Dispose and release the resources attached to this renderer.
  55283. */
  55284. dispose(): void;
  55285. }
  55286. }
  55287. declare module "babylonjs/Shaders/depth.fragment" {
  55288. /** @hidden */
  55289. export var depthPixelShader: {
  55290. name: string;
  55291. shader: string;
  55292. };
  55293. }
  55294. declare module "babylonjs/Rendering/depthRenderer" {
  55295. import { Nullable } from "babylonjs/types";
  55296. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55297. import { Scene } from "babylonjs/scene";
  55298. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55299. import { Camera } from "babylonjs/Cameras/camera";
  55300. import "babylonjs/Shaders/depth.fragment";
  55301. import "babylonjs/Shaders/depth.vertex";
  55302. /**
  55303. * This represents a depth renderer in Babylon.
  55304. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55305. */
  55306. export class DepthRenderer {
  55307. private _scene;
  55308. private _depthMap;
  55309. private _effect;
  55310. private _cachedDefines;
  55311. private _camera;
  55312. /**
  55313. * Specifiess that the depth renderer will only be used within
  55314. * the camera it is created for.
  55315. * This can help forcing its rendering during the camera processing.
  55316. */
  55317. useOnlyInActiveCamera: boolean;
  55318. /** @hidden */
  55319. static _SceneComponentInitialization: (scene: Scene) => void;
  55320. /**
  55321. * Instantiates a depth renderer
  55322. * @param scene The scene the renderer belongs to
  55323. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55324. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55325. */
  55326. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55327. /**
  55328. * Creates the depth rendering effect and checks if the effect is ready.
  55329. * @param subMesh The submesh to be used to render the depth map of
  55330. * @param useInstances If multiple world instances should be used
  55331. * @returns if the depth renderer is ready to render the depth map
  55332. */
  55333. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55334. /**
  55335. * Gets the texture which the depth map will be written to.
  55336. * @returns The depth map texture
  55337. */
  55338. getDepthMap(): RenderTargetTexture;
  55339. /**
  55340. * Disposes of the depth renderer.
  55341. */
  55342. dispose(): void;
  55343. }
  55344. }
  55345. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  55346. import { Nullable } from "babylonjs/types";
  55347. import { Scene } from "babylonjs/scene";
  55348. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  55349. import { Camera } from "babylonjs/Cameras/camera";
  55350. import { ISceneComponent } from "babylonjs/sceneComponent";
  55351. module "babylonjs/scene" {
  55352. interface Scene {
  55353. /** @hidden (Backing field) */
  55354. _depthRenderer: {
  55355. [id: string]: DepthRenderer;
  55356. };
  55357. /**
  55358. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55359. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55360. * @returns the created depth renderer
  55361. */
  55362. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55363. /**
  55364. * Disables a depth renderer for a given camera
  55365. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55366. */
  55367. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55368. }
  55369. }
  55370. /**
  55371. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55372. * in several rendering techniques.
  55373. */
  55374. export class DepthRendererSceneComponent implements ISceneComponent {
  55375. /**
  55376. * The component name helpfull to identify the component in the list of scene components.
  55377. */
  55378. readonly name: string;
  55379. /**
  55380. * The scene the component belongs to.
  55381. */
  55382. scene: Scene;
  55383. /**
  55384. * Creates a new instance of the component for the given scene
  55385. * @param scene Defines the scene to register the component in
  55386. */
  55387. constructor(scene: Scene);
  55388. /**
  55389. * Registers the component in a given scene
  55390. */
  55391. register(): void;
  55392. /**
  55393. * Rebuilds the elements related to this component in case of
  55394. * context lost for instance.
  55395. */
  55396. rebuild(): void;
  55397. /**
  55398. * Disposes the component and the associated ressources
  55399. */
  55400. dispose(): void;
  55401. private _gatherRenderTargets;
  55402. private _gatherActiveCameraRenderTargets;
  55403. }
  55404. }
  55405. declare module "babylonjs/Shaders/outline.fragment" {
  55406. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55407. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  55408. /** @hidden */
  55409. export var outlinePixelShader: {
  55410. name: string;
  55411. shader: string;
  55412. };
  55413. }
  55414. declare module "babylonjs/Shaders/outline.vertex" {
  55415. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55416. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55417. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  55418. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55419. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55420. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  55421. /** @hidden */
  55422. export var outlineVertexShader: {
  55423. name: string;
  55424. shader: string;
  55425. };
  55426. }
  55427. declare module "babylonjs/Rendering/outlineRenderer" {
  55428. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55429. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  55430. import { Scene } from "babylonjs/scene";
  55431. import { ISceneComponent } from "babylonjs/sceneComponent";
  55432. import "babylonjs/Shaders/outline.fragment";
  55433. import "babylonjs/Shaders/outline.vertex";
  55434. module "babylonjs/scene" {
  55435. interface Scene {
  55436. /** @hidden */
  55437. _outlineRenderer: OutlineRenderer;
  55438. /**
  55439. * Gets the outline renderer associated with the scene
  55440. * @returns a OutlineRenderer
  55441. */
  55442. getOutlineRenderer(): OutlineRenderer;
  55443. }
  55444. }
  55445. module "babylonjs/Meshes/abstractMesh" {
  55446. interface AbstractMesh {
  55447. /** @hidden (Backing field) */
  55448. _renderOutline: boolean;
  55449. /**
  55450. * Gets or sets a boolean indicating if the outline must be rendered as well
  55451. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55452. */
  55453. renderOutline: boolean;
  55454. /** @hidden (Backing field) */
  55455. _renderOverlay: boolean;
  55456. /**
  55457. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55458. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55459. */
  55460. renderOverlay: boolean;
  55461. }
  55462. }
  55463. /**
  55464. * This class is responsible to draw bothe outline/overlay of meshes.
  55465. * It should not be used directly but through the available method on mesh.
  55466. */
  55467. export class OutlineRenderer implements ISceneComponent {
  55468. /**
  55469. * The name of the component. Each component must have a unique name.
  55470. */
  55471. name: string;
  55472. /**
  55473. * The scene the component belongs to.
  55474. */
  55475. scene: Scene;
  55476. /**
  55477. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55478. */
  55479. zOffset: number;
  55480. private _engine;
  55481. private _effect;
  55482. private _cachedDefines;
  55483. private _savedDepthWrite;
  55484. /**
  55485. * Instantiates a new outline renderer. (There could be only one per scene).
  55486. * @param scene Defines the scene it belongs to
  55487. */
  55488. constructor(scene: Scene);
  55489. /**
  55490. * Register the component to one instance of a scene.
  55491. */
  55492. register(): void;
  55493. /**
  55494. * Rebuilds the elements related to this component in case of
  55495. * context lost for instance.
  55496. */
  55497. rebuild(): void;
  55498. /**
  55499. * Disposes the component and the associated ressources.
  55500. */
  55501. dispose(): void;
  55502. /**
  55503. * Renders the outline in the canvas.
  55504. * @param subMesh Defines the sumesh to render
  55505. * @param batch Defines the batch of meshes in case of instances
  55506. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55507. */
  55508. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55509. /**
  55510. * Returns whether or not the outline renderer is ready for a given submesh.
  55511. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55512. * @param subMesh Defines the submesh to check readyness for
  55513. * @param useInstances Defines wheter wee are trying to render instances or not
  55514. * @returns true if ready otherwise false
  55515. */
  55516. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55517. private _beforeRenderingMesh;
  55518. private _afterRenderingMesh;
  55519. }
  55520. }
  55521. declare module "babylonjs/Rendering/index" {
  55522. export * from "babylonjs/Rendering/boundingBoxRenderer";
  55523. export * from "babylonjs/Rendering/depthRenderer";
  55524. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  55525. export * from "babylonjs/Rendering/edgesRenderer";
  55526. export * from "babylonjs/Rendering/geometryBufferRenderer";
  55527. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55528. export * from "babylonjs/Rendering/outlineRenderer";
  55529. export * from "babylonjs/Rendering/renderingGroup";
  55530. export * from "babylonjs/Rendering/renderingManager";
  55531. export * from "babylonjs/Rendering/utilityLayerRenderer";
  55532. }
  55533. declare module "babylonjs/Sprites/index" {
  55534. export * from "babylonjs/Sprites/sprite";
  55535. export * from "babylonjs/Sprites/spriteManager";
  55536. export * from "babylonjs/Sprites/spriteSceneComponent";
  55537. }
  55538. declare module "babylonjs/Misc/assetsManager" {
  55539. import { Scene } from "babylonjs/scene";
  55540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55541. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55542. import { Skeleton } from "babylonjs/Bones/skeleton";
  55543. import { Observable } from "babylonjs/Misc/observable";
  55544. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55545. import { Texture } from "babylonjs/Materials/Textures/texture";
  55546. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55547. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  55548. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  55549. /**
  55550. * Defines the list of states available for a task inside a AssetsManager
  55551. */
  55552. export enum AssetTaskState {
  55553. /**
  55554. * Initialization
  55555. */
  55556. INIT = 0,
  55557. /**
  55558. * Running
  55559. */
  55560. RUNNING = 1,
  55561. /**
  55562. * Done
  55563. */
  55564. DONE = 2,
  55565. /**
  55566. * Error
  55567. */
  55568. ERROR = 3
  55569. }
  55570. /**
  55571. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55572. */
  55573. export abstract class AbstractAssetTask {
  55574. /**
  55575. * Task name
  55576. */ name: string;
  55577. /**
  55578. * Callback called when the task is successful
  55579. */
  55580. onSuccess: (task: any) => void;
  55581. /**
  55582. * Callback called when the task is not successful
  55583. */
  55584. onError: (task: any, message?: string, exception?: any) => void;
  55585. /**
  55586. * Creates a new AssetsManager
  55587. * @param name defines the name of the task
  55588. */
  55589. constructor(
  55590. /**
  55591. * Task name
  55592. */ name: string);
  55593. private _isCompleted;
  55594. private _taskState;
  55595. private _errorObject;
  55596. /**
  55597. * Get if the task is completed
  55598. */
  55599. readonly isCompleted: boolean;
  55600. /**
  55601. * Gets the current state of the task
  55602. */
  55603. readonly taskState: AssetTaskState;
  55604. /**
  55605. * Gets the current error object (if task is in error)
  55606. */
  55607. readonly errorObject: {
  55608. message?: string;
  55609. exception?: any;
  55610. };
  55611. /**
  55612. * Internal only
  55613. * @hidden
  55614. */
  55615. _setErrorObject(message?: string, exception?: any): void;
  55616. /**
  55617. * Execute the current task
  55618. * @param scene defines the scene where you want your assets to be loaded
  55619. * @param onSuccess is a callback called when the task is successfully executed
  55620. * @param onError is a callback called if an error occurs
  55621. */
  55622. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55623. /**
  55624. * Execute the current task
  55625. * @param scene defines the scene where you want your assets to be loaded
  55626. * @param onSuccess is a callback called when the task is successfully executed
  55627. * @param onError is a callback called if an error occurs
  55628. */
  55629. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55630. /**
  55631. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55632. * This can be used with failed tasks that have the reason for failure fixed.
  55633. */
  55634. reset(): void;
  55635. private onErrorCallback;
  55636. private onDoneCallback;
  55637. }
  55638. /**
  55639. * Define the interface used by progress events raised during assets loading
  55640. */
  55641. export interface IAssetsProgressEvent {
  55642. /**
  55643. * Defines the number of remaining tasks to process
  55644. */
  55645. remainingCount: number;
  55646. /**
  55647. * Defines the total number of tasks
  55648. */
  55649. totalCount: number;
  55650. /**
  55651. * Defines the task that was just processed
  55652. */
  55653. task: AbstractAssetTask;
  55654. }
  55655. /**
  55656. * Class used to share progress information about assets loading
  55657. */
  55658. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55659. /**
  55660. * Defines the number of remaining tasks to process
  55661. */
  55662. remainingCount: number;
  55663. /**
  55664. * Defines the total number of tasks
  55665. */
  55666. totalCount: number;
  55667. /**
  55668. * Defines the task that was just processed
  55669. */
  55670. task: AbstractAssetTask;
  55671. /**
  55672. * Creates a AssetsProgressEvent
  55673. * @param remainingCount defines the number of remaining tasks to process
  55674. * @param totalCount defines the total number of tasks
  55675. * @param task defines the task that was just processed
  55676. */
  55677. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55678. }
  55679. /**
  55680. * Define a task used by AssetsManager to load meshes
  55681. */
  55682. export class MeshAssetTask extends AbstractAssetTask {
  55683. /**
  55684. * Defines the name of the task
  55685. */
  55686. name: string;
  55687. /**
  55688. * Defines the list of mesh's names you want to load
  55689. */
  55690. meshesNames: any;
  55691. /**
  55692. * Defines the root url to use as a base to load your meshes and associated resources
  55693. */
  55694. rootUrl: string;
  55695. /**
  55696. * Defines the filename of the scene to load from
  55697. */
  55698. sceneFilename: string;
  55699. /**
  55700. * Gets the list of loaded meshes
  55701. */
  55702. loadedMeshes: Array<AbstractMesh>;
  55703. /**
  55704. * Gets the list of loaded particle systems
  55705. */
  55706. loadedParticleSystems: Array<IParticleSystem>;
  55707. /**
  55708. * Gets the list of loaded skeletons
  55709. */
  55710. loadedSkeletons: Array<Skeleton>;
  55711. /**
  55712. * Gets the list of loaded animation groups
  55713. */
  55714. loadedAnimationGroups: Array<AnimationGroup>;
  55715. /**
  55716. * Callback called when the task is successful
  55717. */
  55718. onSuccess: (task: MeshAssetTask) => void;
  55719. /**
  55720. * Callback called when the task is successful
  55721. */
  55722. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55723. /**
  55724. * Creates a new MeshAssetTask
  55725. * @param name defines the name of the task
  55726. * @param meshesNames defines the list of mesh's names you want to load
  55727. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55728. * @param sceneFilename defines the filename of the scene to load from
  55729. */
  55730. constructor(
  55731. /**
  55732. * Defines the name of the task
  55733. */
  55734. name: string,
  55735. /**
  55736. * Defines the list of mesh's names you want to load
  55737. */
  55738. meshesNames: any,
  55739. /**
  55740. * Defines the root url to use as a base to load your meshes and associated resources
  55741. */
  55742. rootUrl: string,
  55743. /**
  55744. * Defines the filename of the scene to load from
  55745. */
  55746. sceneFilename: string);
  55747. /**
  55748. * Execute the current task
  55749. * @param scene defines the scene where you want your assets to be loaded
  55750. * @param onSuccess is a callback called when the task is successfully executed
  55751. * @param onError is a callback called if an error occurs
  55752. */
  55753. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55754. }
  55755. /**
  55756. * Define a task used by AssetsManager to load text content
  55757. */
  55758. export class TextFileAssetTask extends AbstractAssetTask {
  55759. /**
  55760. * Defines the name of the task
  55761. */
  55762. name: string;
  55763. /**
  55764. * Defines the location of the file to load
  55765. */
  55766. url: string;
  55767. /**
  55768. * Gets the loaded text string
  55769. */
  55770. text: string;
  55771. /**
  55772. * Callback called when the task is successful
  55773. */
  55774. onSuccess: (task: TextFileAssetTask) => void;
  55775. /**
  55776. * Callback called when the task is successful
  55777. */
  55778. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55779. /**
  55780. * Creates a new TextFileAssetTask object
  55781. * @param name defines the name of the task
  55782. * @param url defines the location of the file to load
  55783. */
  55784. constructor(
  55785. /**
  55786. * Defines the name of the task
  55787. */
  55788. name: string,
  55789. /**
  55790. * Defines the location of the file to load
  55791. */
  55792. url: string);
  55793. /**
  55794. * Execute the current task
  55795. * @param scene defines the scene where you want your assets to be loaded
  55796. * @param onSuccess is a callback called when the task is successfully executed
  55797. * @param onError is a callback called if an error occurs
  55798. */
  55799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55800. }
  55801. /**
  55802. * Define a task used by AssetsManager to load binary data
  55803. */
  55804. export class BinaryFileAssetTask extends AbstractAssetTask {
  55805. /**
  55806. * Defines the name of the task
  55807. */
  55808. name: string;
  55809. /**
  55810. * Defines the location of the file to load
  55811. */
  55812. url: string;
  55813. /**
  55814. * Gets the lodaded data (as an array buffer)
  55815. */
  55816. data: ArrayBuffer;
  55817. /**
  55818. * Callback called when the task is successful
  55819. */
  55820. onSuccess: (task: BinaryFileAssetTask) => void;
  55821. /**
  55822. * Callback called when the task is successful
  55823. */
  55824. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55825. /**
  55826. * Creates a new BinaryFileAssetTask object
  55827. * @param name defines the name of the new task
  55828. * @param url defines the location of the file to load
  55829. */
  55830. constructor(
  55831. /**
  55832. * Defines the name of the task
  55833. */
  55834. name: string,
  55835. /**
  55836. * Defines the location of the file to load
  55837. */
  55838. url: string);
  55839. /**
  55840. * Execute the current task
  55841. * @param scene defines the scene where you want your assets to be loaded
  55842. * @param onSuccess is a callback called when the task is successfully executed
  55843. * @param onError is a callback called if an error occurs
  55844. */
  55845. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55846. }
  55847. /**
  55848. * Define a task used by AssetsManager to load images
  55849. */
  55850. export class ImageAssetTask extends AbstractAssetTask {
  55851. /**
  55852. * Defines the name of the task
  55853. */
  55854. name: string;
  55855. /**
  55856. * Defines the location of the image to load
  55857. */
  55858. url: string;
  55859. /**
  55860. * Gets the loaded images
  55861. */
  55862. image: HTMLImageElement;
  55863. /**
  55864. * Callback called when the task is successful
  55865. */
  55866. onSuccess: (task: ImageAssetTask) => void;
  55867. /**
  55868. * Callback called when the task is successful
  55869. */
  55870. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55871. /**
  55872. * Creates a new ImageAssetTask
  55873. * @param name defines the name of the task
  55874. * @param url defines the location of the image to load
  55875. */
  55876. constructor(
  55877. /**
  55878. * Defines the name of the task
  55879. */
  55880. name: string,
  55881. /**
  55882. * Defines the location of the image to load
  55883. */
  55884. url: string);
  55885. /**
  55886. * Execute the current task
  55887. * @param scene defines the scene where you want your assets to be loaded
  55888. * @param onSuccess is a callback called when the task is successfully executed
  55889. * @param onError is a callback called if an error occurs
  55890. */
  55891. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55892. }
  55893. /**
  55894. * Defines the interface used by texture loading tasks
  55895. */
  55896. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55897. /**
  55898. * Gets the loaded texture
  55899. */
  55900. texture: TEX;
  55901. }
  55902. /**
  55903. * Define a task used by AssetsManager to load 2D textures
  55904. */
  55905. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55906. /**
  55907. * Defines the name of the task
  55908. */
  55909. name: string;
  55910. /**
  55911. * Defines the location of the file to load
  55912. */
  55913. url: string;
  55914. /**
  55915. * Defines if mipmap should not be generated (default is false)
  55916. */
  55917. noMipmap?: boolean | undefined;
  55918. /**
  55919. * Defines if texture must be inverted on Y axis (default is false)
  55920. */
  55921. invertY?: boolean | undefined;
  55922. /**
  55923. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55924. */
  55925. samplingMode: number;
  55926. /**
  55927. * Gets the loaded texture
  55928. */
  55929. texture: Texture;
  55930. /**
  55931. * Callback called when the task is successful
  55932. */
  55933. onSuccess: (task: TextureAssetTask) => void;
  55934. /**
  55935. * Callback called when the task is successful
  55936. */
  55937. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55938. /**
  55939. * Creates a new TextureAssetTask object
  55940. * @param name defines the name of the task
  55941. * @param url defines the location of the file to load
  55942. * @param noMipmap defines if mipmap should not be generated (default is false)
  55943. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55944. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55945. */
  55946. constructor(
  55947. /**
  55948. * Defines the name of the task
  55949. */
  55950. name: string,
  55951. /**
  55952. * Defines the location of the file to load
  55953. */
  55954. url: string,
  55955. /**
  55956. * Defines if mipmap should not be generated (default is false)
  55957. */
  55958. noMipmap?: boolean | undefined,
  55959. /**
  55960. * Defines if texture must be inverted on Y axis (default is false)
  55961. */
  55962. invertY?: boolean | undefined,
  55963. /**
  55964. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55965. */
  55966. samplingMode?: number);
  55967. /**
  55968. * Execute the current task
  55969. * @param scene defines the scene where you want your assets to be loaded
  55970. * @param onSuccess is a callback called when the task is successfully executed
  55971. * @param onError is a callback called if an error occurs
  55972. */
  55973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55974. }
  55975. /**
  55976. * Define a task used by AssetsManager to load cube textures
  55977. */
  55978. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55979. /**
  55980. * Defines the name of the task
  55981. */
  55982. name: string;
  55983. /**
  55984. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55985. */
  55986. url: string;
  55987. /**
  55988. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55989. */
  55990. extensions?: string[] | undefined;
  55991. /**
  55992. * Defines if mipmaps should not be generated (default is false)
  55993. */
  55994. noMipmap?: boolean | undefined;
  55995. /**
  55996. * Defines the explicit list of files (undefined by default)
  55997. */
  55998. files?: string[] | undefined;
  55999. /**
  56000. * Gets the loaded texture
  56001. */
  56002. texture: CubeTexture;
  56003. /**
  56004. * Callback called when the task is successful
  56005. */
  56006. onSuccess: (task: CubeTextureAssetTask) => void;
  56007. /**
  56008. * Callback called when the task is successful
  56009. */
  56010. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56011. /**
  56012. * Creates a new CubeTextureAssetTask
  56013. * @param name defines the name of the task
  56014. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56015. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56016. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56017. * @param files defines the explicit list of files (undefined by default)
  56018. */
  56019. constructor(
  56020. /**
  56021. * Defines the name of the task
  56022. */
  56023. name: string,
  56024. /**
  56025. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56026. */
  56027. url: string,
  56028. /**
  56029. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56030. */
  56031. extensions?: string[] | undefined,
  56032. /**
  56033. * Defines if mipmaps should not be generated (default is false)
  56034. */
  56035. noMipmap?: boolean | undefined,
  56036. /**
  56037. * Defines the explicit list of files (undefined by default)
  56038. */
  56039. files?: string[] | undefined);
  56040. /**
  56041. * Execute the current task
  56042. * @param scene defines the scene where you want your assets to be loaded
  56043. * @param onSuccess is a callback called when the task is successfully executed
  56044. * @param onError is a callback called if an error occurs
  56045. */
  56046. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56047. }
  56048. /**
  56049. * Define a task used by AssetsManager to load HDR cube textures
  56050. */
  56051. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56052. /**
  56053. * Defines the name of the task
  56054. */
  56055. name: string;
  56056. /**
  56057. * Defines the location of the file to load
  56058. */
  56059. url: string;
  56060. /**
  56061. * Defines the desired size (the more it increases the longer the generation will be)
  56062. */
  56063. size: number;
  56064. /**
  56065. * Defines if mipmaps should not be generated (default is false)
  56066. */
  56067. noMipmap: boolean;
  56068. /**
  56069. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56070. */
  56071. generateHarmonics: boolean;
  56072. /**
  56073. * 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)
  56074. */
  56075. gammaSpace: boolean;
  56076. /**
  56077. * Internal Use Only
  56078. */
  56079. reserved: boolean;
  56080. /**
  56081. * Gets the loaded texture
  56082. */
  56083. texture: HDRCubeTexture;
  56084. /**
  56085. * Callback called when the task is successful
  56086. */
  56087. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56088. /**
  56089. * Callback called when the task is successful
  56090. */
  56091. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56092. /**
  56093. * Creates a new HDRCubeTextureAssetTask object
  56094. * @param name defines the name of the task
  56095. * @param url defines the location of the file to load
  56096. * @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.
  56097. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56098. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56099. * @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)
  56100. * @param reserved Internal use only
  56101. */
  56102. constructor(
  56103. /**
  56104. * Defines the name of the task
  56105. */
  56106. name: string,
  56107. /**
  56108. * Defines the location of the file to load
  56109. */
  56110. url: string,
  56111. /**
  56112. * Defines the desired size (the more it increases the longer the generation will be)
  56113. */
  56114. size: number,
  56115. /**
  56116. * Defines if mipmaps should not be generated (default is false)
  56117. */
  56118. noMipmap?: boolean,
  56119. /**
  56120. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56121. */
  56122. generateHarmonics?: boolean,
  56123. /**
  56124. * 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)
  56125. */
  56126. gammaSpace?: boolean,
  56127. /**
  56128. * Internal Use Only
  56129. */
  56130. reserved?: boolean);
  56131. /**
  56132. * Execute the current task
  56133. * @param scene defines the scene where you want your assets to be loaded
  56134. * @param onSuccess is a callback called when the task is successfully executed
  56135. * @param onError is a callback called if an error occurs
  56136. */
  56137. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56138. }
  56139. /**
  56140. * This class can be used to easily import assets into a scene
  56141. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56142. */
  56143. export class AssetsManager {
  56144. private _scene;
  56145. private _isLoading;
  56146. protected _tasks: AbstractAssetTask[];
  56147. protected _waitingTasksCount: number;
  56148. protected _totalTasksCount: number;
  56149. /**
  56150. * Callback called when all tasks are processed
  56151. */
  56152. onFinish: (tasks: AbstractAssetTask[]) => void;
  56153. /**
  56154. * Callback called when a task is successful
  56155. */
  56156. onTaskSuccess: (task: AbstractAssetTask) => void;
  56157. /**
  56158. * Callback called when a task had an error
  56159. */
  56160. onTaskError: (task: AbstractAssetTask) => void;
  56161. /**
  56162. * Callback called when a task is done (whatever the result is)
  56163. */
  56164. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56165. /**
  56166. * Observable called when all tasks are processed
  56167. */
  56168. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56169. /**
  56170. * Observable called when a task had an error
  56171. */
  56172. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56173. /**
  56174. * Observable called when a task is successful
  56175. */
  56176. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56177. /**
  56178. * Observable called when a task is done (whatever the result is)
  56179. */
  56180. onProgressObservable: Observable<IAssetsProgressEvent>;
  56181. /**
  56182. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56183. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56184. */
  56185. useDefaultLoadingScreen: boolean;
  56186. /**
  56187. * Creates a new AssetsManager
  56188. * @param scene defines the scene to work on
  56189. */
  56190. constructor(scene: Scene);
  56191. /**
  56192. * Add a MeshAssetTask to the list of active tasks
  56193. * @param taskName defines the name of the new task
  56194. * @param meshesNames defines the name of meshes to load
  56195. * @param rootUrl defines the root url to use to locate files
  56196. * @param sceneFilename defines the filename of the scene file
  56197. * @returns a new MeshAssetTask object
  56198. */
  56199. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56200. /**
  56201. * Add a TextFileAssetTask to the list of active tasks
  56202. * @param taskName defines the name of the new task
  56203. * @param url defines the url of the file to load
  56204. * @returns a new TextFileAssetTask object
  56205. */
  56206. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56207. /**
  56208. * Add a BinaryFileAssetTask to the list of active tasks
  56209. * @param taskName defines the name of the new task
  56210. * @param url defines the url of the file to load
  56211. * @returns a new BinaryFileAssetTask object
  56212. */
  56213. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56214. /**
  56215. * Add a ImageAssetTask to the list of active tasks
  56216. * @param taskName defines the name of the new task
  56217. * @param url defines the url of the file to load
  56218. * @returns a new ImageAssetTask object
  56219. */
  56220. addImageTask(taskName: string, url: string): ImageAssetTask;
  56221. /**
  56222. * Add a TextureAssetTask to the list of active tasks
  56223. * @param taskName defines the name of the new task
  56224. * @param url defines the url of the file to load
  56225. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56226. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56227. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56228. * @returns a new TextureAssetTask object
  56229. */
  56230. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56231. /**
  56232. * Add a CubeTextureAssetTask to the list of active tasks
  56233. * @param taskName defines the name of the new task
  56234. * @param url defines the url of the file to load
  56235. * @param extensions defines the extension to use to load the cube map (can be null)
  56236. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56237. * @param files defines the list of files to load (can be null)
  56238. * @returns a new CubeTextureAssetTask object
  56239. */
  56240. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56241. /**
  56242. *
  56243. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56244. * @param taskName defines the name of the new task
  56245. * @param url defines the url of the file to load
  56246. * @param size defines the size you want for the cubemap (can be null)
  56247. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56248. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56249. * @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)
  56250. * @param reserved Internal use only
  56251. * @returns a new HDRCubeTextureAssetTask object
  56252. */
  56253. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56254. /**
  56255. * Remove a task from the assets manager.
  56256. * @param task the task to remove
  56257. */
  56258. removeTask(task: AbstractAssetTask): void;
  56259. private _decreaseWaitingTasksCount;
  56260. private _runTask;
  56261. /**
  56262. * Reset the AssetsManager and remove all tasks
  56263. * @return the current instance of the AssetsManager
  56264. */
  56265. reset(): AssetsManager;
  56266. /**
  56267. * Start the loading process
  56268. * @return the current instance of the AssetsManager
  56269. */
  56270. load(): AssetsManager;
  56271. }
  56272. }
  56273. declare module "babylonjs/Misc/deferred" {
  56274. /**
  56275. * Wrapper class for promise with external resolve and reject.
  56276. */
  56277. export class Deferred<T> {
  56278. /**
  56279. * The promise associated with this deferred object.
  56280. */
  56281. readonly promise: Promise<T>;
  56282. private _resolve;
  56283. private _reject;
  56284. /**
  56285. * The resolve method of the promise associated with this deferred object.
  56286. */
  56287. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56288. /**
  56289. * The reject method of the promise associated with this deferred object.
  56290. */
  56291. readonly reject: (reason?: any) => void;
  56292. /**
  56293. * Constructor for this deferred object.
  56294. */
  56295. constructor();
  56296. }
  56297. }
  56298. declare module "babylonjs/Misc/filesInput" {
  56299. import { Engine } from "babylonjs/Engines/engine";
  56300. import { Scene } from "babylonjs/scene";
  56301. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  56302. /**
  56303. * Class used to help managing file picking and drag'n'drop
  56304. */
  56305. export class FilesInput {
  56306. /**
  56307. * List of files ready to be loaded
  56308. */
  56309. static readonly FilesToLoad: {
  56310. [key: string]: File;
  56311. };
  56312. /**
  56313. * Callback called when a file is processed
  56314. */
  56315. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56316. private _engine;
  56317. private _currentScene;
  56318. private _sceneLoadedCallback;
  56319. private _progressCallback;
  56320. private _additionalRenderLoopLogicCallback;
  56321. private _textureLoadingCallback;
  56322. private _startingProcessingFilesCallback;
  56323. private _onReloadCallback;
  56324. private _errorCallback;
  56325. private _elementToMonitor;
  56326. private _sceneFileToLoad;
  56327. private _filesToLoad;
  56328. /**
  56329. * Creates a new FilesInput
  56330. * @param engine defines the rendering engine
  56331. * @param scene defines the hosting scene
  56332. * @param sceneLoadedCallback callback called when scene is loaded
  56333. * @param progressCallback callback called to track progress
  56334. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56335. * @param textureLoadingCallback callback called when a texture is loading
  56336. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56337. * @param onReloadCallback callback called when a reload is requested
  56338. * @param errorCallback callback call if an error occurs
  56339. */
  56340. 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);
  56341. private _dragEnterHandler;
  56342. private _dragOverHandler;
  56343. private _dropHandler;
  56344. /**
  56345. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56346. * @param elementToMonitor defines the DOM element to track
  56347. */
  56348. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56349. /**
  56350. * Release all associated resources
  56351. */
  56352. dispose(): void;
  56353. private renderFunction;
  56354. private drag;
  56355. private drop;
  56356. private _traverseFolder;
  56357. private _processFiles;
  56358. /**
  56359. * Load files from a drop event
  56360. * @param event defines the drop event to use as source
  56361. */
  56362. loadFiles(event: any): void;
  56363. private _processReload;
  56364. /**
  56365. * Reload the current scene from the loaded files
  56366. */
  56367. reload(): void;
  56368. }
  56369. }
  56370. declare module "babylonjs/Misc/HighDynamicRange/index" {
  56371. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  56372. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  56373. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56374. }
  56375. declare module "babylonjs/Misc/sceneOptimizer" {
  56376. import { Scene, IDisposable } from "babylonjs/scene";
  56377. import { Observable } from "babylonjs/Misc/observable";
  56378. /**
  56379. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56380. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56381. */
  56382. export class SceneOptimization {
  56383. /**
  56384. * Defines the priority of this optimization (0 by default which means first in the list)
  56385. */
  56386. priority: number;
  56387. /**
  56388. * Gets a string describing the action executed by the current optimization
  56389. * @returns description string
  56390. */
  56391. getDescription(): string;
  56392. /**
  56393. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56394. * @param scene defines the current scene where to apply this optimization
  56395. * @param optimizer defines the current optimizer
  56396. * @returns true if everything that can be done was applied
  56397. */
  56398. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56399. /**
  56400. * Creates the SceneOptimization object
  56401. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56402. * @param desc defines the description associated with the optimization
  56403. */
  56404. constructor(
  56405. /**
  56406. * Defines the priority of this optimization (0 by default which means first in the list)
  56407. */
  56408. priority?: number);
  56409. }
  56410. /**
  56411. * Defines an optimization used to reduce the size of render target textures
  56412. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56413. */
  56414. export class TextureOptimization extends SceneOptimization {
  56415. /**
  56416. * Defines the priority of this optimization (0 by default which means first in the list)
  56417. */
  56418. priority: number;
  56419. /**
  56420. * 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
  56421. */
  56422. maximumSize: number;
  56423. /**
  56424. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56425. */
  56426. step: number;
  56427. /**
  56428. * Gets a string describing the action executed by the current optimization
  56429. * @returns description string
  56430. */
  56431. getDescription(): string;
  56432. /**
  56433. * Creates the TextureOptimization object
  56434. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56435. * @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
  56436. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56437. */
  56438. constructor(
  56439. /**
  56440. * Defines the priority of this optimization (0 by default which means first in the list)
  56441. */
  56442. priority?: number,
  56443. /**
  56444. * 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
  56445. */
  56446. maximumSize?: number,
  56447. /**
  56448. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56449. */
  56450. step?: number);
  56451. /**
  56452. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56453. * @param scene defines the current scene where to apply this optimization
  56454. * @param optimizer defines the current optimizer
  56455. * @returns true if everything that can be done was applied
  56456. */
  56457. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56458. }
  56459. /**
  56460. * Defines an optimization used to increase or decrease the rendering resolution
  56461. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56462. */
  56463. export class HardwareScalingOptimization extends SceneOptimization {
  56464. /**
  56465. * Defines the priority of this optimization (0 by default which means first in the list)
  56466. */
  56467. priority: number;
  56468. /**
  56469. * Defines the maximum scale to use (2 by default)
  56470. */
  56471. maximumScale: number;
  56472. /**
  56473. * Defines the step to use between two passes (0.5 by default)
  56474. */
  56475. step: number;
  56476. private _currentScale;
  56477. private _directionOffset;
  56478. /**
  56479. * Gets a string describing the action executed by the current optimization
  56480. * @return description string
  56481. */
  56482. getDescription(): string;
  56483. /**
  56484. * Creates the HardwareScalingOptimization object
  56485. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56486. * @param maximumScale defines the maximum scale to use (2 by default)
  56487. * @param step defines the step to use between two passes (0.5 by default)
  56488. */
  56489. constructor(
  56490. /**
  56491. * Defines the priority of this optimization (0 by default which means first in the list)
  56492. */
  56493. priority?: number,
  56494. /**
  56495. * Defines the maximum scale to use (2 by default)
  56496. */
  56497. maximumScale?: number,
  56498. /**
  56499. * Defines the step to use between two passes (0.5 by default)
  56500. */
  56501. step?: number);
  56502. /**
  56503. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56504. * @param scene defines the current scene where to apply this optimization
  56505. * @param optimizer defines the current optimizer
  56506. * @returns true if everything that can be done was applied
  56507. */
  56508. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56509. }
  56510. /**
  56511. * Defines an optimization used to remove shadows
  56512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56513. */
  56514. export class ShadowsOptimization extends SceneOptimization {
  56515. /**
  56516. * Gets a string describing the action executed by the current optimization
  56517. * @return description string
  56518. */
  56519. getDescription(): string;
  56520. /**
  56521. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56522. * @param scene defines the current scene where to apply this optimization
  56523. * @param optimizer defines the current optimizer
  56524. * @returns true if everything that can be done was applied
  56525. */
  56526. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56527. }
  56528. /**
  56529. * Defines an optimization used to turn post-processes off
  56530. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56531. */
  56532. export class PostProcessesOptimization extends SceneOptimization {
  56533. /**
  56534. * Gets a string describing the action executed by the current optimization
  56535. * @return description string
  56536. */
  56537. getDescription(): string;
  56538. /**
  56539. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56540. * @param scene defines the current scene where to apply this optimization
  56541. * @param optimizer defines the current optimizer
  56542. * @returns true if everything that can be done was applied
  56543. */
  56544. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56545. }
  56546. /**
  56547. * Defines an optimization used to turn lens flares off
  56548. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56549. */
  56550. export class LensFlaresOptimization extends SceneOptimization {
  56551. /**
  56552. * Gets a string describing the action executed by the current optimization
  56553. * @return description string
  56554. */
  56555. getDescription(): string;
  56556. /**
  56557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56558. * @param scene defines the current scene where to apply this optimization
  56559. * @param optimizer defines the current optimizer
  56560. * @returns true if everything that can be done was applied
  56561. */
  56562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56563. }
  56564. /**
  56565. * Defines an optimization based on user defined callback.
  56566. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56567. */
  56568. export class CustomOptimization extends SceneOptimization {
  56569. /**
  56570. * Callback called to apply the custom optimization.
  56571. */
  56572. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56573. /**
  56574. * Callback called to get custom description
  56575. */
  56576. onGetDescription: () => string;
  56577. /**
  56578. * Gets a string describing the action executed by the current optimization
  56579. * @returns description string
  56580. */
  56581. getDescription(): string;
  56582. /**
  56583. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56584. * @param scene defines the current scene where to apply this optimization
  56585. * @param optimizer defines the current optimizer
  56586. * @returns true if everything that can be done was applied
  56587. */
  56588. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56589. }
  56590. /**
  56591. * Defines an optimization used to turn particles off
  56592. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56593. */
  56594. export class ParticlesOptimization extends SceneOptimization {
  56595. /**
  56596. * Gets a string describing the action executed by the current optimization
  56597. * @return description string
  56598. */
  56599. getDescription(): string;
  56600. /**
  56601. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56602. * @param scene defines the current scene where to apply this optimization
  56603. * @param optimizer defines the current optimizer
  56604. * @returns true if everything that can be done was applied
  56605. */
  56606. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56607. }
  56608. /**
  56609. * Defines an optimization used to turn render targets off
  56610. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56611. */
  56612. export class RenderTargetsOptimization extends SceneOptimization {
  56613. /**
  56614. * Gets a string describing the action executed by the current optimization
  56615. * @return description string
  56616. */
  56617. getDescription(): string;
  56618. /**
  56619. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56620. * @param scene defines the current scene where to apply this optimization
  56621. * @param optimizer defines the current optimizer
  56622. * @returns true if everything that can be done was applied
  56623. */
  56624. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56625. }
  56626. /**
  56627. * Defines an optimization used to merge meshes with compatible materials
  56628. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56629. */
  56630. export class MergeMeshesOptimization extends SceneOptimization {
  56631. private static _UpdateSelectionTree;
  56632. /**
  56633. * Gets or sets a boolean which defines if optimization octree has to be updated
  56634. */
  56635. /**
  56636. * Gets or sets a boolean which defines if optimization octree has to be updated
  56637. */
  56638. static UpdateSelectionTree: boolean;
  56639. /**
  56640. * Gets a string describing the action executed by the current optimization
  56641. * @return description string
  56642. */
  56643. getDescription(): string;
  56644. private _canBeMerged;
  56645. /**
  56646. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56647. * @param scene defines the current scene where to apply this optimization
  56648. * @param optimizer defines the current optimizer
  56649. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56650. * @returns true if everything that can be done was applied
  56651. */
  56652. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56653. }
  56654. /**
  56655. * Defines a list of options used by SceneOptimizer
  56656. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56657. */
  56658. export class SceneOptimizerOptions {
  56659. /**
  56660. * Defines the target frame rate to reach (60 by default)
  56661. */
  56662. targetFrameRate: number;
  56663. /**
  56664. * Defines the interval between two checkes (2000ms by default)
  56665. */
  56666. trackerDuration: number;
  56667. /**
  56668. * Gets the list of optimizations to apply
  56669. */
  56670. optimizations: SceneOptimization[];
  56671. /**
  56672. * Creates a new list of options used by SceneOptimizer
  56673. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56674. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56675. */
  56676. constructor(
  56677. /**
  56678. * Defines the target frame rate to reach (60 by default)
  56679. */
  56680. targetFrameRate?: number,
  56681. /**
  56682. * Defines the interval between two checkes (2000ms by default)
  56683. */
  56684. trackerDuration?: number);
  56685. /**
  56686. * Add a new optimization
  56687. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56688. * @returns the current SceneOptimizerOptions
  56689. */
  56690. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56691. /**
  56692. * Add a new custom optimization
  56693. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56694. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56695. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56696. * @returns the current SceneOptimizerOptions
  56697. */
  56698. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56699. /**
  56700. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56701. * @param targetFrameRate defines the target frame rate (60 by default)
  56702. * @returns a SceneOptimizerOptions object
  56703. */
  56704. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56705. /**
  56706. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56707. * @param targetFrameRate defines the target frame rate (60 by default)
  56708. * @returns a SceneOptimizerOptions object
  56709. */
  56710. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56711. /**
  56712. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56713. * @param targetFrameRate defines the target frame rate (60 by default)
  56714. * @returns a SceneOptimizerOptions object
  56715. */
  56716. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56717. }
  56718. /**
  56719. * Class used to run optimizations in order to reach a target frame rate
  56720. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56721. */
  56722. export class SceneOptimizer implements IDisposable {
  56723. private _isRunning;
  56724. private _options;
  56725. private _scene;
  56726. private _currentPriorityLevel;
  56727. private _targetFrameRate;
  56728. private _trackerDuration;
  56729. private _currentFrameRate;
  56730. private _sceneDisposeObserver;
  56731. private _improvementMode;
  56732. /**
  56733. * Defines an observable called when the optimizer reaches the target frame rate
  56734. */
  56735. onSuccessObservable: Observable<SceneOptimizer>;
  56736. /**
  56737. * Defines an observable called when the optimizer enables an optimization
  56738. */
  56739. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56740. /**
  56741. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56742. */
  56743. onFailureObservable: Observable<SceneOptimizer>;
  56744. /**
  56745. * Gets a boolean indicating if the optimizer is in improvement mode
  56746. */
  56747. readonly isInImprovementMode: boolean;
  56748. /**
  56749. * Gets the current priority level (0 at start)
  56750. */
  56751. readonly currentPriorityLevel: number;
  56752. /**
  56753. * Gets the current frame rate checked by the SceneOptimizer
  56754. */
  56755. readonly currentFrameRate: number;
  56756. /**
  56757. * Gets or sets the current target frame rate (60 by default)
  56758. */
  56759. /**
  56760. * Gets or sets the current target frame rate (60 by default)
  56761. */
  56762. targetFrameRate: number;
  56763. /**
  56764. * Gets or sets the current interval between two checks (every 2000ms by default)
  56765. */
  56766. /**
  56767. * Gets or sets the current interval between two checks (every 2000ms by default)
  56768. */
  56769. trackerDuration: number;
  56770. /**
  56771. * Gets the list of active optimizations
  56772. */
  56773. readonly optimizations: SceneOptimization[];
  56774. /**
  56775. * Creates a new SceneOptimizer
  56776. * @param scene defines the scene to work on
  56777. * @param options defines the options to use with the SceneOptimizer
  56778. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56779. * @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)
  56780. */
  56781. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56782. /**
  56783. * Stops the current optimizer
  56784. */
  56785. stop(): void;
  56786. /**
  56787. * Reset the optimizer to initial step (current priority level = 0)
  56788. */
  56789. reset(): void;
  56790. /**
  56791. * Start the optimizer. By default it will try to reach a specific framerate
  56792. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56793. */
  56794. start(): void;
  56795. private _checkCurrentState;
  56796. /**
  56797. * Release all resources
  56798. */
  56799. dispose(): void;
  56800. /**
  56801. * Helper function to create a SceneOptimizer with one single line of code
  56802. * @param scene defines the scene to work on
  56803. * @param options defines the options to use with the SceneOptimizer
  56804. * @param onSuccess defines a callback to call on success
  56805. * @param onFailure defines a callback to call on failure
  56806. * @returns the new SceneOptimizer object
  56807. */
  56808. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56809. }
  56810. }
  56811. declare module "babylonjs/Misc/sceneSerializer" {
  56812. import { Scene } from "babylonjs/scene";
  56813. /**
  56814. * Class used to serialize a scene into a string
  56815. */
  56816. export class SceneSerializer {
  56817. /**
  56818. * Clear cache used by a previous serialization
  56819. */
  56820. static ClearCache(): void;
  56821. /**
  56822. * Serialize a scene into a JSON compatible object
  56823. * @param scene defines the scene to serialize
  56824. * @returns a JSON compatible object
  56825. */
  56826. static Serialize(scene: Scene): any;
  56827. /**
  56828. * Serialize a mesh into a JSON compatible object
  56829. * @param toSerialize defines the mesh to serialize
  56830. * @param withParents defines if parents must be serialized as well
  56831. * @param withChildren defines if children must be serialized as well
  56832. * @returns a JSON compatible object
  56833. */
  56834. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56835. }
  56836. }
  56837. declare module "babylonjs/Misc/videoRecorder" {
  56838. import { Nullable } from "babylonjs/types";
  56839. import { Engine } from "babylonjs/Engines/engine";
  56840. /**
  56841. * This represents the different options avilable for the video capture.
  56842. */
  56843. export interface VideoRecorderOptions {
  56844. /** Defines the mime type of the video */
  56845. mimeType: string;
  56846. /** Defines the video the video should be recorded at */
  56847. fps: number;
  56848. /** Defines the chunk size for the recording data */
  56849. recordChunckSize: number;
  56850. /** The audio tracks to attach to the record */
  56851. audioTracks?: MediaStreamTrack[];
  56852. }
  56853. /**
  56854. * This can helps recording videos from BabylonJS.
  56855. * This is based on the available WebRTC functionalities of the browser.
  56856. *
  56857. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56858. */
  56859. export class VideoRecorder {
  56860. private static readonly _defaultOptions;
  56861. /**
  56862. * Returns wehther or not the VideoRecorder is available in your browser.
  56863. * @param engine Defines the Babylon Engine to check the support for
  56864. * @returns true if supported otherwise false
  56865. */
  56866. static IsSupported(engine: Engine): boolean;
  56867. private readonly _options;
  56868. private _canvas;
  56869. private _mediaRecorder;
  56870. private _recordedChunks;
  56871. private _fileName;
  56872. private _resolve;
  56873. private _reject;
  56874. /**
  56875. * True wether a recording is already in progress.
  56876. */
  56877. readonly isRecording: boolean;
  56878. /**
  56879. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56880. * a video file.
  56881. * @param engine Defines the BabylonJS Engine you wish to record
  56882. * @param options Defines options that can be used to customized the capture
  56883. */
  56884. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56885. /**
  56886. * Stops the current recording before the default capture timeout passed in the startRecording
  56887. * functions.
  56888. */
  56889. stopRecording(): void;
  56890. /**
  56891. * Starts recording the canvas for a max duration specified in parameters.
  56892. * @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.
  56893. * @param maxDuration Defines the maximum recording time in seconds.
  56894. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56895. * @return a promise callback at the end of the recording with the video data in Blob.
  56896. */
  56897. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56898. /**
  56899. * Releases internal resources used during the recording.
  56900. */
  56901. dispose(): void;
  56902. private _handleDataAvailable;
  56903. private _handleError;
  56904. private _handleStop;
  56905. }
  56906. }
  56907. declare module "babylonjs/Misc/workerPool" {
  56908. import { IDisposable } from "babylonjs/scene";
  56909. /**
  56910. * Helper class to push actions to a pool of workers.
  56911. */
  56912. export class WorkerPool implements IDisposable {
  56913. private _workerInfos;
  56914. private _pendingActions;
  56915. /**
  56916. * Constructor
  56917. * @param workers Array of workers to use for actions
  56918. */
  56919. constructor(workers: Array<Worker>);
  56920. /**
  56921. * Terminates all workers and clears any pending actions.
  56922. */
  56923. dispose(): void;
  56924. /**
  56925. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56926. * pended until a worker has completed its action.
  56927. * @param action The action to perform. Call onComplete when the action is complete.
  56928. */
  56929. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56930. private _execute;
  56931. }
  56932. }
  56933. declare module "babylonjs/Misc/screenshotTools" {
  56934. import { Camera } from "babylonjs/Cameras/camera";
  56935. import { Engine } from "babylonjs/Engines/engine";
  56936. /**
  56937. * Class containing a set of static utilities functions for screenshots
  56938. */
  56939. export class ScreenshotTools {
  56940. /**
  56941. * Captures a screenshot of the current rendering
  56942. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56943. * @param engine defines the rendering engine
  56944. * @param camera defines the source camera
  56945. * @param size This parameter can be set to a single number or to an object with the
  56946. * following (optional) properties: precision, width, height. If a single number is passed,
  56947. * it will be used for both width and height. If an object is passed, the screenshot size
  56948. * will be derived from the parameters. The precision property is a multiplier allowing
  56949. * rendering at a higher or lower resolution
  56950. * @param successCallback defines the callback receives a single parameter which contains the
  56951. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56952. * src parameter of an <img> to display it
  56953. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56954. * Check your browser for supported MIME types
  56955. */
  56956. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56957. /**
  56958. * Generates an image screenshot from the specified camera.
  56959. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56960. * @param engine The engine to use for rendering
  56961. * @param camera The camera to use for rendering
  56962. * @param size This parameter can be set to a single number or to an object with the
  56963. * following (optional) properties: precision, width, height. If a single number is passed,
  56964. * it will be used for both width and height. If an object is passed, the screenshot size
  56965. * will be derived from the parameters. The precision property is a multiplier allowing
  56966. * rendering at a higher or lower resolution
  56967. * @param successCallback The callback receives a single parameter which contains the
  56968. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56969. * src parameter of an <img> to display it
  56970. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56971. * Check your browser for supported MIME types
  56972. * @param samples Texture samples (default: 1)
  56973. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56974. * @param fileName A name for for the downloaded file.
  56975. */
  56976. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56977. }
  56978. }
  56979. declare module "babylonjs/Misc/index" {
  56980. export * from "babylonjs/Misc/andOrNotEvaluator";
  56981. export * from "babylonjs/Misc/assetsManager";
  56982. export * from "babylonjs/Misc/dds";
  56983. export * from "babylonjs/Misc/decorators";
  56984. export * from "babylonjs/Misc/deferred";
  56985. export * from "babylonjs/Misc/environmentTextureTools";
  56986. export * from "babylonjs/Misc/filesInput";
  56987. export * from "babylonjs/Misc/HighDynamicRange/index";
  56988. export * from "babylonjs/Misc/khronosTextureContainer";
  56989. export * from "babylonjs/Misc/observable";
  56990. export * from "babylonjs/Misc/performanceMonitor";
  56991. export * from "babylonjs/Misc/promise";
  56992. export * from "babylonjs/Misc/sceneOptimizer";
  56993. export * from "babylonjs/Misc/sceneSerializer";
  56994. export * from "babylonjs/Misc/smartArray";
  56995. export * from "babylonjs/Misc/stringDictionary";
  56996. export * from "babylonjs/Misc/tags";
  56997. export * from "babylonjs/Misc/textureTools";
  56998. export * from "babylonjs/Misc/tga";
  56999. export * from "babylonjs/Misc/tools";
  57000. export * from "babylonjs/Misc/videoRecorder";
  57001. export * from "babylonjs/Misc/virtualJoystick";
  57002. export * from "babylonjs/Misc/workerPool";
  57003. export * from "babylonjs/Misc/logger";
  57004. export * from "babylonjs/Misc/typeStore";
  57005. export * from "babylonjs/Misc/filesInputStore";
  57006. export * from "babylonjs/Misc/deepCopier";
  57007. export * from "babylonjs/Misc/pivotTools";
  57008. export * from "babylonjs/Misc/precisionDate";
  57009. export * from "babylonjs/Misc/screenshotTools";
  57010. export * from "babylonjs/Misc/typeStore";
  57011. }
  57012. declare module "babylonjs/index" {
  57013. export * from "babylonjs/abstractScene";
  57014. export * from "babylonjs/Actions/index";
  57015. export * from "babylonjs/Animations/index";
  57016. export * from "babylonjs/assetContainer";
  57017. export * from "babylonjs/Audio/index";
  57018. export * from "babylonjs/Behaviors/index";
  57019. export * from "babylonjs/Bones/index";
  57020. export * from "babylonjs/Cameras/index";
  57021. export * from "babylonjs/Collisions/index";
  57022. export * from "babylonjs/Culling/index";
  57023. export * from "babylonjs/Debug/index";
  57024. export * from "babylonjs/Engines/index";
  57025. export * from "babylonjs/Events/index";
  57026. export * from "babylonjs/Gamepads/index";
  57027. export * from "babylonjs/Gizmos/index";
  57028. export * from "babylonjs/Helpers/index";
  57029. export * from "babylonjs/Instrumentation/index";
  57030. export * from "babylonjs/Layers/index";
  57031. export * from "babylonjs/LensFlares/index";
  57032. export * from "babylonjs/Lights/index";
  57033. export * from "babylonjs/Loading/index";
  57034. export * from "babylonjs/Materials/index";
  57035. export * from "babylonjs/Maths/index";
  57036. export * from "babylonjs/Meshes/index";
  57037. export * from "babylonjs/Morph/index";
  57038. export * from "babylonjs/node";
  57039. export * from "babylonjs/Offline/index";
  57040. export * from "babylonjs/Particles/index";
  57041. export * from "babylonjs/Physics/index";
  57042. export * from "babylonjs/PostProcesses/index";
  57043. export * from "babylonjs/Probes/index";
  57044. export * from "babylonjs/Rendering/index";
  57045. export * from "babylonjs/scene";
  57046. export * from "babylonjs/sceneComponent";
  57047. export * from "babylonjs/Sprites/index";
  57048. export * from "babylonjs/States/index";
  57049. export * from "babylonjs/Misc/index";
  57050. export * from "babylonjs/types";
  57051. }
  57052. declare module "babylonjs/Animations/pathCursor" {
  57053. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57054. /**
  57055. * A cursor which tracks a point on a path
  57056. */
  57057. export class PathCursor {
  57058. private path;
  57059. /**
  57060. * Stores path cursor callbacks for when an onchange event is triggered
  57061. */
  57062. private _onchange;
  57063. /**
  57064. * The value of the path cursor
  57065. */
  57066. value: number;
  57067. /**
  57068. * The animation array of the path cursor
  57069. */
  57070. animations: Animation[];
  57071. /**
  57072. * Initializes the path cursor
  57073. * @param path The path to track
  57074. */
  57075. constructor(path: Path2);
  57076. /**
  57077. * Gets the cursor point on the path
  57078. * @returns A point on the path cursor at the cursor location
  57079. */
  57080. getPoint(): Vector3;
  57081. /**
  57082. * Moves the cursor ahead by the step amount
  57083. * @param step The amount to move the cursor forward
  57084. * @returns This path cursor
  57085. */
  57086. moveAhead(step?: number): PathCursor;
  57087. /**
  57088. * Moves the cursor behind by the step amount
  57089. * @param step The amount to move the cursor back
  57090. * @returns This path cursor
  57091. */
  57092. moveBack(step?: number): PathCursor;
  57093. /**
  57094. * Moves the cursor by the step amount
  57095. * If the step amount is greater than one, an exception is thrown
  57096. * @param step The amount to move the cursor
  57097. * @returns This path cursor
  57098. */
  57099. move(step: number): PathCursor;
  57100. /**
  57101. * Ensures that the value is limited between zero and one
  57102. * @returns This path cursor
  57103. */
  57104. private ensureLimits;
  57105. /**
  57106. * Runs onchange callbacks on change (used by the animation engine)
  57107. * @returns This path cursor
  57108. */
  57109. private raiseOnChange;
  57110. /**
  57111. * Executes a function on change
  57112. * @param f A path cursor onchange callback
  57113. * @returns This path cursor
  57114. */
  57115. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57116. }
  57117. }
  57118. declare module "babylonjs/Legacy/legacy" {
  57119. import * as Babylon from "babylonjs/index";
  57120. export * from "babylonjs/index";
  57121. }
  57122. declare module "babylonjs/Shaders/blur.fragment" {
  57123. /** @hidden */
  57124. export var blurPixelShader: {
  57125. name: string;
  57126. shader: string;
  57127. };
  57128. }
  57129. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57130. /** @hidden */
  57131. export var bones300Declaration: {
  57132. name: string;
  57133. shader: string;
  57134. };
  57135. }
  57136. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57137. /** @hidden */
  57138. export var instances300Declaration: {
  57139. name: string;
  57140. shader: string;
  57141. };
  57142. }
  57143. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57144. /** @hidden */
  57145. export var pointCloudVertexDeclaration: {
  57146. name: string;
  57147. shader: string;
  57148. };
  57149. }
  57150. // Mixins
  57151. interface Window {
  57152. mozIndexedDB: IDBFactory;
  57153. webkitIndexedDB: IDBFactory;
  57154. msIndexedDB: IDBFactory;
  57155. webkitURL: typeof URL;
  57156. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57157. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57158. WebGLRenderingContext: WebGLRenderingContext;
  57159. MSGesture: MSGesture;
  57160. CANNON: any;
  57161. AudioContext: AudioContext;
  57162. webkitAudioContext: AudioContext;
  57163. PointerEvent: any;
  57164. Math: Math;
  57165. Uint8Array: Uint8ArrayConstructor;
  57166. Float32Array: Float32ArrayConstructor;
  57167. mozURL: typeof URL;
  57168. msURL: typeof URL;
  57169. VRFrameData: any; // WebVR, from specs 1.1
  57170. DracoDecoderModule: any;
  57171. setImmediate(handler: (...args: any[]) => void): number;
  57172. }
  57173. interface HTMLCanvasElement {
  57174. requestPointerLock(): void;
  57175. msRequestPointerLock?(): void;
  57176. mozRequestPointerLock?(): void;
  57177. webkitRequestPointerLock?(): void;
  57178. /** Track wether a record is in progress */
  57179. isRecording: boolean;
  57180. /** Capture Stream method defined by some browsers */
  57181. captureStream(fps?: number): MediaStream;
  57182. }
  57183. interface CanvasRenderingContext2D {
  57184. msImageSmoothingEnabled: boolean;
  57185. }
  57186. interface MouseEvent {
  57187. mozMovementX: number;
  57188. mozMovementY: number;
  57189. webkitMovementX: number;
  57190. webkitMovementY: number;
  57191. msMovementX: number;
  57192. msMovementY: number;
  57193. }
  57194. interface Navigator {
  57195. mozGetVRDevices: (any: any) => any;
  57196. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57197. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57198. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57199. webkitGetGamepads(): Gamepad[];
  57200. msGetGamepads(): Gamepad[];
  57201. webkitGamepads(): Gamepad[];
  57202. }
  57203. interface HTMLVideoElement {
  57204. mozSrcObject: any;
  57205. }
  57206. interface Math {
  57207. fround(x: number): number;
  57208. imul(a: number, b: number): number;
  57209. }
  57210. interface WebGLProgram {
  57211. context?: WebGLRenderingContext;
  57212. vertexShader?: WebGLShader;
  57213. fragmentShader?: WebGLShader;
  57214. isParallelCompiled: boolean;
  57215. onCompiled?: () => void;
  57216. }
  57217. interface WebGLRenderingContext {
  57218. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57219. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57220. vertexAttribDivisor(index: number, divisor: number): void;
  57221. createVertexArray(): any;
  57222. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57223. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57224. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57225. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57226. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57227. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57228. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57229. // Queries
  57230. createQuery(): WebGLQuery;
  57231. deleteQuery(query: WebGLQuery): void;
  57232. beginQuery(target: number, query: WebGLQuery): void;
  57233. endQuery(target: number): void;
  57234. getQueryParameter(query: WebGLQuery, pname: number): any;
  57235. getQuery(target: number, pname: number): any;
  57236. MAX_SAMPLES: number;
  57237. RGBA8: number;
  57238. READ_FRAMEBUFFER: number;
  57239. DRAW_FRAMEBUFFER: number;
  57240. UNIFORM_BUFFER: number;
  57241. HALF_FLOAT_OES: number;
  57242. RGBA16F: number;
  57243. RGBA32F: number;
  57244. R32F: number;
  57245. RG32F: number;
  57246. RGB32F: number;
  57247. R16F: number;
  57248. RG16F: number;
  57249. RGB16F: number;
  57250. RED: number;
  57251. RG: number;
  57252. R8: number;
  57253. RG8: number;
  57254. UNSIGNED_INT_24_8: number;
  57255. DEPTH24_STENCIL8: number;
  57256. /* Multiple Render Targets */
  57257. drawBuffers(buffers: number[]): void;
  57258. readBuffer(src: number): void;
  57259. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57260. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57261. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57262. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57263. // Occlusion Query
  57264. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57265. ANY_SAMPLES_PASSED: number;
  57266. QUERY_RESULT_AVAILABLE: number;
  57267. QUERY_RESULT: number;
  57268. }
  57269. interface WebGLBuffer {
  57270. references: number;
  57271. capacity: number;
  57272. is32Bits: boolean;
  57273. }
  57274. interface WebGLProgram {
  57275. transformFeedback?: WebGLTransformFeedback | null;
  57276. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57277. }
  57278. interface EXT_disjoint_timer_query {
  57279. QUERY_COUNTER_BITS_EXT: number;
  57280. TIME_ELAPSED_EXT: number;
  57281. TIMESTAMP_EXT: number;
  57282. GPU_DISJOINT_EXT: number;
  57283. QUERY_RESULT_EXT: number;
  57284. QUERY_RESULT_AVAILABLE_EXT: number;
  57285. queryCounterEXT(query: WebGLQuery, target: number): void;
  57286. createQueryEXT(): WebGLQuery;
  57287. beginQueryEXT(target: number, query: WebGLQuery): void;
  57288. endQueryEXT(target: number): void;
  57289. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57290. deleteQueryEXT(query: WebGLQuery): void;
  57291. }
  57292. interface WebGLUniformLocation {
  57293. _currentState: any;
  57294. }
  57295. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57296. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57297. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57298. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57299. interface WebGLRenderingContext {
  57300. readonly RASTERIZER_DISCARD: number;
  57301. readonly DEPTH_COMPONENT24: number;
  57302. readonly TEXTURE_3D: number;
  57303. readonly TEXTURE_2D_ARRAY: number;
  57304. readonly TEXTURE_COMPARE_FUNC: number;
  57305. readonly TEXTURE_COMPARE_MODE: number;
  57306. readonly COMPARE_REF_TO_TEXTURE: number;
  57307. readonly TEXTURE_WRAP_R: number;
  57308. readonly HALF_FLOAT: number;
  57309. readonly RGB8: number;
  57310. readonly RED_INTEGER: number;
  57311. readonly RG_INTEGER: number;
  57312. readonly RGB_INTEGER: number;
  57313. readonly RGBA_INTEGER: number;
  57314. readonly R8_SNORM: number;
  57315. readonly RG8_SNORM: number;
  57316. readonly RGB8_SNORM: number;
  57317. readonly RGBA8_SNORM: number;
  57318. readonly R8I: number;
  57319. readonly RG8I: number;
  57320. readonly RGB8I: number;
  57321. readonly RGBA8I: number;
  57322. readonly R8UI: number;
  57323. readonly RG8UI: number;
  57324. readonly RGB8UI: number;
  57325. readonly RGBA8UI: number;
  57326. readonly R16I: number;
  57327. readonly RG16I: number;
  57328. readonly RGB16I: number;
  57329. readonly RGBA16I: number;
  57330. readonly R16UI: number;
  57331. readonly RG16UI: number;
  57332. readonly RGB16UI: number;
  57333. readonly RGBA16UI: number;
  57334. readonly R32I: number;
  57335. readonly RG32I: number;
  57336. readonly RGB32I: number;
  57337. readonly RGBA32I: number;
  57338. readonly R32UI: number;
  57339. readonly RG32UI: number;
  57340. readonly RGB32UI: number;
  57341. readonly RGBA32UI: number;
  57342. readonly RGB10_A2UI: number;
  57343. readonly R11F_G11F_B10F: number;
  57344. readonly RGB9_E5: number;
  57345. readonly RGB10_A2: number;
  57346. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57347. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57348. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57349. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57350. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57351. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57352. 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;
  57353. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57354. readonly TRANSFORM_FEEDBACK: number;
  57355. readonly INTERLEAVED_ATTRIBS: number;
  57356. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57357. createTransformFeedback(): WebGLTransformFeedback;
  57358. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57359. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57360. beginTransformFeedback(primitiveMode: number): void;
  57361. endTransformFeedback(): void;
  57362. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57363. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57364. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57365. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57366. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57367. }
  57368. interface ImageBitmap {
  57369. readonly width: number;
  57370. readonly height: number;
  57371. close(): void;
  57372. }
  57373. interface WebGLQuery extends WebGLObject {
  57374. }
  57375. declare var WebGLQuery: {
  57376. prototype: WebGLQuery;
  57377. new(): WebGLQuery;
  57378. };
  57379. interface WebGLSampler extends WebGLObject {
  57380. }
  57381. declare var WebGLSampler: {
  57382. prototype: WebGLSampler;
  57383. new(): WebGLSampler;
  57384. };
  57385. interface WebGLSync extends WebGLObject {
  57386. }
  57387. declare var WebGLSync: {
  57388. prototype: WebGLSync;
  57389. new(): WebGLSync;
  57390. };
  57391. interface WebGLTransformFeedback extends WebGLObject {
  57392. }
  57393. declare var WebGLTransformFeedback: {
  57394. prototype: WebGLTransformFeedback;
  57395. new(): WebGLTransformFeedback;
  57396. };
  57397. interface WebGLVertexArrayObject extends WebGLObject {
  57398. }
  57399. declare var WebGLVertexArrayObject: {
  57400. prototype: WebGLVertexArrayObject;
  57401. new(): WebGLVertexArrayObject;
  57402. };
  57403. // Type definitions for WebVR API
  57404. // Project: https://w3c.github.io/webvr/
  57405. // Definitions by: six a <https://github.com/lostfictions>
  57406. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57407. interface VRDisplay extends EventTarget {
  57408. /**
  57409. * Dictionary of capabilities describing the VRDisplay.
  57410. */
  57411. readonly capabilities: VRDisplayCapabilities;
  57412. /**
  57413. * z-depth defining the far plane of the eye view frustum
  57414. * enables mapping of values in the render target depth
  57415. * attachment to scene coordinates. Initially set to 10000.0.
  57416. */
  57417. depthFar: number;
  57418. /**
  57419. * z-depth defining the near plane of the eye view frustum
  57420. * enables mapping of values in the render target depth
  57421. * attachment to scene coordinates. Initially set to 0.01.
  57422. */
  57423. depthNear: number;
  57424. /**
  57425. * An identifier for this distinct VRDisplay. Used as an
  57426. * association point in the Gamepad API.
  57427. */
  57428. readonly displayId: number;
  57429. /**
  57430. * A display name, a user-readable name identifying it.
  57431. */
  57432. readonly displayName: string;
  57433. readonly isConnected: boolean;
  57434. readonly isPresenting: boolean;
  57435. /**
  57436. * If this VRDisplay supports room-scale experiences, the optional
  57437. * stage attribute contains details on the room-scale parameters.
  57438. */
  57439. readonly stageParameters: VRStageParameters | null;
  57440. /**
  57441. * Passing the value returned by `requestAnimationFrame` to
  57442. * `cancelAnimationFrame` will unregister the callback.
  57443. * @param handle Define the hanle of the request to cancel
  57444. */
  57445. cancelAnimationFrame(handle: number): void;
  57446. /**
  57447. * Stops presenting to the VRDisplay.
  57448. * @returns a promise to know when it stopped
  57449. */
  57450. exitPresent(): Promise<void>;
  57451. /**
  57452. * Return the current VREyeParameters for the given eye.
  57453. * @param whichEye Define the eye we want the parameter for
  57454. * @returns the eye parameters
  57455. */
  57456. getEyeParameters(whichEye: string): VREyeParameters;
  57457. /**
  57458. * Populates the passed VRFrameData with the information required to render
  57459. * the current frame.
  57460. * @param frameData Define the data structure to populate
  57461. * @returns true if ok otherwise false
  57462. */
  57463. getFrameData(frameData: VRFrameData): boolean;
  57464. /**
  57465. * Get the layers currently being presented.
  57466. * @returns the list of VR layers
  57467. */
  57468. getLayers(): VRLayer[];
  57469. /**
  57470. * Return a VRPose containing the future predicted pose of the VRDisplay
  57471. * when the current frame will be presented. The value returned will not
  57472. * change until JavaScript has returned control to the browser.
  57473. *
  57474. * The VRPose will contain the position, orientation, velocity,
  57475. * and acceleration of each of these properties.
  57476. * @returns the pose object
  57477. */
  57478. getPose(): VRPose;
  57479. /**
  57480. * Return the current instantaneous pose of the VRDisplay, with no
  57481. * prediction applied.
  57482. * @returns the current instantaneous pose
  57483. */
  57484. getImmediatePose(): VRPose;
  57485. /**
  57486. * The callback passed to `requestAnimationFrame` will be called
  57487. * any time a new frame should be rendered. When the VRDisplay is
  57488. * presenting the callback will be called at the native refresh
  57489. * rate of the HMD. When not presenting this function acts
  57490. * identically to how window.requestAnimationFrame acts. Content should
  57491. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57492. * asynchronously from other displays and at differing refresh rates.
  57493. * @param callback Define the eaction to run next frame
  57494. * @returns the request handle it
  57495. */
  57496. requestAnimationFrame(callback: FrameRequestCallback): number;
  57497. /**
  57498. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57499. * Repeat calls while already presenting will update the VRLayers being displayed.
  57500. * @param layers Define the list of layer to present
  57501. * @returns a promise to know when the request has been fulfilled
  57502. */
  57503. requestPresent(layers: VRLayer[]): Promise<void>;
  57504. /**
  57505. * Reset the pose for this display, treating its current position and
  57506. * orientation as the "origin/zero" values. VRPose.position,
  57507. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57508. * updated when calling resetPose(). This should be called in only
  57509. * sitting-space experiences.
  57510. */
  57511. resetPose(): void;
  57512. /**
  57513. * The VRLayer provided to the VRDisplay will be captured and presented
  57514. * in the HMD. Calling this function has the same effect on the source
  57515. * canvas as any other operation that uses its source image, and canvases
  57516. * created without preserveDrawingBuffer set to true will be cleared.
  57517. * @param pose Define the pose to submit
  57518. */
  57519. submitFrame(pose?: VRPose): void;
  57520. }
  57521. declare var VRDisplay: {
  57522. prototype: VRDisplay;
  57523. new(): VRDisplay;
  57524. };
  57525. interface VRLayer {
  57526. leftBounds?: number[] | Float32Array | null;
  57527. rightBounds?: number[] | Float32Array | null;
  57528. source?: HTMLCanvasElement | null;
  57529. }
  57530. interface VRDisplayCapabilities {
  57531. readonly canPresent: boolean;
  57532. readonly hasExternalDisplay: boolean;
  57533. readonly hasOrientation: boolean;
  57534. readonly hasPosition: boolean;
  57535. readonly maxLayers: number;
  57536. }
  57537. interface VREyeParameters {
  57538. /** @deprecated */
  57539. readonly fieldOfView: VRFieldOfView;
  57540. readonly offset: Float32Array;
  57541. readonly renderHeight: number;
  57542. readonly renderWidth: number;
  57543. }
  57544. interface VRFieldOfView {
  57545. readonly downDegrees: number;
  57546. readonly leftDegrees: number;
  57547. readonly rightDegrees: number;
  57548. readonly upDegrees: number;
  57549. }
  57550. interface VRFrameData {
  57551. readonly leftProjectionMatrix: Float32Array;
  57552. readonly leftViewMatrix: Float32Array;
  57553. readonly pose: VRPose;
  57554. readonly rightProjectionMatrix: Float32Array;
  57555. readonly rightViewMatrix: Float32Array;
  57556. readonly timestamp: number;
  57557. }
  57558. interface VRPose {
  57559. readonly angularAcceleration: Float32Array | null;
  57560. readonly angularVelocity: Float32Array | null;
  57561. readonly linearAcceleration: Float32Array | null;
  57562. readonly linearVelocity: Float32Array | null;
  57563. readonly orientation: Float32Array | null;
  57564. readonly position: Float32Array | null;
  57565. readonly timestamp: number;
  57566. }
  57567. interface VRStageParameters {
  57568. sittingToStandingTransform?: Float32Array;
  57569. sizeX?: number;
  57570. sizeY?: number;
  57571. }
  57572. interface Navigator {
  57573. getVRDisplays(): Promise<VRDisplay[]>;
  57574. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57575. }
  57576. interface Window {
  57577. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57578. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57579. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57580. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57581. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57582. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57583. }
  57584. interface Gamepad {
  57585. readonly displayId: number;
  57586. }
  57587. interface XRDevice {
  57588. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57589. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57590. }
  57591. interface XRSession {
  57592. getInputSources(): Array<any>;
  57593. baseLayer: XRWebGLLayer;
  57594. requestFrameOfReference(type: string): Promise<void>;
  57595. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57596. end(): Promise<void>;
  57597. requestAnimationFrame: Function;
  57598. addEventListener: Function;
  57599. }
  57600. interface XRSessionCreationOptions {
  57601. outputContext?: WebGLRenderingContext | null;
  57602. immersive?: boolean;
  57603. environmentIntegration?: boolean;
  57604. }
  57605. interface XRLayer {
  57606. getViewport: Function;
  57607. framebufferWidth: number;
  57608. framebufferHeight: number;
  57609. }
  57610. interface XRView {
  57611. projectionMatrix: Float32Array;
  57612. }
  57613. interface XRFrame {
  57614. getDevicePose: Function;
  57615. getInputPose: Function;
  57616. views: Array<XRView>;
  57617. baseLayer: XRLayer;
  57618. }
  57619. interface XRFrameOfReference {
  57620. }
  57621. interface XRWebGLLayer extends XRLayer {
  57622. framebuffer: WebGLFramebuffer;
  57623. }
  57624. declare var XRWebGLLayer: {
  57625. prototype: XRWebGLLayer;
  57626. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57627. };
  57628. declare module "babylonjs" {
  57629. export * from "babylonjs/Legacy/legacy";
  57630. }
  57631. declare module BABYLON {
  57632. /** Alias type for value that can be null */
  57633. export type Nullable<T> = T | null;
  57634. /**
  57635. * Alias type for number that are floats
  57636. * @ignorenaming
  57637. */
  57638. export type float = number;
  57639. /**
  57640. * Alias type for number that are doubles.
  57641. * @ignorenaming
  57642. */
  57643. export type double = number;
  57644. /**
  57645. * Alias type for number that are integer
  57646. * @ignorenaming
  57647. */
  57648. export type int = number;
  57649. /** Alias type for number array or Float32Array */
  57650. export type FloatArray = number[] | Float32Array;
  57651. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  57652. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  57653. /**
  57654. * Alias for types that can be used by a Buffer or VertexBuffer.
  57655. */
  57656. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  57657. /**
  57658. * Alias type for primitive types
  57659. * @ignorenaming
  57660. */
  57661. type Primitive = undefined | null | boolean | string | number | Function;
  57662. /**
  57663. * Type modifier to make all the properties of an object Readonly
  57664. */
  57665. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  57666. /**
  57667. * Type modifier to make all the properties of an object Readonly recursively
  57668. */
  57669. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  57670. /** @hidden */
  57671. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  57672. }
  57673. /** @hidden */
  57674. /** @hidden */
  57675. type DeepImmutableObject<T> = {
  57676. readonly [K in keyof T]: DeepImmutable<T[K]>;
  57677. };
  57678. }
  57679. declare module BABYLON {
  57680. /**
  57681. * Class containing a set of static utilities functions for arrays.
  57682. */
  57683. export class ArrayTools {
  57684. /**
  57685. * Returns an array of the given size filled with element built from the given constructor and the paramters
  57686. * @param size the number of element to construct and put in the array
  57687. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  57688. * @returns a new array filled with new objects
  57689. */
  57690. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  57691. }
  57692. }
  57693. declare module BABYLON {
  57694. /**
  57695. * Scalar computation library
  57696. */
  57697. export class Scalar {
  57698. /**
  57699. * Two pi constants convenient for computation.
  57700. */
  57701. static TwoPi: number;
  57702. /**
  57703. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57704. * @param a number
  57705. * @param b number
  57706. * @param epsilon (default = 1.401298E-45)
  57707. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  57708. */
  57709. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  57710. /**
  57711. * Returns a string : the upper case translation of the number i to hexadecimal.
  57712. * @param i number
  57713. * @returns the upper case translation of the number i to hexadecimal.
  57714. */
  57715. static ToHex(i: number): string;
  57716. /**
  57717. * Returns -1 if value is negative and +1 is value is positive.
  57718. * @param value the value
  57719. * @returns the value itself if it's equal to zero.
  57720. */
  57721. static Sign(value: number): number;
  57722. /**
  57723. * Returns the value itself if it's between min and max.
  57724. * Returns min if the value is lower than min.
  57725. * Returns max if the value is greater than max.
  57726. * @param value the value to clmap
  57727. * @param min the min value to clamp to (default: 0)
  57728. * @param max the max value to clamp to (default: 1)
  57729. * @returns the clamped value
  57730. */
  57731. static Clamp(value: number, min?: number, max?: number): number;
  57732. /**
  57733. * the log2 of value.
  57734. * @param value the value to compute log2 of
  57735. * @returns the log2 of value.
  57736. */
  57737. static Log2(value: number): number;
  57738. /**
  57739. * Loops the value, so that it is never larger than length and never smaller than 0.
  57740. *
  57741. * This is similar to the modulo operator but it works with floating point numbers.
  57742. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  57743. * With t = 5 and length = 2.5, the result would be 0.0.
  57744. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  57745. * @param value the value
  57746. * @param length the length
  57747. * @returns the looped value
  57748. */
  57749. static Repeat(value: number, length: number): number;
  57750. /**
  57751. * Normalize the value between 0.0 and 1.0 using min and max values
  57752. * @param value value to normalize
  57753. * @param min max to normalize between
  57754. * @param max min to normalize between
  57755. * @returns the normalized value
  57756. */
  57757. static Normalize(value: number, min: number, max: number): number;
  57758. /**
  57759. * Denormalize the value from 0.0 and 1.0 using min and max values
  57760. * @param normalized value to denormalize
  57761. * @param min max to denormalize between
  57762. * @param max min to denormalize between
  57763. * @returns the denormalized value
  57764. */
  57765. static Denormalize(normalized: number, min: number, max: number): number;
  57766. /**
  57767. * Calculates the shortest difference between two given angles given in degrees.
  57768. * @param current current angle in degrees
  57769. * @param target target angle in degrees
  57770. * @returns the delta
  57771. */
  57772. static DeltaAngle(current: number, target: number): number;
  57773. /**
  57774. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  57775. * @param tx value
  57776. * @param length length
  57777. * @returns The returned value will move back and forth between 0 and length
  57778. */
  57779. static PingPong(tx: number, length: number): number;
  57780. /**
  57781. * Interpolates between min and max with smoothing at the limits.
  57782. *
  57783. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  57784. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  57785. * @param from from
  57786. * @param to to
  57787. * @param tx value
  57788. * @returns the smooth stepped value
  57789. */
  57790. static SmoothStep(from: number, to: number, tx: number): number;
  57791. /**
  57792. * Moves a value current towards target.
  57793. *
  57794. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  57795. * Negative values of maxDelta pushes the value away from target.
  57796. * @param current current value
  57797. * @param target target value
  57798. * @param maxDelta max distance to move
  57799. * @returns resulting value
  57800. */
  57801. static MoveTowards(current: number, target: number, maxDelta: number): number;
  57802. /**
  57803. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57804. *
  57805. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  57806. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  57807. * @param current current value
  57808. * @param target target value
  57809. * @param maxDelta max distance to move
  57810. * @returns resulting angle
  57811. */
  57812. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  57813. /**
  57814. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  57815. * @param start start value
  57816. * @param end target value
  57817. * @param amount amount to lerp between
  57818. * @returns the lerped value
  57819. */
  57820. static Lerp(start: number, end: number, amount: number): number;
  57821. /**
  57822. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  57823. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  57824. * @param start start value
  57825. * @param end target value
  57826. * @param amount amount to lerp between
  57827. * @returns the lerped value
  57828. */
  57829. static LerpAngle(start: number, end: number, amount: number): number;
  57830. /**
  57831. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  57832. * @param a start value
  57833. * @param b target value
  57834. * @param value value between a and b
  57835. * @returns the inverseLerp value
  57836. */
  57837. static InverseLerp(a: number, b: number, value: number): number;
  57838. /**
  57839. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  57840. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  57841. * @param value1 spline value
  57842. * @param tangent1 spline value
  57843. * @param value2 spline value
  57844. * @param tangent2 spline value
  57845. * @param amount input value
  57846. * @returns hermite result
  57847. */
  57848. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  57849. /**
  57850. * Returns a random float number between and min and max values
  57851. * @param min min value of random
  57852. * @param max max value of random
  57853. * @returns random value
  57854. */
  57855. static RandomRange(min: number, max: number): number;
  57856. /**
  57857. * This function returns percentage of a number in a given range.
  57858. *
  57859. * RangeToPercent(40,20,60) will return 0.5 (50%)
  57860. * RangeToPercent(34,0,100) will return 0.34 (34%)
  57861. * @param number to convert to percentage
  57862. * @param min min range
  57863. * @param max max range
  57864. * @returns the percentage
  57865. */
  57866. static RangeToPercent(number: number, min: number, max: number): number;
  57867. /**
  57868. * This function returns number that corresponds to the percentage in a given range.
  57869. *
  57870. * PercentToRange(0.34,0,100) will return 34.
  57871. * @param percent to convert to number
  57872. * @param min min range
  57873. * @param max max range
  57874. * @returns the number
  57875. */
  57876. static PercentToRange(percent: number, min: number, max: number): number;
  57877. /**
  57878. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  57879. * @param angle The angle to normalize in radian.
  57880. * @return The converted angle.
  57881. */
  57882. static NormalizeRadians(angle: number): number;
  57883. }
  57884. }
  57885. declare module BABYLON {
  57886. /**
  57887. * Constant used to convert a value to gamma space
  57888. * @ignorenaming
  57889. */
  57890. export const ToGammaSpace: number;
  57891. /**
  57892. * Constant used to convert a value to linear space
  57893. * @ignorenaming
  57894. */
  57895. export const ToLinearSpace = 2.2;
  57896. /**
  57897. * Constant used to define the minimal number value in Babylon.js
  57898. * @ignorenaming
  57899. */
  57900. export const Epsilon = 0.001;
  57901. /**
  57902. * Class used to hold a RBG color
  57903. */
  57904. export class Color3 {
  57905. /**
  57906. * Defines the red component (between 0 and 1, default is 0)
  57907. */
  57908. r: number;
  57909. /**
  57910. * Defines the green component (between 0 and 1, default is 0)
  57911. */
  57912. g: number;
  57913. /**
  57914. * Defines the blue component (between 0 and 1, default is 0)
  57915. */
  57916. b: number;
  57917. /**
  57918. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  57919. * @param r defines the red component (between 0 and 1, default is 0)
  57920. * @param g defines the green component (between 0 and 1, default is 0)
  57921. * @param b defines the blue component (between 0 and 1, default is 0)
  57922. */
  57923. constructor(
  57924. /**
  57925. * Defines the red component (between 0 and 1, default is 0)
  57926. */
  57927. r?: number,
  57928. /**
  57929. * Defines the green component (between 0 and 1, default is 0)
  57930. */
  57931. g?: number,
  57932. /**
  57933. * Defines the blue component (between 0 and 1, default is 0)
  57934. */
  57935. b?: number);
  57936. /**
  57937. * Creates a string with the Color3 current values
  57938. * @returns the string representation of the Color3 object
  57939. */
  57940. toString(): string;
  57941. /**
  57942. * Returns the string "Color3"
  57943. * @returns "Color3"
  57944. */
  57945. getClassName(): string;
  57946. /**
  57947. * Compute the Color3 hash code
  57948. * @returns an unique number that can be used to hash Color3 objects
  57949. */
  57950. getHashCode(): number;
  57951. /**
  57952. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  57953. * @param array defines the array where to store the r,g,b components
  57954. * @param index defines an optional index in the target array to define where to start storing values
  57955. * @returns the current Color3 object
  57956. */
  57957. toArray(array: FloatArray, index?: number): Color3;
  57958. /**
  57959. * Returns a new Color4 object from the current Color3 and the given alpha
  57960. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  57961. * @returns a new Color4 object
  57962. */
  57963. toColor4(alpha?: number): Color4;
  57964. /**
  57965. * Returns a new array populated with 3 numeric elements : red, green and blue values
  57966. * @returns the new array
  57967. */
  57968. asArray(): number[];
  57969. /**
  57970. * Returns the luminance value
  57971. * @returns a float value
  57972. */
  57973. toLuminance(): number;
  57974. /**
  57975. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  57976. * @param otherColor defines the second operand
  57977. * @returns the new Color3 object
  57978. */
  57979. multiply(otherColor: DeepImmutable<Color3>): Color3;
  57980. /**
  57981. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  57982. * @param otherColor defines the second operand
  57983. * @param result defines the Color3 object where to store the result
  57984. * @returns the current Color3
  57985. */
  57986. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  57987. /**
  57988. * Determines equality between Color3 objects
  57989. * @param otherColor defines the second operand
  57990. * @returns true if the rgb values are equal to the given ones
  57991. */
  57992. equals(otherColor: DeepImmutable<Color3>): boolean;
  57993. /**
  57994. * Determines equality between the current Color3 object and a set of r,b,g values
  57995. * @param r defines the red component to check
  57996. * @param g defines the green component to check
  57997. * @param b defines the blue component to check
  57998. * @returns true if the rgb values are equal to the given ones
  57999. */
  58000. equalsFloats(r: number, g: number, b: number): boolean;
  58001. /**
  58002. * Multiplies in place each rgb value by scale
  58003. * @param scale defines the scaling factor
  58004. * @returns the updated Color3
  58005. */
  58006. scale(scale: number): Color3;
  58007. /**
  58008. * Multiplies the rgb values by scale and stores the result into "result"
  58009. * @param scale defines the scaling factor
  58010. * @param result defines the Color3 object where to store the result
  58011. * @returns the unmodified current Color3
  58012. */
  58013. scaleToRef(scale: number, result: Color3): Color3;
  58014. /**
  58015. * Scale the current Color3 values by a factor and add the result to a given Color3
  58016. * @param scale defines the scale factor
  58017. * @param result defines color to store the result into
  58018. * @returns the unmodified current Color3
  58019. */
  58020. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58021. /**
  58022. * Clamps the rgb values by the min and max values and stores the result into "result"
  58023. * @param min defines minimum clamping value (default is 0)
  58024. * @param max defines maximum clamping value (default is 1)
  58025. * @param result defines color to store the result into
  58026. * @returns the original Color3
  58027. */
  58028. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58029. /**
  58030. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58031. * @param otherColor defines the second operand
  58032. * @returns the new Color3
  58033. */
  58034. add(otherColor: DeepImmutable<Color3>): Color3;
  58035. /**
  58036. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58037. * @param otherColor defines the second operand
  58038. * @param result defines Color3 object to store the result into
  58039. * @returns the unmodified current Color3
  58040. */
  58041. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58042. /**
  58043. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58044. * @param otherColor defines the second operand
  58045. * @returns the new Color3
  58046. */
  58047. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58048. /**
  58049. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58050. * @param otherColor defines the second operand
  58051. * @param result defines Color3 object to store the result into
  58052. * @returns the unmodified current Color3
  58053. */
  58054. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58055. /**
  58056. * Copy the current object
  58057. * @returns a new Color3 copied the current one
  58058. */
  58059. clone(): Color3;
  58060. /**
  58061. * Copies the rgb values from the source in the current Color3
  58062. * @param source defines the source Color3 object
  58063. * @returns the updated Color3 object
  58064. */
  58065. copyFrom(source: DeepImmutable<Color3>): Color3;
  58066. /**
  58067. * Updates the Color3 rgb values from the given floats
  58068. * @param r defines the red component to read from
  58069. * @param g defines the green component to read from
  58070. * @param b defines the blue component to read from
  58071. * @returns the current Color3 object
  58072. */
  58073. copyFromFloats(r: number, g: number, b: number): Color3;
  58074. /**
  58075. * Updates the Color3 rgb values from the given floats
  58076. * @param r defines the red component to read from
  58077. * @param g defines the green component to read from
  58078. * @param b defines the blue component to read from
  58079. * @returns the current Color3 object
  58080. */
  58081. set(r: number, g: number, b: number): Color3;
  58082. /**
  58083. * Compute the Color3 hexadecimal code as a string
  58084. * @returns a string containing the hexadecimal representation of the Color3 object
  58085. */
  58086. toHexString(): string;
  58087. /**
  58088. * Computes a new Color3 converted from the current one to linear space
  58089. * @returns a new Color3 object
  58090. */
  58091. toLinearSpace(): Color3;
  58092. /**
  58093. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58094. * @param convertedColor defines the Color3 object where to store the linear space version
  58095. * @returns the unmodified Color3
  58096. */
  58097. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58098. /**
  58099. * Computes a new Color3 converted from the current one to gamma space
  58100. * @returns a new Color3 object
  58101. */
  58102. toGammaSpace(): Color3;
  58103. /**
  58104. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58105. * @param convertedColor defines the Color3 object where to store the gamma space version
  58106. * @returns the unmodified Color3
  58107. */
  58108. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58109. private static _BlackReadOnly;
  58110. /**
  58111. * Creates a new Color3 from the string containing valid hexadecimal values
  58112. * @param hex defines a string containing valid hexadecimal values
  58113. * @returns a new Color3 object
  58114. */
  58115. static FromHexString(hex: string): Color3;
  58116. /**
  58117. * Creates a new Vector3 from the starting index of the given array
  58118. * @param array defines the source array
  58119. * @param offset defines an offset in the source array
  58120. * @returns a new Color3 object
  58121. */
  58122. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58123. /**
  58124. * Creates a new Color3 from integer values (< 256)
  58125. * @param r defines the red component to read from (value between 0 and 255)
  58126. * @param g defines the green component to read from (value between 0 and 255)
  58127. * @param b defines the blue component to read from (value between 0 and 255)
  58128. * @returns a new Color3 object
  58129. */
  58130. static FromInts(r: number, g: number, b: number): Color3;
  58131. /**
  58132. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58133. * @param start defines the start Color3 value
  58134. * @param end defines the end Color3 value
  58135. * @param amount defines the gradient value between start and end
  58136. * @returns a new Color3 object
  58137. */
  58138. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58139. /**
  58140. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58141. * @param left defines the start value
  58142. * @param right defines the end value
  58143. * @param amount defines the gradient factor
  58144. * @param result defines the Color3 object where to store the result
  58145. */
  58146. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58147. /**
  58148. * Returns a Color3 value containing a red color
  58149. * @returns a new Color3 object
  58150. */
  58151. static Red(): Color3;
  58152. /**
  58153. * Returns a Color3 value containing a green color
  58154. * @returns a new Color3 object
  58155. */
  58156. static Green(): Color3;
  58157. /**
  58158. * Returns a Color3 value containing a blue color
  58159. * @returns a new Color3 object
  58160. */
  58161. static Blue(): Color3;
  58162. /**
  58163. * Returns a Color3 value containing a black color
  58164. * @returns a new Color3 object
  58165. */
  58166. static Black(): Color3;
  58167. /**
  58168. * Gets a Color3 value containing a black color that must not be updated
  58169. */
  58170. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58171. /**
  58172. * Returns a Color3 value containing a white color
  58173. * @returns a new Color3 object
  58174. */
  58175. static White(): Color3;
  58176. /**
  58177. * Returns a Color3 value containing a purple color
  58178. * @returns a new Color3 object
  58179. */
  58180. static Purple(): Color3;
  58181. /**
  58182. * Returns a Color3 value containing a magenta color
  58183. * @returns a new Color3 object
  58184. */
  58185. static Magenta(): Color3;
  58186. /**
  58187. * Returns a Color3 value containing a yellow color
  58188. * @returns a new Color3 object
  58189. */
  58190. static Yellow(): Color3;
  58191. /**
  58192. * Returns a Color3 value containing a gray color
  58193. * @returns a new Color3 object
  58194. */
  58195. static Gray(): Color3;
  58196. /**
  58197. * Returns a Color3 value containing a teal color
  58198. * @returns a new Color3 object
  58199. */
  58200. static Teal(): Color3;
  58201. /**
  58202. * Returns a Color3 value containing a random color
  58203. * @returns a new Color3 object
  58204. */
  58205. static Random(): Color3;
  58206. }
  58207. /**
  58208. * Class used to hold a RBGA color
  58209. */
  58210. export class Color4 {
  58211. /**
  58212. * Defines the red component (between 0 and 1, default is 0)
  58213. */
  58214. r: number;
  58215. /**
  58216. * Defines the green component (between 0 and 1, default is 0)
  58217. */
  58218. g: number;
  58219. /**
  58220. * Defines the blue component (between 0 and 1, default is 0)
  58221. */
  58222. b: number;
  58223. /**
  58224. * Defines the alpha component (between 0 and 1, default is 1)
  58225. */
  58226. a: number;
  58227. /**
  58228. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58229. * @param r defines the red component (between 0 and 1, default is 0)
  58230. * @param g defines the green component (between 0 and 1, default is 0)
  58231. * @param b defines the blue component (between 0 and 1, default is 0)
  58232. * @param a defines the alpha component (between 0 and 1, default is 1)
  58233. */
  58234. constructor(
  58235. /**
  58236. * Defines the red component (between 0 and 1, default is 0)
  58237. */
  58238. r?: number,
  58239. /**
  58240. * Defines the green component (between 0 and 1, default is 0)
  58241. */
  58242. g?: number,
  58243. /**
  58244. * Defines the blue component (between 0 and 1, default is 0)
  58245. */
  58246. b?: number,
  58247. /**
  58248. * Defines the alpha component (between 0 and 1, default is 1)
  58249. */
  58250. a?: number);
  58251. /**
  58252. * Adds in place the given Color4 values to the current Color4 object
  58253. * @param right defines the second operand
  58254. * @returns the current updated Color4 object
  58255. */
  58256. addInPlace(right: DeepImmutable<Color4>): Color4;
  58257. /**
  58258. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58259. * @returns the new array
  58260. */
  58261. asArray(): number[];
  58262. /**
  58263. * Stores from the starting index in the given array the Color4 successive values
  58264. * @param array defines the array where to store the r,g,b components
  58265. * @param index defines an optional index in the target array to define where to start storing values
  58266. * @returns the current Color4 object
  58267. */
  58268. toArray(array: number[], index?: number): Color4;
  58269. /**
  58270. * Determines equality between Color4 objects
  58271. * @param otherColor defines the second operand
  58272. * @returns true if the rgba values are equal to the given ones
  58273. */
  58274. equals(otherColor: DeepImmutable<Color4>): boolean;
  58275. /**
  58276. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  58277. * @param right defines the second operand
  58278. * @returns a new Color4 object
  58279. */
  58280. add(right: DeepImmutable<Color4>): Color4;
  58281. /**
  58282. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  58283. * @param right defines the second operand
  58284. * @returns a new Color4 object
  58285. */
  58286. subtract(right: DeepImmutable<Color4>): Color4;
  58287. /**
  58288. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  58289. * @param right defines the second operand
  58290. * @param result defines the Color4 object where to store the result
  58291. * @returns the current Color4 object
  58292. */
  58293. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  58294. /**
  58295. * Creates a new Color4 with the current Color4 values multiplied by scale
  58296. * @param scale defines the scaling factor to apply
  58297. * @returns a new Color4 object
  58298. */
  58299. scale(scale: number): Color4;
  58300. /**
  58301. * Multiplies the current Color4 values by scale and stores the result in "result"
  58302. * @param scale defines the scaling factor to apply
  58303. * @param result defines the Color4 object where to store the result
  58304. * @returns the current unmodified Color4
  58305. */
  58306. scaleToRef(scale: number, result: Color4): Color4;
  58307. /**
  58308. * Scale the current Color4 values by a factor and add the result to a given Color4
  58309. * @param scale defines the scale factor
  58310. * @param result defines the Color4 object where to store the result
  58311. * @returns the unmodified current Color4
  58312. */
  58313. scaleAndAddToRef(scale: number, result: Color4): Color4;
  58314. /**
  58315. * Clamps the rgb values by the min and max values and stores the result into "result"
  58316. * @param min defines minimum clamping value (default is 0)
  58317. * @param max defines maximum clamping value (default is 1)
  58318. * @param result defines color to store the result into.
  58319. * @returns the cuurent Color4
  58320. */
  58321. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  58322. /**
  58323. * Multipy an Color4 value by another and return a new Color4 object
  58324. * @param color defines the Color4 value to multiply by
  58325. * @returns a new Color4 object
  58326. */
  58327. multiply(color: Color4): Color4;
  58328. /**
  58329. * Multipy a Color4 value by another and push the result in a reference value
  58330. * @param color defines the Color4 value to multiply by
  58331. * @param result defines the Color4 to fill the result in
  58332. * @returns the result Color4
  58333. */
  58334. multiplyToRef(color: Color4, result: Color4): Color4;
  58335. /**
  58336. * Creates a string with the Color4 current values
  58337. * @returns the string representation of the Color4 object
  58338. */
  58339. toString(): string;
  58340. /**
  58341. * Returns the string "Color4"
  58342. * @returns "Color4"
  58343. */
  58344. getClassName(): string;
  58345. /**
  58346. * Compute the Color4 hash code
  58347. * @returns an unique number that can be used to hash Color4 objects
  58348. */
  58349. getHashCode(): number;
  58350. /**
  58351. * Creates a new Color4 copied from the current one
  58352. * @returns a new Color4 object
  58353. */
  58354. clone(): Color4;
  58355. /**
  58356. * Copies the given Color4 values into the current one
  58357. * @param source defines the source Color4 object
  58358. * @returns the current updated Color4 object
  58359. */
  58360. copyFrom(source: Color4): Color4;
  58361. /**
  58362. * Copies the given float values into the current one
  58363. * @param r defines the red component to read from
  58364. * @param g defines the green component to read from
  58365. * @param b defines the blue component to read from
  58366. * @param a defines the alpha component to read from
  58367. * @returns the current updated Color4 object
  58368. */
  58369. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  58370. /**
  58371. * Copies the given float values into the current one
  58372. * @param r defines the red component to read from
  58373. * @param g defines the green component to read from
  58374. * @param b defines the blue component to read from
  58375. * @param a defines the alpha component to read from
  58376. * @returns the current updated Color4 object
  58377. */
  58378. set(r: number, g: number, b: number, a: number): Color4;
  58379. /**
  58380. * Compute the Color4 hexadecimal code as a string
  58381. * @returns a string containing the hexadecimal representation of the Color4 object
  58382. */
  58383. toHexString(): string;
  58384. /**
  58385. * Computes a new Color4 converted from the current one to linear space
  58386. * @returns a new Color4 object
  58387. */
  58388. toLinearSpace(): Color4;
  58389. /**
  58390. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  58391. * @param convertedColor defines the Color4 object where to store the linear space version
  58392. * @returns the unmodified Color4
  58393. */
  58394. toLinearSpaceToRef(convertedColor: Color4): Color4;
  58395. /**
  58396. * Computes a new Color4 converted from the current one to gamma space
  58397. * @returns a new Color4 object
  58398. */
  58399. toGammaSpace(): Color4;
  58400. /**
  58401. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  58402. * @param convertedColor defines the Color4 object where to store the gamma space version
  58403. * @returns the unmodified Color4
  58404. */
  58405. toGammaSpaceToRef(convertedColor: Color4): Color4;
  58406. /**
  58407. * Creates a new Color4 from the string containing valid hexadecimal values
  58408. * @param hex defines a string containing valid hexadecimal values
  58409. * @returns a new Color4 object
  58410. */
  58411. static FromHexString(hex: string): Color4;
  58412. /**
  58413. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58414. * @param left defines the start value
  58415. * @param right defines the end value
  58416. * @param amount defines the gradient factor
  58417. * @returns a new Color4 object
  58418. */
  58419. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  58420. /**
  58421. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  58422. * @param left defines the start value
  58423. * @param right defines the end value
  58424. * @param amount defines the gradient factor
  58425. * @param result defines the Color4 object where to store data
  58426. */
  58427. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  58428. /**
  58429. * Creates a new Color4 from a Color3 and an alpha value
  58430. * @param color3 defines the source Color3 to read from
  58431. * @param alpha defines the alpha component (1.0 by default)
  58432. * @returns a new Color4 object
  58433. */
  58434. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  58435. /**
  58436. * Creates a new Color4 from the starting index element of the given array
  58437. * @param array defines the source array to read from
  58438. * @param offset defines the offset in the source array
  58439. * @returns a new Color4 object
  58440. */
  58441. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  58442. /**
  58443. * Creates a new Color3 from integer values (< 256)
  58444. * @param r defines the red component to read from (value between 0 and 255)
  58445. * @param g defines the green component to read from (value between 0 and 255)
  58446. * @param b defines the blue component to read from (value between 0 and 255)
  58447. * @param a defines the alpha component to read from (value between 0 and 255)
  58448. * @returns a new Color3 object
  58449. */
  58450. static FromInts(r: number, g: number, b: number, a: number): Color4;
  58451. /**
  58452. * Check the content of a given array and convert it to an array containing RGBA data
  58453. * If the original array was already containing count * 4 values then it is returned directly
  58454. * @param colors defines the array to check
  58455. * @param count defines the number of RGBA data to expect
  58456. * @returns an array containing count * 4 values (RGBA)
  58457. */
  58458. static CheckColors4(colors: number[], count: number): number[];
  58459. }
  58460. /**
  58461. * Class representing a vector containing 2 coordinates
  58462. */
  58463. export class Vector2 {
  58464. /** defines the first coordinate */
  58465. x: number;
  58466. /** defines the second coordinate */
  58467. y: number;
  58468. /**
  58469. * Creates a new Vector2 from the given x and y coordinates
  58470. * @param x defines the first coordinate
  58471. * @param y defines the second coordinate
  58472. */
  58473. constructor(
  58474. /** defines the first coordinate */
  58475. x?: number,
  58476. /** defines the second coordinate */
  58477. y?: number);
  58478. /**
  58479. * Gets a string with the Vector2 coordinates
  58480. * @returns a string with the Vector2 coordinates
  58481. */
  58482. toString(): string;
  58483. /**
  58484. * Gets class name
  58485. * @returns the string "Vector2"
  58486. */
  58487. getClassName(): string;
  58488. /**
  58489. * Gets current vector hash code
  58490. * @returns the Vector2 hash code as a number
  58491. */
  58492. getHashCode(): number;
  58493. /**
  58494. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  58495. * @param array defines the source array
  58496. * @param index defines the offset in source array
  58497. * @returns the current Vector2
  58498. */
  58499. toArray(array: FloatArray, index?: number): Vector2;
  58500. /**
  58501. * Copy the current vector to an array
  58502. * @returns a new array with 2 elements: the Vector2 coordinates.
  58503. */
  58504. asArray(): number[];
  58505. /**
  58506. * Sets the Vector2 coordinates with the given Vector2 coordinates
  58507. * @param source defines the source Vector2
  58508. * @returns the current updated Vector2
  58509. */
  58510. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  58511. /**
  58512. * Sets the Vector2 coordinates with the given floats
  58513. * @param x defines the first coordinate
  58514. * @param y defines the second coordinate
  58515. * @returns the current updated Vector2
  58516. */
  58517. copyFromFloats(x: number, y: number): Vector2;
  58518. /**
  58519. * Sets the Vector2 coordinates with the given floats
  58520. * @param x defines the first coordinate
  58521. * @param y defines the second coordinate
  58522. * @returns the current updated Vector2
  58523. */
  58524. set(x: number, y: number): Vector2;
  58525. /**
  58526. * Add another vector with the current one
  58527. * @param otherVector defines the other vector
  58528. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  58529. */
  58530. add(otherVector: DeepImmutable<Vector2>): Vector2;
  58531. /**
  58532. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  58533. * @param otherVector defines the other vector
  58534. * @param result defines the target vector
  58535. * @returns the unmodified current Vector2
  58536. */
  58537. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58538. /**
  58539. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  58540. * @param otherVector defines the other vector
  58541. * @returns the current updated Vector2
  58542. */
  58543. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58544. /**
  58545. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  58546. * @param otherVector defines the other vector
  58547. * @returns a new Vector2
  58548. */
  58549. addVector3(otherVector: Vector3): Vector2;
  58550. /**
  58551. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  58552. * @param otherVector defines the other vector
  58553. * @returns a new Vector2
  58554. */
  58555. subtract(otherVector: Vector2): Vector2;
  58556. /**
  58557. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  58558. * @param otherVector defines the other vector
  58559. * @param result defines the target vector
  58560. * @returns the unmodified current Vector2
  58561. */
  58562. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58563. /**
  58564. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  58565. * @param otherVector defines the other vector
  58566. * @returns the current updated Vector2
  58567. */
  58568. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58569. /**
  58570. * Multiplies in place the current Vector2 coordinates by the given ones
  58571. * @param otherVector defines the other vector
  58572. * @returns the current updated Vector2
  58573. */
  58574. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58575. /**
  58576. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  58577. * @param otherVector defines the other vector
  58578. * @returns a new Vector2
  58579. */
  58580. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  58581. /**
  58582. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  58583. * @param otherVector defines the other vector
  58584. * @param result defines the target vector
  58585. * @returns the unmodified current Vector2
  58586. */
  58587. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58588. /**
  58589. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  58590. * @param x defines the first coordinate
  58591. * @param y defines the second coordinate
  58592. * @returns a new Vector2
  58593. */
  58594. multiplyByFloats(x: number, y: number): Vector2;
  58595. /**
  58596. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  58597. * @param otherVector defines the other vector
  58598. * @returns a new Vector2
  58599. */
  58600. divide(otherVector: Vector2): Vector2;
  58601. /**
  58602. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  58603. * @param otherVector defines the other vector
  58604. * @param result defines the target vector
  58605. * @returns the unmodified current Vector2
  58606. */
  58607. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  58608. /**
  58609. * Divides the current Vector2 coordinates by the given ones
  58610. * @param otherVector defines the other vector
  58611. * @returns the current updated Vector2
  58612. */
  58613. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  58614. /**
  58615. * Gets a new Vector2 with current Vector2 negated coordinates
  58616. * @returns a new Vector2
  58617. */
  58618. negate(): Vector2;
  58619. /**
  58620. * Multiply the Vector2 coordinates by scale
  58621. * @param scale defines the scaling factor
  58622. * @returns the current updated Vector2
  58623. */
  58624. scaleInPlace(scale: number): Vector2;
  58625. /**
  58626. * Returns a new Vector2 scaled by "scale" from the current Vector2
  58627. * @param scale defines the scaling factor
  58628. * @returns a new Vector2
  58629. */
  58630. scale(scale: number): Vector2;
  58631. /**
  58632. * Scale the current Vector2 values by a factor to a given Vector2
  58633. * @param scale defines the scale factor
  58634. * @param result defines the Vector2 object where to store the result
  58635. * @returns the unmodified current Vector2
  58636. */
  58637. scaleToRef(scale: number, result: Vector2): Vector2;
  58638. /**
  58639. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  58640. * @param scale defines the scale factor
  58641. * @param result defines the Vector2 object where to store the result
  58642. * @returns the unmodified current Vector2
  58643. */
  58644. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  58645. /**
  58646. * Gets a boolean if two vectors are equals
  58647. * @param otherVector defines the other vector
  58648. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  58649. */
  58650. equals(otherVector: DeepImmutable<Vector2>): boolean;
  58651. /**
  58652. * Gets a boolean if two vectors are equals (using an epsilon value)
  58653. * @param otherVector defines the other vector
  58654. * @param epsilon defines the minimal distance to consider equality
  58655. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  58656. */
  58657. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  58658. /**
  58659. * Gets a new Vector2 from current Vector2 floored values
  58660. * @returns a new Vector2
  58661. */
  58662. floor(): Vector2;
  58663. /**
  58664. * Gets a new Vector2 from current Vector2 floored values
  58665. * @returns a new Vector2
  58666. */
  58667. fract(): Vector2;
  58668. /**
  58669. * Gets the length of the vector
  58670. * @returns the vector length (float)
  58671. */
  58672. length(): number;
  58673. /**
  58674. * Gets the vector squared length
  58675. * @returns the vector squared length (float)
  58676. */
  58677. lengthSquared(): number;
  58678. /**
  58679. * Normalize the vector
  58680. * @returns the current updated Vector2
  58681. */
  58682. normalize(): Vector2;
  58683. /**
  58684. * Gets a new Vector2 copied from the Vector2
  58685. * @returns a new Vector2
  58686. */
  58687. clone(): Vector2;
  58688. /**
  58689. * Gets a new Vector2(0, 0)
  58690. * @returns a new Vector2
  58691. */
  58692. static Zero(): Vector2;
  58693. /**
  58694. * Gets a new Vector2(1, 1)
  58695. * @returns a new Vector2
  58696. */
  58697. static One(): Vector2;
  58698. /**
  58699. * Gets a new Vector2 set from the given index element of the given array
  58700. * @param array defines the data source
  58701. * @param offset defines the offset in the data source
  58702. * @returns a new Vector2
  58703. */
  58704. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  58705. /**
  58706. * Sets "result" from the given index element of the given array
  58707. * @param array defines the data source
  58708. * @param offset defines the offset in the data source
  58709. * @param result defines the target vector
  58710. */
  58711. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  58712. /**
  58713. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  58714. * @param value1 defines 1st point of control
  58715. * @param value2 defines 2nd point of control
  58716. * @param value3 defines 3rd point of control
  58717. * @param value4 defines 4th point of control
  58718. * @param amount defines the interpolation factor
  58719. * @returns a new Vector2
  58720. */
  58721. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  58722. /**
  58723. * 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".
  58724. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  58725. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  58726. * @param value defines the value to clamp
  58727. * @param min defines the lower limit
  58728. * @param max defines the upper limit
  58729. * @returns a new Vector2
  58730. */
  58731. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  58732. /**
  58733. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  58734. * @param value1 defines the 1st control point
  58735. * @param tangent1 defines the outgoing tangent
  58736. * @param value2 defines the 2nd control point
  58737. * @param tangent2 defines the incoming tangent
  58738. * @param amount defines the interpolation factor
  58739. * @returns a new Vector2
  58740. */
  58741. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  58742. /**
  58743. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  58744. * @param start defines the start vector
  58745. * @param end defines the end vector
  58746. * @param amount defines the interpolation factor
  58747. * @returns a new Vector2
  58748. */
  58749. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  58750. /**
  58751. * Gets the dot product of the vector "left" and the vector "right"
  58752. * @param left defines first vector
  58753. * @param right defines second vector
  58754. * @returns the dot product (float)
  58755. */
  58756. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  58757. /**
  58758. * Returns a new Vector2 equal to the normalized given vector
  58759. * @param vector defines the vector to normalize
  58760. * @returns a new Vector2
  58761. */
  58762. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  58763. /**
  58764. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  58765. * @param left defines 1st vector
  58766. * @param right defines 2nd vector
  58767. * @returns a new Vector2
  58768. */
  58769. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58770. /**
  58771. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  58772. * @param left defines 1st vector
  58773. * @param right defines 2nd vector
  58774. * @returns a new Vector2
  58775. */
  58776. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  58777. /**
  58778. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  58779. * @param vector defines the vector to transform
  58780. * @param transformation defines the matrix to apply
  58781. * @returns a new Vector2
  58782. */
  58783. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  58784. /**
  58785. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  58786. * @param vector defines the vector to transform
  58787. * @param transformation defines the matrix to apply
  58788. * @param result defines the target vector
  58789. */
  58790. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  58791. /**
  58792. * Determines if a given vector is included in a triangle
  58793. * @param p defines the vector to test
  58794. * @param p0 defines 1st triangle point
  58795. * @param p1 defines 2nd triangle point
  58796. * @param p2 defines 3rd triangle point
  58797. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  58798. */
  58799. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  58800. /**
  58801. * Gets the distance between the vectors "value1" and "value2"
  58802. * @param value1 defines first vector
  58803. * @param value2 defines second vector
  58804. * @returns the distance between vectors
  58805. */
  58806. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58807. /**
  58808. * Returns the squared distance between the vectors "value1" and "value2"
  58809. * @param value1 defines first vector
  58810. * @param value2 defines second vector
  58811. * @returns the squared distance between vectors
  58812. */
  58813. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  58814. /**
  58815. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  58816. * @param value1 defines first vector
  58817. * @param value2 defines second vector
  58818. * @returns a new Vector2
  58819. */
  58820. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  58821. /**
  58822. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  58823. * @param p defines the middle point
  58824. * @param segA defines one point of the segment
  58825. * @param segB defines the other point of the segment
  58826. * @returns the shortest distance
  58827. */
  58828. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  58829. }
  58830. /**
  58831. * Classed used to store (x,y,z) vector representation
  58832. * A Vector3 is the main object used in 3D geometry
  58833. * It can represent etiher the coordinates of a point the space, either a direction
  58834. * Reminder: js uses a left handed forward facing system
  58835. */
  58836. export class Vector3 {
  58837. /**
  58838. * Defines the first coordinates (on X axis)
  58839. */
  58840. x: number;
  58841. /**
  58842. * Defines the second coordinates (on Y axis)
  58843. */
  58844. y: number;
  58845. /**
  58846. * Defines the third coordinates (on Z axis)
  58847. */
  58848. z: number;
  58849. private static _UpReadOnly;
  58850. /**
  58851. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  58852. * @param x defines the first coordinates (on X axis)
  58853. * @param y defines the second coordinates (on Y axis)
  58854. * @param z defines the third coordinates (on Z axis)
  58855. */
  58856. constructor(
  58857. /**
  58858. * Defines the first coordinates (on X axis)
  58859. */
  58860. x?: number,
  58861. /**
  58862. * Defines the second coordinates (on Y axis)
  58863. */
  58864. y?: number,
  58865. /**
  58866. * Defines the third coordinates (on Z axis)
  58867. */
  58868. z?: number);
  58869. /**
  58870. * Creates a string representation of the Vector3
  58871. * @returns a string with the Vector3 coordinates.
  58872. */
  58873. toString(): string;
  58874. /**
  58875. * Gets the class name
  58876. * @returns the string "Vector3"
  58877. */
  58878. getClassName(): string;
  58879. /**
  58880. * Creates the Vector3 hash code
  58881. * @returns a number which tends to be unique between Vector3 instances
  58882. */
  58883. getHashCode(): number;
  58884. /**
  58885. * Creates an array containing three elements : the coordinates of the Vector3
  58886. * @returns a new array of numbers
  58887. */
  58888. asArray(): number[];
  58889. /**
  58890. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  58891. * @param array defines the destination array
  58892. * @param index defines the offset in the destination array
  58893. * @returns the current Vector3
  58894. */
  58895. toArray(array: FloatArray, index?: number): Vector3;
  58896. /**
  58897. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  58898. * @returns a new Quaternion object, computed from the Vector3 coordinates
  58899. */
  58900. toQuaternion(): Quaternion;
  58901. /**
  58902. * Adds the given vector to the current Vector3
  58903. * @param otherVector defines the second operand
  58904. * @returns the current updated Vector3
  58905. */
  58906. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58907. /**
  58908. * Adds the given coordinates to the current Vector3
  58909. * @param x defines the x coordinate of the operand
  58910. * @param y defines the y coordinate of the operand
  58911. * @param z defines the z coordinate of the operand
  58912. * @returns the current updated Vector3
  58913. */
  58914. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  58915. /**
  58916. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  58917. * @param otherVector defines the second operand
  58918. * @returns the resulting Vector3
  58919. */
  58920. add(otherVector: DeepImmutable<Vector3>): Vector3;
  58921. /**
  58922. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  58923. * @param otherVector defines the second operand
  58924. * @param result defines the Vector3 object where to store the result
  58925. * @returns the current Vector3
  58926. */
  58927. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58928. /**
  58929. * Subtract the given vector from the current Vector3
  58930. * @param otherVector defines the second operand
  58931. * @returns the current updated Vector3
  58932. */
  58933. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  58934. /**
  58935. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  58936. * @param otherVector defines the second operand
  58937. * @returns the resulting Vector3
  58938. */
  58939. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  58940. /**
  58941. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  58942. * @param otherVector defines the second operand
  58943. * @param result defines the Vector3 object where to store the result
  58944. * @returns the current Vector3
  58945. */
  58946. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  58947. /**
  58948. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  58949. * @param x defines the x coordinate of the operand
  58950. * @param y defines the y coordinate of the operand
  58951. * @param z defines the z coordinate of the operand
  58952. * @returns the resulting Vector3
  58953. */
  58954. subtractFromFloats(x: number, y: number, z: number): Vector3;
  58955. /**
  58956. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  58957. * @param x defines the x coordinate of the operand
  58958. * @param y defines the y coordinate of the operand
  58959. * @param z defines the z coordinate of the operand
  58960. * @param result defines the Vector3 object where to store the result
  58961. * @returns the current Vector3
  58962. */
  58963. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  58964. /**
  58965. * Gets a new Vector3 set with the current Vector3 negated coordinates
  58966. * @returns a new Vector3
  58967. */
  58968. negate(): Vector3;
  58969. /**
  58970. * Multiplies the Vector3 coordinates by the float "scale"
  58971. * @param scale defines the multiplier factor
  58972. * @returns the current updated Vector3
  58973. */
  58974. scaleInPlace(scale: number): Vector3;
  58975. /**
  58976. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  58977. * @param scale defines the multiplier factor
  58978. * @returns a new Vector3
  58979. */
  58980. scale(scale: number): Vector3;
  58981. /**
  58982. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  58983. * @param scale defines the multiplier factor
  58984. * @param result defines the Vector3 object where to store the result
  58985. * @returns the current Vector3
  58986. */
  58987. scaleToRef(scale: number, result: Vector3): Vector3;
  58988. /**
  58989. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  58990. * @param scale defines the scale factor
  58991. * @param result defines the Vector3 object where to store the result
  58992. * @returns the unmodified current Vector3
  58993. */
  58994. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  58995. /**
  58996. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  58997. * @param otherVector defines the second operand
  58998. * @returns true if both vectors are equals
  58999. */
  59000. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59001. /**
  59002. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59003. * @param otherVector defines the second operand
  59004. * @param epsilon defines the minimal distance to define values as equals
  59005. * @returns true if both vectors are distant less than epsilon
  59006. */
  59007. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59008. /**
  59009. * Returns true if the current Vector3 coordinates equals the given floats
  59010. * @param x defines the x coordinate of the operand
  59011. * @param y defines the y coordinate of the operand
  59012. * @param z defines the z coordinate of the operand
  59013. * @returns true if both vectors are equals
  59014. */
  59015. equalsToFloats(x: number, y: number, z: number): boolean;
  59016. /**
  59017. * Multiplies the current Vector3 coordinates by the given ones
  59018. * @param otherVector defines the second operand
  59019. * @returns the current updated Vector3
  59020. */
  59021. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59022. /**
  59023. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59024. * @param otherVector defines the second operand
  59025. * @returns the new Vector3
  59026. */
  59027. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59028. /**
  59029. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59030. * @param otherVector defines the second operand
  59031. * @param result defines the Vector3 object where to store the result
  59032. * @returns the current Vector3
  59033. */
  59034. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59035. /**
  59036. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59037. * @param x defines the x coordinate of the operand
  59038. * @param y defines the y coordinate of the operand
  59039. * @param z defines the z coordinate of the operand
  59040. * @returns the new Vector3
  59041. */
  59042. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59043. /**
  59044. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59045. * @param otherVector defines the second operand
  59046. * @returns the new Vector3
  59047. */
  59048. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59049. /**
  59050. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59051. * @param otherVector defines the second operand
  59052. * @param result defines the Vector3 object where to store the result
  59053. * @returns the current Vector3
  59054. */
  59055. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59056. /**
  59057. * Divides the current Vector3 coordinates by the given ones.
  59058. * @param otherVector defines the second operand
  59059. * @returns the current updated Vector3
  59060. */
  59061. divideInPlace(otherVector: Vector3): Vector3;
  59062. /**
  59063. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59064. * @param other defines the second operand
  59065. * @returns the current updated Vector3
  59066. */
  59067. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59068. /**
  59069. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59070. * @param other defines the second operand
  59071. * @returns the current updated Vector3
  59072. */
  59073. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59074. /**
  59075. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59076. * @param x defines the x coordinate of the operand
  59077. * @param y defines the y coordinate of the operand
  59078. * @param z defines the z coordinate of the operand
  59079. * @returns the current updated Vector3
  59080. */
  59081. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59082. /**
  59083. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59084. * @param x defines the x coordinate of the operand
  59085. * @param y defines the y coordinate of the operand
  59086. * @param z defines the z coordinate of the operand
  59087. * @returns the current updated Vector3
  59088. */
  59089. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59090. /**
  59091. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59092. * Check if is non uniform within a certain amount of decimal places to account for this
  59093. * @param epsilon the amount the values can differ
  59094. * @returns if the the vector is non uniform to a certain number of decimal places
  59095. */
  59096. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59097. /**
  59098. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59099. */
  59100. readonly isNonUniform: boolean;
  59101. /**
  59102. * Gets a new Vector3 from current Vector3 floored values
  59103. * @returns a new Vector3
  59104. */
  59105. floor(): Vector3;
  59106. /**
  59107. * Gets a new Vector3 from current Vector3 floored values
  59108. * @returns a new Vector3
  59109. */
  59110. fract(): Vector3;
  59111. /**
  59112. * Gets the length of the Vector3
  59113. * @returns the length of the Vecto3
  59114. */
  59115. length(): number;
  59116. /**
  59117. * Gets the squared length of the Vector3
  59118. * @returns squared length of the Vector3
  59119. */
  59120. lengthSquared(): number;
  59121. /**
  59122. * Normalize the current Vector3.
  59123. * Please note that this is an in place operation.
  59124. * @returns the current updated Vector3
  59125. */
  59126. normalize(): Vector3;
  59127. /**
  59128. * Reorders the x y z properties of the vector in place
  59129. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59130. * @returns the current updated vector
  59131. */
  59132. reorderInPlace(order: string): this;
  59133. /**
  59134. * Rotates the vector around 0,0,0 by a quaternion
  59135. * @param quaternion the rotation quaternion
  59136. * @param result vector to store the result
  59137. * @returns the resulting vector
  59138. */
  59139. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59140. /**
  59141. * Rotates a vector around a given point
  59142. * @param quaternion the rotation quaternion
  59143. * @param point the point to rotate around
  59144. * @param result vector to store the result
  59145. * @returns the resulting vector
  59146. */
  59147. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59148. /**
  59149. * Normalize the current Vector3 with the given input length.
  59150. * Please note that this is an in place operation.
  59151. * @param len the length of the vector
  59152. * @returns the current updated Vector3
  59153. */
  59154. normalizeFromLength(len: number): Vector3;
  59155. /**
  59156. * Normalize the current Vector3 to a new vector
  59157. * @returns the new Vector3
  59158. */
  59159. normalizeToNew(): Vector3;
  59160. /**
  59161. * Normalize the current Vector3 to the reference
  59162. * @param reference define the Vector3 to update
  59163. * @returns the updated Vector3
  59164. */
  59165. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59166. /**
  59167. * Creates a new Vector3 copied from the current Vector3
  59168. * @returns the new Vector3
  59169. */
  59170. clone(): Vector3;
  59171. /**
  59172. * Copies the given vector coordinates to the current Vector3 ones
  59173. * @param source defines the source Vector3
  59174. * @returns the current updated Vector3
  59175. */
  59176. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59177. /**
  59178. * Copies the given floats to the current Vector3 coordinates
  59179. * @param x defines the x coordinate of the operand
  59180. * @param y defines the y coordinate of the operand
  59181. * @param z defines the z coordinate of the operand
  59182. * @returns the current updated Vector3
  59183. */
  59184. copyFromFloats(x: number, y: number, z: number): Vector3;
  59185. /**
  59186. * Copies the given floats to the current Vector3 coordinates
  59187. * @param x defines the x coordinate of the operand
  59188. * @param y defines the y coordinate of the operand
  59189. * @param z defines the z coordinate of the operand
  59190. * @returns the current updated Vector3
  59191. */
  59192. set(x: number, y: number, z: number): Vector3;
  59193. /**
  59194. * Copies the given float to the current Vector3 coordinates
  59195. * @param v defines the x, y and z coordinates of the operand
  59196. * @returns the current updated Vector3
  59197. */
  59198. setAll(v: number): Vector3;
  59199. /**
  59200. * Get the clip factor between two vectors
  59201. * @param vector0 defines the first operand
  59202. * @param vector1 defines the second operand
  59203. * @param axis defines the axis to use
  59204. * @param size defines the size along the axis
  59205. * @returns the clip factor
  59206. */
  59207. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59208. /**
  59209. * Get angle between two vectors
  59210. * @param vector0 angle between vector0 and vector1
  59211. * @param vector1 angle between vector0 and vector1
  59212. * @param normal direction of the normal
  59213. * @return the angle between vector0 and vector1
  59214. */
  59215. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59216. /**
  59217. * Returns a new Vector3 set from the index "offset" of the given array
  59218. * @param array defines the source array
  59219. * @param offset defines the offset in the source array
  59220. * @returns the new Vector3
  59221. */
  59222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59223. /**
  59224. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59225. * This function is deprecated. Use FromArray instead
  59226. * @param array defines the source array
  59227. * @param offset defines the offset in the source array
  59228. * @returns the new Vector3
  59229. */
  59230. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59231. /**
  59232. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59233. * @param array defines the source array
  59234. * @param offset defines the offset in the source array
  59235. * @param result defines the Vector3 where to store the result
  59236. */
  59237. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59238. /**
  59239. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59240. * This function is deprecated. Use FromArrayToRef instead.
  59241. * @param array defines the source array
  59242. * @param offset defines the offset in the source array
  59243. * @param result defines the Vector3 where to store the result
  59244. */
  59245. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59246. /**
  59247. * Sets the given vector "result" with the given floats.
  59248. * @param x defines the x coordinate of the source
  59249. * @param y defines the y coordinate of the source
  59250. * @param z defines the z coordinate of the source
  59251. * @param result defines the Vector3 where to store the result
  59252. */
  59253. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59254. /**
  59255. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59256. * @returns a new empty Vector3
  59257. */
  59258. static Zero(): Vector3;
  59259. /**
  59260. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59261. * @returns a new unit Vector3
  59262. */
  59263. static One(): Vector3;
  59264. /**
  59265. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59266. * @returns a new up Vector3
  59267. */
  59268. static Up(): Vector3;
  59269. /**
  59270. * Gets a up Vector3 that must not be updated
  59271. */
  59272. static readonly UpReadOnly: DeepImmutable<Vector3>;
  59273. /**
  59274. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  59275. * @returns a new down Vector3
  59276. */
  59277. static Down(): Vector3;
  59278. /**
  59279. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  59280. * @returns a new forward Vector3
  59281. */
  59282. static Forward(): Vector3;
  59283. /**
  59284. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  59285. * @returns a new forward Vector3
  59286. */
  59287. static Backward(): Vector3;
  59288. /**
  59289. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  59290. * @returns a new right Vector3
  59291. */
  59292. static Right(): Vector3;
  59293. /**
  59294. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  59295. * @returns a new left Vector3
  59296. */
  59297. static Left(): Vector3;
  59298. /**
  59299. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  59300. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59301. * @param vector defines the Vector3 to transform
  59302. * @param transformation defines the transformation matrix
  59303. * @returns the transformed Vector3
  59304. */
  59305. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59306. /**
  59307. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  59308. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  59309. * @param vector defines the Vector3 to transform
  59310. * @param transformation defines the transformation matrix
  59311. * @param result defines the Vector3 where to store the result
  59312. */
  59313. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59314. /**
  59315. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  59316. * This method computes tranformed coordinates only, not transformed direction vectors
  59317. * @param x define the x coordinate of the source vector
  59318. * @param y define the y coordinate of the source vector
  59319. * @param z define the z coordinate of the source vector
  59320. * @param transformation defines the transformation matrix
  59321. * @param result defines the Vector3 where to store the result
  59322. */
  59323. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59324. /**
  59325. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  59326. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59327. * @param vector defines the Vector3 to transform
  59328. * @param transformation defines the transformation matrix
  59329. * @returns the new Vector3
  59330. */
  59331. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  59332. /**
  59333. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  59334. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59335. * @param vector defines the Vector3 to transform
  59336. * @param transformation defines the transformation matrix
  59337. * @param result defines the Vector3 where to store the result
  59338. */
  59339. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59340. /**
  59341. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  59342. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  59343. * @param x define the x coordinate of the source vector
  59344. * @param y define the y coordinate of the source vector
  59345. * @param z define the z coordinate of the source vector
  59346. * @param transformation defines the transformation matrix
  59347. * @param result defines the Vector3 where to store the result
  59348. */
  59349. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  59350. /**
  59351. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  59352. * @param value1 defines the first control point
  59353. * @param value2 defines the second control point
  59354. * @param value3 defines the third control point
  59355. * @param value4 defines the fourth control point
  59356. * @param amount defines the amount on the spline to use
  59357. * @returns the new Vector3
  59358. */
  59359. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  59360. /**
  59361. * 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"
  59362. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59363. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59364. * @param value defines the current value
  59365. * @param min defines the lower range value
  59366. * @param max defines the upper range value
  59367. * @returns the new Vector3
  59368. */
  59369. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  59370. /**
  59371. * 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"
  59372. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  59373. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  59374. * @param value defines the current value
  59375. * @param min defines the lower range value
  59376. * @param max defines the upper range value
  59377. * @param result defines the Vector3 where to store the result
  59378. */
  59379. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  59380. /**
  59381. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  59382. * @param value1 defines the first control point
  59383. * @param tangent1 defines the first tangent vector
  59384. * @param value2 defines the second control point
  59385. * @param tangent2 defines the second tangent vector
  59386. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  59387. * @returns the new Vector3
  59388. */
  59389. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  59390. /**
  59391. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  59392. * @param start defines the start value
  59393. * @param end defines the end value
  59394. * @param amount max defines amount between both (between 0 and 1)
  59395. * @returns the new Vector3
  59396. */
  59397. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  59398. /**
  59399. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  59400. * @param start defines the start value
  59401. * @param end defines the end value
  59402. * @param amount max defines amount between both (between 0 and 1)
  59403. * @param result defines the Vector3 where to store the result
  59404. */
  59405. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  59406. /**
  59407. * Returns the dot product (float) between the vectors "left" and "right"
  59408. * @param left defines the left operand
  59409. * @param right defines the right operand
  59410. * @returns the dot product
  59411. */
  59412. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  59413. /**
  59414. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  59415. * The cross product is then orthogonal to both "left" and "right"
  59416. * @param left defines the left operand
  59417. * @param right defines the right operand
  59418. * @returns the cross product
  59419. */
  59420. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59421. /**
  59422. * Sets the given vector "result" with the cross product of "left" and "right"
  59423. * The cross product is then orthogonal to both "left" and "right"
  59424. * @param left defines the left operand
  59425. * @param right defines the right operand
  59426. * @param result defines the Vector3 where to store the result
  59427. */
  59428. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  59429. /**
  59430. * Returns a new Vector3 as the normalization of the given vector
  59431. * @param vector defines the Vector3 to normalize
  59432. * @returns the new Vector3
  59433. */
  59434. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  59435. /**
  59436. * Sets the given vector "result" with the normalization of the given first vector
  59437. * @param vector defines the Vector3 to normalize
  59438. * @param result defines the Vector3 where to store the result
  59439. */
  59440. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  59441. /**
  59442. * Project a Vector3 onto screen space
  59443. * @param vector defines the Vector3 to project
  59444. * @param world defines the world matrix to use
  59445. * @param transform defines the transform (view x projection) matrix to use
  59446. * @param viewport defines the screen viewport to use
  59447. * @returns the new Vector3
  59448. */
  59449. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  59450. /** @hidden */
  59451. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  59452. /**
  59453. * Unproject from screen space to object space
  59454. * @param source defines the screen space Vector3 to use
  59455. * @param viewportWidth defines the current width of the viewport
  59456. * @param viewportHeight defines the current height of the viewport
  59457. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59458. * @param transform defines the transform (view x projection) matrix to use
  59459. * @returns the new Vector3
  59460. */
  59461. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  59462. /**
  59463. * Unproject from screen space to object space
  59464. * @param source defines the screen space Vector3 to use
  59465. * @param viewportWidth defines the current width of the viewport
  59466. * @param viewportHeight defines the current height of the viewport
  59467. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59468. * @param view defines the view matrix to use
  59469. * @param projection defines the projection matrix to use
  59470. * @returns the new Vector3
  59471. */
  59472. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  59473. /**
  59474. * Unproject from screen space to object space
  59475. * @param source defines the screen space Vector3 to use
  59476. * @param viewportWidth defines the current width of the viewport
  59477. * @param viewportHeight defines the current height of the viewport
  59478. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59479. * @param view defines the view matrix to use
  59480. * @param projection defines the projection matrix to use
  59481. * @param result defines the Vector3 where to store the result
  59482. */
  59483. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59484. /**
  59485. * Unproject from screen space to object space
  59486. * @param sourceX defines the screen space x coordinate to use
  59487. * @param sourceY defines the screen space y coordinate to use
  59488. * @param sourceZ defines the screen space z coordinate to use
  59489. * @param viewportWidth defines the current width of the viewport
  59490. * @param viewportHeight defines the current height of the viewport
  59491. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  59492. * @param view defines the view matrix to use
  59493. * @param projection defines the projection matrix to use
  59494. * @param result defines the Vector3 where to store the result
  59495. */
  59496. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  59497. /**
  59498. * Gets the minimal coordinate values between two Vector3
  59499. * @param left defines the first operand
  59500. * @param right defines the second operand
  59501. * @returns the new Vector3
  59502. */
  59503. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59504. /**
  59505. * Gets the maximal coordinate values between two Vector3
  59506. * @param left defines the first operand
  59507. * @param right defines the second operand
  59508. * @returns the new Vector3
  59509. */
  59510. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  59511. /**
  59512. * Returns the distance between the vectors "value1" and "value2"
  59513. * @param value1 defines the first operand
  59514. * @param value2 defines the second operand
  59515. * @returns the distance
  59516. */
  59517. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59518. /**
  59519. * Returns the squared distance between the vectors "value1" and "value2"
  59520. * @param value1 defines the first operand
  59521. * @param value2 defines the second operand
  59522. * @returns the squared distance
  59523. */
  59524. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  59525. /**
  59526. * Returns a new Vector3 located at the center between "value1" and "value2"
  59527. * @param value1 defines the first operand
  59528. * @param value2 defines the second operand
  59529. * @returns the new Vector3
  59530. */
  59531. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  59532. /**
  59533. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  59534. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  59535. * to something in order to rotate it from its local system to the given target system
  59536. * Note: axis1, axis2 and axis3 are normalized during this operation
  59537. * @param axis1 defines the first axis
  59538. * @param axis2 defines the second axis
  59539. * @param axis3 defines the third axis
  59540. * @returns a new Vector3
  59541. */
  59542. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  59543. /**
  59544. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  59545. * @param axis1 defines the first axis
  59546. * @param axis2 defines the second axis
  59547. * @param axis3 defines the third axis
  59548. * @param ref defines the Vector3 where to store the result
  59549. */
  59550. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  59551. }
  59552. /**
  59553. * Vector4 class created for EulerAngle class conversion to Quaternion
  59554. */
  59555. export class Vector4 {
  59556. /** x value of the vector */
  59557. x: number;
  59558. /** y value of the vector */
  59559. y: number;
  59560. /** z value of the vector */
  59561. z: number;
  59562. /** w value of the vector */
  59563. w: number;
  59564. /**
  59565. * Creates a Vector4 object from the given floats.
  59566. * @param x x value of the vector
  59567. * @param y y value of the vector
  59568. * @param z z value of the vector
  59569. * @param w w value of the vector
  59570. */
  59571. constructor(
  59572. /** x value of the vector */
  59573. x: number,
  59574. /** y value of the vector */
  59575. y: number,
  59576. /** z value of the vector */
  59577. z: number,
  59578. /** w value of the vector */
  59579. w: number);
  59580. /**
  59581. * Returns the string with the Vector4 coordinates.
  59582. * @returns a string containing all the vector values
  59583. */
  59584. toString(): string;
  59585. /**
  59586. * Returns the string "Vector4".
  59587. * @returns "Vector4"
  59588. */
  59589. getClassName(): string;
  59590. /**
  59591. * Returns the Vector4 hash code.
  59592. * @returns a unique hash code
  59593. */
  59594. getHashCode(): number;
  59595. /**
  59596. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  59597. * @returns the resulting array
  59598. */
  59599. asArray(): number[];
  59600. /**
  59601. * Populates the given array from the given index with the Vector4 coordinates.
  59602. * @param array array to populate
  59603. * @param index index of the array to start at (default: 0)
  59604. * @returns the Vector4.
  59605. */
  59606. toArray(array: FloatArray, index?: number): Vector4;
  59607. /**
  59608. * Adds the given vector to the current Vector4.
  59609. * @param otherVector the vector to add
  59610. * @returns the updated Vector4.
  59611. */
  59612. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59613. /**
  59614. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  59615. * @param otherVector the vector to add
  59616. * @returns the resulting vector
  59617. */
  59618. add(otherVector: DeepImmutable<Vector4>): Vector4;
  59619. /**
  59620. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  59621. * @param otherVector the vector to add
  59622. * @param result the vector to store the result
  59623. * @returns the current Vector4.
  59624. */
  59625. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59626. /**
  59627. * Subtract in place the given vector from the current Vector4.
  59628. * @param otherVector the vector to subtract
  59629. * @returns the updated Vector4.
  59630. */
  59631. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59632. /**
  59633. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  59634. * @param otherVector the vector to add
  59635. * @returns the new vector with the result
  59636. */
  59637. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  59638. /**
  59639. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  59640. * @param otherVector the vector to subtract
  59641. * @param result the vector to store the result
  59642. * @returns the current Vector4.
  59643. */
  59644. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59645. /**
  59646. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59647. */
  59648. /**
  59649. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59650. * @param x value to subtract
  59651. * @param y value to subtract
  59652. * @param z value to subtract
  59653. * @param w value to subtract
  59654. * @returns new vector containing the result
  59655. */
  59656. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59657. /**
  59658. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  59659. * @param x value to subtract
  59660. * @param y value to subtract
  59661. * @param z value to subtract
  59662. * @param w value to subtract
  59663. * @param result the vector to store the result in
  59664. * @returns the current Vector4.
  59665. */
  59666. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  59667. /**
  59668. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  59669. * @returns a new vector with the negated values
  59670. */
  59671. negate(): Vector4;
  59672. /**
  59673. * Multiplies the current Vector4 coordinates by scale (float).
  59674. * @param scale the number to scale with
  59675. * @returns the updated Vector4.
  59676. */
  59677. scaleInPlace(scale: number): Vector4;
  59678. /**
  59679. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  59680. * @param scale the number to scale with
  59681. * @returns a new vector with the result
  59682. */
  59683. scale(scale: number): Vector4;
  59684. /**
  59685. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  59686. * @param scale the number to scale with
  59687. * @param result a vector to store the result in
  59688. * @returns the current Vector4.
  59689. */
  59690. scaleToRef(scale: number, result: Vector4): Vector4;
  59691. /**
  59692. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  59693. * @param scale defines the scale factor
  59694. * @param result defines the Vector4 object where to store the result
  59695. * @returns the unmodified current Vector4
  59696. */
  59697. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  59698. /**
  59699. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  59700. * @param otherVector the vector to compare against
  59701. * @returns true if they are equal
  59702. */
  59703. equals(otherVector: DeepImmutable<Vector4>): boolean;
  59704. /**
  59705. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  59706. * @param otherVector vector to compare against
  59707. * @param epsilon (Default: very small number)
  59708. * @returns true if they are equal
  59709. */
  59710. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  59711. /**
  59712. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  59713. * @param x x value to compare against
  59714. * @param y y value to compare against
  59715. * @param z z value to compare against
  59716. * @param w w value to compare against
  59717. * @returns true if equal
  59718. */
  59719. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  59720. /**
  59721. * Multiplies in place the current Vector4 by the given one.
  59722. * @param otherVector vector to multiple with
  59723. * @returns the updated Vector4.
  59724. */
  59725. multiplyInPlace(otherVector: Vector4): Vector4;
  59726. /**
  59727. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  59728. * @param otherVector vector to multiple with
  59729. * @returns resulting new vector
  59730. */
  59731. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  59732. /**
  59733. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  59734. * @param otherVector vector to multiple with
  59735. * @param result vector to store the result
  59736. * @returns the current Vector4.
  59737. */
  59738. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59739. /**
  59740. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  59741. * @param x x value multiply with
  59742. * @param y y value multiply with
  59743. * @param z z value multiply with
  59744. * @param w w value multiply with
  59745. * @returns resulting new vector
  59746. */
  59747. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  59748. /**
  59749. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  59750. * @param otherVector vector to devide with
  59751. * @returns resulting new vector
  59752. */
  59753. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  59754. /**
  59755. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  59756. * @param otherVector vector to devide with
  59757. * @param result vector to store the result
  59758. * @returns the current Vector4.
  59759. */
  59760. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  59761. /**
  59762. * Divides the current Vector3 coordinates by the given ones.
  59763. * @param otherVector vector to devide with
  59764. * @returns the updated Vector3.
  59765. */
  59766. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  59767. /**
  59768. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  59769. * @param other defines the second operand
  59770. * @returns the current updated Vector4
  59771. */
  59772. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59773. /**
  59774. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  59775. * @param other defines the second operand
  59776. * @returns the current updated Vector4
  59777. */
  59778. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  59779. /**
  59780. * Gets a new Vector4 from current Vector4 floored values
  59781. * @returns a new Vector4
  59782. */
  59783. floor(): Vector4;
  59784. /**
  59785. * Gets a new Vector4 from current Vector3 floored values
  59786. * @returns a new Vector4
  59787. */
  59788. fract(): Vector4;
  59789. /**
  59790. * Returns the Vector4 length (float).
  59791. * @returns the length
  59792. */
  59793. length(): number;
  59794. /**
  59795. * Returns the Vector4 squared length (float).
  59796. * @returns the length squared
  59797. */
  59798. lengthSquared(): number;
  59799. /**
  59800. * Normalizes in place the Vector4.
  59801. * @returns the updated Vector4.
  59802. */
  59803. normalize(): Vector4;
  59804. /**
  59805. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  59806. * @returns this converted to a new vector3
  59807. */
  59808. toVector3(): Vector3;
  59809. /**
  59810. * Returns a new Vector4 copied from the current one.
  59811. * @returns the new cloned vector
  59812. */
  59813. clone(): Vector4;
  59814. /**
  59815. * Updates the current Vector4 with the given one coordinates.
  59816. * @param source the source vector to copy from
  59817. * @returns the updated Vector4.
  59818. */
  59819. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  59820. /**
  59821. * Updates the current Vector4 coordinates with the given floats.
  59822. * @param x float to copy from
  59823. * @param y float to copy from
  59824. * @param z float to copy from
  59825. * @param w float to copy from
  59826. * @returns the updated Vector4.
  59827. */
  59828. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  59829. /**
  59830. * Updates the current Vector4 coordinates with the given floats.
  59831. * @param x float to set from
  59832. * @param y float to set from
  59833. * @param z float to set from
  59834. * @param w float to set from
  59835. * @returns the updated Vector4.
  59836. */
  59837. set(x: number, y: number, z: number, w: number): Vector4;
  59838. /**
  59839. * Copies the given float to the current Vector3 coordinates
  59840. * @param v defines the x, y, z and w coordinates of the operand
  59841. * @returns the current updated Vector3
  59842. */
  59843. setAll(v: number): Vector4;
  59844. /**
  59845. * Returns a new Vector4 set from the starting index of the given array.
  59846. * @param array the array to pull values from
  59847. * @param offset the offset into the array to start at
  59848. * @returns the new vector
  59849. */
  59850. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  59851. /**
  59852. * Updates the given vector "result" from the starting index of the given array.
  59853. * @param array the array to pull values from
  59854. * @param offset the offset into the array to start at
  59855. * @param result the vector to store the result in
  59856. */
  59857. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  59858. /**
  59859. * Updates the given vector "result" from the starting index of the given Float32Array.
  59860. * @param array the array to pull values from
  59861. * @param offset the offset into the array to start at
  59862. * @param result the vector to store the result in
  59863. */
  59864. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  59865. /**
  59866. * Updates the given vector "result" coordinates from the given floats.
  59867. * @param x float to set from
  59868. * @param y float to set from
  59869. * @param z float to set from
  59870. * @param w float to set from
  59871. * @param result the vector to the floats in
  59872. */
  59873. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  59874. /**
  59875. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  59876. * @returns the new vector
  59877. */
  59878. static Zero(): Vector4;
  59879. /**
  59880. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  59881. * @returns the new vector
  59882. */
  59883. static One(): Vector4;
  59884. /**
  59885. * Returns a new normalized Vector4 from the given one.
  59886. * @param vector the vector to normalize
  59887. * @returns the vector
  59888. */
  59889. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  59890. /**
  59891. * Updates the given vector "result" from the normalization of the given one.
  59892. * @param vector the vector to normalize
  59893. * @param result the vector to store the result in
  59894. */
  59895. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  59896. /**
  59897. * Returns a vector with the minimum values from the left and right vectors
  59898. * @param left left vector to minimize
  59899. * @param right right vector to minimize
  59900. * @returns a new vector with the minimum of the left and right vector values
  59901. */
  59902. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59903. /**
  59904. * Returns a vector with the maximum values from the left and right vectors
  59905. * @param left left vector to maximize
  59906. * @param right right vector to maximize
  59907. * @returns a new vector with the maximum of the left and right vector values
  59908. */
  59909. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  59910. /**
  59911. * Returns the distance (float) between the vectors "value1" and "value2".
  59912. * @param value1 value to calulate the distance between
  59913. * @param value2 value to calulate the distance between
  59914. * @return the distance between the two vectors
  59915. */
  59916. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59917. /**
  59918. * Returns the squared distance (float) between the vectors "value1" and "value2".
  59919. * @param value1 value to calulate the distance between
  59920. * @param value2 value to calulate the distance between
  59921. * @return the distance between the two vectors squared
  59922. */
  59923. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  59924. /**
  59925. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  59926. * @param value1 value to calulate the center between
  59927. * @param value2 value to calulate the center between
  59928. * @return the center between the two vectors
  59929. */
  59930. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  59931. /**
  59932. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  59933. * This methods computes transformed normalized direction vectors only.
  59934. * @param vector the vector to transform
  59935. * @param transformation the transformation matrix to apply
  59936. * @returns the new vector
  59937. */
  59938. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  59939. /**
  59940. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  59941. * This methods computes transformed normalized direction vectors only.
  59942. * @param vector the vector to transform
  59943. * @param transformation the transformation matrix to apply
  59944. * @param result the vector to store the result in
  59945. */
  59946. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59947. /**
  59948. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  59949. * This methods computes transformed normalized direction vectors only.
  59950. * @param x value to transform
  59951. * @param y value to transform
  59952. * @param z value to transform
  59953. * @param w value to transform
  59954. * @param transformation the transformation matrix to apply
  59955. * @param result the vector to store the results in
  59956. */
  59957. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  59958. /**
  59959. * Creates a new Vector4 from a Vector3
  59960. * @param source defines the source data
  59961. * @param w defines the 4th component (default is 0)
  59962. * @returns a new Vector4
  59963. */
  59964. static FromVector3(source: Vector3, w?: number): Vector4;
  59965. }
  59966. /**
  59967. * Interface for the size containing width and height
  59968. */
  59969. export interface ISize {
  59970. /**
  59971. * Width
  59972. */
  59973. width: number;
  59974. /**
  59975. * Heighht
  59976. */
  59977. height: number;
  59978. }
  59979. /**
  59980. * Size containing widht and height
  59981. */
  59982. export class Size implements ISize {
  59983. /**
  59984. * Width
  59985. */
  59986. width: number;
  59987. /**
  59988. * Height
  59989. */
  59990. height: number;
  59991. /**
  59992. * Creates a Size object from the given width and height (floats).
  59993. * @param width width of the new size
  59994. * @param height height of the new size
  59995. */
  59996. constructor(width: number, height: number);
  59997. /**
  59998. * Returns a string with the Size width and height
  59999. * @returns a string with the Size width and height
  60000. */
  60001. toString(): string;
  60002. /**
  60003. * "Size"
  60004. * @returns the string "Size"
  60005. */
  60006. getClassName(): string;
  60007. /**
  60008. * Returns the Size hash code.
  60009. * @returns a hash code for a unique width and height
  60010. */
  60011. getHashCode(): number;
  60012. /**
  60013. * Updates the current size from the given one.
  60014. * @param src the given size
  60015. */
  60016. copyFrom(src: Size): void;
  60017. /**
  60018. * Updates in place the current Size from the given floats.
  60019. * @param width width of the new size
  60020. * @param height height of the new size
  60021. * @returns the updated Size.
  60022. */
  60023. copyFromFloats(width: number, height: number): Size;
  60024. /**
  60025. * Updates in place the current Size from the given floats.
  60026. * @param width width to set
  60027. * @param height height to set
  60028. * @returns the updated Size.
  60029. */
  60030. set(width: number, height: number): Size;
  60031. /**
  60032. * Multiplies the width and height by numbers
  60033. * @param w factor to multiple the width by
  60034. * @param h factor to multiple the height by
  60035. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60036. */
  60037. multiplyByFloats(w: number, h: number): Size;
  60038. /**
  60039. * Clones the size
  60040. * @returns a new Size copied from the given one.
  60041. */
  60042. clone(): Size;
  60043. /**
  60044. * True if the current Size and the given one width and height are strictly equal.
  60045. * @param other the other size to compare against
  60046. * @returns True if the current Size and the given one width and height are strictly equal.
  60047. */
  60048. equals(other: Size): boolean;
  60049. /**
  60050. * The surface of the Size : width * height (float).
  60051. */
  60052. readonly surface: number;
  60053. /**
  60054. * Create a new size of zero
  60055. * @returns a new Size set to (0.0, 0.0)
  60056. */
  60057. static Zero(): Size;
  60058. /**
  60059. * Sums the width and height of two sizes
  60060. * @param otherSize size to add to this size
  60061. * @returns a new Size set as the addition result of the current Size and the given one.
  60062. */
  60063. add(otherSize: Size): Size;
  60064. /**
  60065. * Subtracts the width and height of two
  60066. * @param otherSize size to subtract to this size
  60067. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60068. */
  60069. subtract(otherSize: Size): Size;
  60070. /**
  60071. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60072. * @param start starting size to lerp between
  60073. * @param end end size to lerp between
  60074. * @param amount amount to lerp between the start and end values
  60075. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60076. */
  60077. static Lerp(start: Size, end: Size, amount: number): Size;
  60078. }
  60079. /**
  60080. * Class used to store quaternion data
  60081. * @see https://en.wikipedia.org/wiki/Quaternion
  60082. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60083. */
  60084. export class Quaternion {
  60085. /** defines the first component (0 by default) */
  60086. x: number;
  60087. /** defines the second component (0 by default) */
  60088. y: number;
  60089. /** defines the third component (0 by default) */
  60090. z: number;
  60091. /** defines the fourth component (1.0 by default) */
  60092. w: number;
  60093. /**
  60094. * Creates a new Quaternion from the given floats
  60095. * @param x defines the first component (0 by default)
  60096. * @param y defines the second component (0 by default)
  60097. * @param z defines the third component (0 by default)
  60098. * @param w defines the fourth component (1.0 by default)
  60099. */
  60100. constructor(
  60101. /** defines the first component (0 by default) */
  60102. x?: number,
  60103. /** defines the second component (0 by default) */
  60104. y?: number,
  60105. /** defines the third component (0 by default) */
  60106. z?: number,
  60107. /** defines the fourth component (1.0 by default) */
  60108. w?: number);
  60109. /**
  60110. * Gets a string representation for the current quaternion
  60111. * @returns a string with the Quaternion coordinates
  60112. */
  60113. toString(): string;
  60114. /**
  60115. * Gets the class name of the quaternion
  60116. * @returns the string "Quaternion"
  60117. */
  60118. getClassName(): string;
  60119. /**
  60120. * Gets a hash code for this quaternion
  60121. * @returns the quaternion hash code
  60122. */
  60123. getHashCode(): number;
  60124. /**
  60125. * Copy the quaternion to an array
  60126. * @returns a new array populated with 4 elements from the quaternion coordinates
  60127. */
  60128. asArray(): number[];
  60129. /**
  60130. * Check if two quaternions are equals
  60131. * @param otherQuaternion defines the second operand
  60132. * @return true if the current quaternion and the given one coordinates are strictly equals
  60133. */
  60134. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60135. /**
  60136. * Clone the current quaternion
  60137. * @returns a new quaternion copied from the current one
  60138. */
  60139. clone(): Quaternion;
  60140. /**
  60141. * Copy a quaternion to the current one
  60142. * @param other defines the other quaternion
  60143. * @returns the updated current quaternion
  60144. */
  60145. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60146. /**
  60147. * Updates the current quaternion with the given float coordinates
  60148. * @param x defines the x coordinate
  60149. * @param y defines the y coordinate
  60150. * @param z defines the z coordinate
  60151. * @param w defines the w coordinate
  60152. * @returns the updated current quaternion
  60153. */
  60154. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60155. /**
  60156. * Updates the current quaternion from the given float coordinates
  60157. * @param x defines the x coordinate
  60158. * @param y defines the y coordinate
  60159. * @param z defines the z coordinate
  60160. * @param w defines the w coordinate
  60161. * @returns the updated current quaternion
  60162. */
  60163. set(x: number, y: number, z: number, w: number): Quaternion;
  60164. /**
  60165. * Adds two quaternions
  60166. * @param other defines the second operand
  60167. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60168. */
  60169. add(other: DeepImmutable<Quaternion>): Quaternion;
  60170. /**
  60171. * Add a quaternion to the current one
  60172. * @param other defines the quaternion to add
  60173. * @returns the current quaternion
  60174. */
  60175. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60176. /**
  60177. * Subtract two quaternions
  60178. * @param other defines the second operand
  60179. * @returns a new quaternion as the subtraction result of the given one from the current one
  60180. */
  60181. subtract(other: Quaternion): Quaternion;
  60182. /**
  60183. * Multiplies the current quaternion by a scale factor
  60184. * @param value defines the scale factor
  60185. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60186. */
  60187. scale(value: number): Quaternion;
  60188. /**
  60189. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60190. * @param scale defines the scale factor
  60191. * @param result defines the Quaternion object where to store the result
  60192. * @returns the unmodified current quaternion
  60193. */
  60194. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60195. /**
  60196. * Multiplies in place the current quaternion by a scale factor
  60197. * @param value defines the scale factor
  60198. * @returns the current modified quaternion
  60199. */
  60200. scaleInPlace(value: number): Quaternion;
  60201. /**
  60202. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60203. * @param scale defines the scale factor
  60204. * @param result defines the Quaternion object where to store the result
  60205. * @returns the unmodified current quaternion
  60206. */
  60207. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60208. /**
  60209. * Multiplies two quaternions
  60210. * @param q1 defines the second operand
  60211. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60212. */
  60213. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60214. /**
  60215. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60216. * @param q1 defines the second operand
  60217. * @param result defines the target quaternion
  60218. * @returns the current quaternion
  60219. */
  60220. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60221. /**
  60222. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60223. * @param q1 defines the second operand
  60224. * @returns the currentupdated quaternion
  60225. */
  60226. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60227. /**
  60228. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60229. * @param ref defines the target quaternion
  60230. * @returns the current quaternion
  60231. */
  60232. conjugateToRef(ref: Quaternion): Quaternion;
  60233. /**
  60234. * Conjugates in place (1-q) the current quaternion
  60235. * @returns the current updated quaternion
  60236. */
  60237. conjugateInPlace(): Quaternion;
  60238. /**
  60239. * Conjugates in place (1-q) the current quaternion
  60240. * @returns a new quaternion
  60241. */
  60242. conjugate(): Quaternion;
  60243. /**
  60244. * Gets length of current quaternion
  60245. * @returns the quaternion length (float)
  60246. */
  60247. length(): number;
  60248. /**
  60249. * Normalize in place the current quaternion
  60250. * @returns the current updated quaternion
  60251. */
  60252. normalize(): Quaternion;
  60253. /**
  60254. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60255. * @param order is a reserved parameter and is ignore for now
  60256. * @returns a new Vector3 containing the Euler angles
  60257. */
  60258. toEulerAngles(order?: string): Vector3;
  60259. /**
  60260. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60261. * @param result defines the vector which will be filled with the Euler angles
  60262. * @param order is a reserved parameter and is ignore for now
  60263. * @returns the current unchanged quaternion
  60264. */
  60265. toEulerAnglesToRef(result: Vector3): Quaternion;
  60266. /**
  60267. * Updates the given rotation matrix with the current quaternion values
  60268. * @param result defines the target matrix
  60269. * @returns the current unchanged quaternion
  60270. */
  60271. toRotationMatrix(result: Matrix): Quaternion;
  60272. /**
  60273. * Updates the current quaternion from the given rotation matrix values
  60274. * @param matrix defines the source matrix
  60275. * @returns the current updated quaternion
  60276. */
  60277. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60278. /**
  60279. * Creates a new quaternion from a rotation matrix
  60280. * @param matrix defines the source matrix
  60281. * @returns a new quaternion created from the given rotation matrix values
  60282. */
  60283. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  60284. /**
  60285. * Updates the given quaternion with the given rotation matrix values
  60286. * @param matrix defines the source matrix
  60287. * @param result defines the target quaternion
  60288. */
  60289. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  60290. /**
  60291. * Returns the dot product (float) between the quaternions "left" and "right"
  60292. * @param left defines the left operand
  60293. * @param right defines the right operand
  60294. * @returns the dot product
  60295. */
  60296. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  60297. /**
  60298. * Checks if the two quaternions are close to each other
  60299. * @param quat0 defines the first quaternion to check
  60300. * @param quat1 defines the second quaternion to check
  60301. * @returns true if the two quaternions are close to each other
  60302. */
  60303. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  60304. /**
  60305. * Creates an empty quaternion
  60306. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  60307. */
  60308. static Zero(): Quaternion;
  60309. /**
  60310. * Inverse a given quaternion
  60311. * @param q defines the source quaternion
  60312. * @returns a new quaternion as the inverted current quaternion
  60313. */
  60314. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  60315. /**
  60316. * Inverse a given quaternion
  60317. * @param q defines the source quaternion
  60318. * @param result the quaternion the result will be stored in
  60319. * @returns the result quaternion
  60320. */
  60321. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  60322. /**
  60323. * Creates an identity quaternion
  60324. * @returns the identity quaternion
  60325. */
  60326. static Identity(): Quaternion;
  60327. /**
  60328. * Gets a boolean indicating if the given quaternion is identity
  60329. * @param quaternion defines the quaternion to check
  60330. * @returns true if the quaternion is identity
  60331. */
  60332. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  60333. /**
  60334. * Creates a quaternion from a rotation around an axis
  60335. * @param axis defines the axis to use
  60336. * @param angle defines the angle to use
  60337. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  60338. */
  60339. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  60340. /**
  60341. * Creates a rotation around an axis and stores it into the given quaternion
  60342. * @param axis defines the axis to use
  60343. * @param angle defines the angle to use
  60344. * @param result defines the target quaternion
  60345. * @returns the target quaternion
  60346. */
  60347. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  60348. /**
  60349. * Creates a new quaternion from data stored into an array
  60350. * @param array defines the data source
  60351. * @param offset defines the offset in the source array where the data starts
  60352. * @returns a new quaternion
  60353. */
  60354. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  60355. /**
  60356. * Create a quaternion from Euler rotation angles
  60357. * @param x Pitch
  60358. * @param y Yaw
  60359. * @param z Roll
  60360. * @returns the new Quaternion
  60361. */
  60362. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  60363. /**
  60364. * Updates a quaternion from Euler rotation angles
  60365. * @param x Pitch
  60366. * @param y Yaw
  60367. * @param z Roll
  60368. * @param result the quaternion to store the result
  60369. * @returns the updated quaternion
  60370. */
  60371. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  60372. /**
  60373. * Create a quaternion from Euler rotation vector
  60374. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60375. * @returns the new Quaternion
  60376. */
  60377. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  60378. /**
  60379. * Updates a quaternion from Euler rotation vector
  60380. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  60381. * @param result the quaternion to store the result
  60382. * @returns the updated quaternion
  60383. */
  60384. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  60385. /**
  60386. * Creates a new quaternion from the given Euler float angles (y, x, z)
  60387. * @param yaw defines the rotation around Y axis
  60388. * @param pitch defines the rotation around X axis
  60389. * @param roll defines the rotation around Z axis
  60390. * @returns the new quaternion
  60391. */
  60392. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  60393. /**
  60394. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  60395. * @param yaw defines the rotation around Y axis
  60396. * @param pitch defines the rotation around X axis
  60397. * @param roll defines the rotation around Z axis
  60398. * @param result defines the target quaternion
  60399. */
  60400. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  60401. /**
  60402. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  60403. * @param alpha defines the rotation around first axis
  60404. * @param beta defines the rotation around second axis
  60405. * @param gamma defines the rotation around third axis
  60406. * @returns the new quaternion
  60407. */
  60408. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  60409. /**
  60410. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  60411. * @param alpha defines the rotation around first axis
  60412. * @param beta defines the rotation around second axis
  60413. * @param gamma defines the rotation around third axis
  60414. * @param result defines the target quaternion
  60415. */
  60416. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  60417. /**
  60418. * 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)
  60419. * @param axis1 defines the first axis
  60420. * @param axis2 defines the second axis
  60421. * @param axis3 defines the third axis
  60422. * @returns the new quaternion
  60423. */
  60424. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  60425. /**
  60426. * 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
  60427. * @param axis1 defines the first axis
  60428. * @param axis2 defines the second axis
  60429. * @param axis3 defines the third axis
  60430. * @param ref defines the target quaternion
  60431. */
  60432. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  60433. /**
  60434. * Interpolates between two quaternions
  60435. * @param left defines first quaternion
  60436. * @param right defines second quaternion
  60437. * @param amount defines the gradient to use
  60438. * @returns the new interpolated quaternion
  60439. */
  60440. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60441. /**
  60442. * Interpolates between two quaternions and stores it into a target quaternion
  60443. * @param left defines first quaternion
  60444. * @param right defines second quaternion
  60445. * @param amount defines the gradient to use
  60446. * @param result defines the target quaternion
  60447. */
  60448. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  60449. /**
  60450. * Interpolate between two quaternions using Hermite interpolation
  60451. * @param value1 defines first quaternion
  60452. * @param tangent1 defines the incoming tangent
  60453. * @param value2 defines second quaternion
  60454. * @param tangent2 defines the outgoing tangent
  60455. * @param amount defines the target quaternion
  60456. * @returns the new interpolated quaternion
  60457. */
  60458. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  60459. }
  60460. /**
  60461. * Class used to store matrix data (4x4)
  60462. */
  60463. export class Matrix {
  60464. private static _updateFlagSeed;
  60465. private static _identityReadOnly;
  60466. private _isIdentity;
  60467. private _isIdentityDirty;
  60468. private _isIdentity3x2;
  60469. private _isIdentity3x2Dirty;
  60470. /**
  60471. * Gets the update flag of the matrix which is an unique number for the matrix.
  60472. * It will be incremented every time the matrix data change.
  60473. * You can use it to speed the comparison between two versions of the same matrix.
  60474. */
  60475. updateFlag: number;
  60476. private readonly _m;
  60477. /**
  60478. * Gets the internal data of the matrix
  60479. */
  60480. readonly m: DeepImmutable<Float32Array>;
  60481. /** @hidden */
  60482. _markAsUpdated(): void;
  60483. /** @hidden */
  60484. private _updateIdentityStatus;
  60485. /**
  60486. * Creates an empty matrix (filled with zeros)
  60487. */
  60488. constructor();
  60489. /**
  60490. * Check if the current matrix is identity
  60491. * @returns true is the matrix is the identity matrix
  60492. */
  60493. isIdentity(): boolean;
  60494. /**
  60495. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  60496. * @returns true is the matrix is the identity matrix
  60497. */
  60498. isIdentityAs3x2(): boolean;
  60499. /**
  60500. * Gets the determinant of the matrix
  60501. * @returns the matrix determinant
  60502. */
  60503. determinant(): number;
  60504. /**
  60505. * Returns the matrix as a Float32Array
  60506. * @returns the matrix underlying array
  60507. */
  60508. toArray(): DeepImmutable<Float32Array>;
  60509. /**
  60510. * Returns the matrix as a Float32Array
  60511. * @returns the matrix underlying array.
  60512. */
  60513. asArray(): DeepImmutable<Float32Array>;
  60514. /**
  60515. * Inverts the current matrix in place
  60516. * @returns the current inverted matrix
  60517. */
  60518. invert(): Matrix;
  60519. /**
  60520. * Sets all the matrix elements to zero
  60521. * @returns the current matrix
  60522. */
  60523. reset(): Matrix;
  60524. /**
  60525. * Adds the current matrix with a second one
  60526. * @param other defines the matrix to add
  60527. * @returns a new matrix as the addition of the current matrix and the given one
  60528. */
  60529. add(other: DeepImmutable<Matrix>): Matrix;
  60530. /**
  60531. * Sets the given matrix "result" to the addition of the current matrix and the given one
  60532. * @param other defines the matrix to add
  60533. * @param result defines the target matrix
  60534. * @returns the current matrix
  60535. */
  60536. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60537. /**
  60538. * Adds in place the given matrix to the current matrix
  60539. * @param other defines the second operand
  60540. * @returns the current updated matrix
  60541. */
  60542. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  60543. /**
  60544. * Sets the given matrix to the current inverted Matrix
  60545. * @param other defines the target matrix
  60546. * @returns the unmodified current matrix
  60547. */
  60548. invertToRef(other: Matrix): Matrix;
  60549. /**
  60550. * add a value at the specified position in the current Matrix
  60551. * @param index the index of the value within the matrix. between 0 and 15.
  60552. * @param value the value to be added
  60553. * @returns the current updated matrix
  60554. */
  60555. addAtIndex(index: number, value: number): Matrix;
  60556. /**
  60557. * mutiply the specified position in the current Matrix by a value
  60558. * @param index the index of the value within the matrix. between 0 and 15.
  60559. * @param value the value to be added
  60560. * @returns the current updated matrix
  60561. */
  60562. multiplyAtIndex(index: number, value: number): Matrix;
  60563. /**
  60564. * Inserts the translation vector (using 3 floats) in the current matrix
  60565. * @param x defines the 1st component of the translation
  60566. * @param y defines the 2nd component of the translation
  60567. * @param z defines the 3rd component of the translation
  60568. * @returns the current updated matrix
  60569. */
  60570. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  60571. /**
  60572. * Inserts the translation vector in the current matrix
  60573. * @param vector3 defines the translation to insert
  60574. * @returns the current updated matrix
  60575. */
  60576. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  60577. /**
  60578. * Gets the translation value of the current matrix
  60579. * @returns a new Vector3 as the extracted translation from the matrix
  60580. */
  60581. getTranslation(): Vector3;
  60582. /**
  60583. * Fill a Vector3 with the extracted translation from the matrix
  60584. * @param result defines the Vector3 where to store the translation
  60585. * @returns the current matrix
  60586. */
  60587. getTranslationToRef(result: Vector3): Matrix;
  60588. /**
  60589. * Remove rotation and scaling part from the matrix
  60590. * @returns the updated matrix
  60591. */
  60592. removeRotationAndScaling(): Matrix;
  60593. /**
  60594. * Multiply two matrices
  60595. * @param other defines the second operand
  60596. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  60597. */
  60598. multiply(other: DeepImmutable<Matrix>): Matrix;
  60599. /**
  60600. * Copy the current matrix from the given one
  60601. * @param other defines the source matrix
  60602. * @returns the current updated matrix
  60603. */
  60604. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  60605. /**
  60606. * Populates the given array from the starting index with the current matrix values
  60607. * @param array defines the target array
  60608. * @param offset defines the offset in the target array where to start storing values
  60609. * @returns the current matrix
  60610. */
  60611. copyToArray(array: Float32Array, offset?: number): Matrix;
  60612. /**
  60613. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  60614. * @param other defines the second operand
  60615. * @param result defines the matrix where to store the multiplication
  60616. * @returns the current matrix
  60617. */
  60618. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  60619. /**
  60620. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  60621. * @param other defines the second operand
  60622. * @param result defines the array where to store the multiplication
  60623. * @param offset defines the offset in the target array where to start storing values
  60624. * @returns the current matrix
  60625. */
  60626. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  60627. /**
  60628. * Check equality between this matrix and a second one
  60629. * @param value defines the second matrix to compare
  60630. * @returns true is the current matrix and the given one values are strictly equal
  60631. */
  60632. equals(value: DeepImmutable<Matrix>): boolean;
  60633. /**
  60634. * Clone the current matrix
  60635. * @returns a new matrix from the current matrix
  60636. */
  60637. clone(): Matrix;
  60638. /**
  60639. * Returns the name of the current matrix class
  60640. * @returns the string "Matrix"
  60641. */
  60642. getClassName(): string;
  60643. /**
  60644. * Gets the hash code of the current matrix
  60645. * @returns the hash code
  60646. */
  60647. getHashCode(): number;
  60648. /**
  60649. * Decomposes the current Matrix into a translation, rotation and scaling components
  60650. * @param scale defines the scale vector3 given as a reference to update
  60651. * @param rotation defines the rotation quaternion given as a reference to update
  60652. * @param translation defines the translation vector3 given as a reference to update
  60653. * @returns true if operation was successful
  60654. */
  60655. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  60656. /**
  60657. * Gets specific row of the matrix
  60658. * @param index defines the number of the row to get
  60659. * @returns the index-th row of the current matrix as a new Vector4
  60660. */
  60661. getRow(index: number): Nullable<Vector4>;
  60662. /**
  60663. * Sets the index-th row of the current matrix to the vector4 values
  60664. * @param index defines the number of the row to set
  60665. * @param row defines the target vector4
  60666. * @returns the updated current matrix
  60667. */
  60668. setRow(index: number, row: Vector4): Matrix;
  60669. /**
  60670. * Compute the transpose of the matrix
  60671. * @returns the new transposed matrix
  60672. */
  60673. transpose(): Matrix;
  60674. /**
  60675. * Compute the transpose of the matrix and store it in a given matrix
  60676. * @param result defines the target matrix
  60677. * @returns the current matrix
  60678. */
  60679. transposeToRef(result: Matrix): Matrix;
  60680. /**
  60681. * Sets the index-th row of the current matrix with the given 4 x float values
  60682. * @param index defines the row index
  60683. * @param x defines the x component to set
  60684. * @param y defines the y component to set
  60685. * @param z defines the z component to set
  60686. * @param w defines the w component to set
  60687. * @returns the updated current matrix
  60688. */
  60689. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  60690. /**
  60691. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  60692. * @param scale defines the scale factor
  60693. * @returns a new matrix
  60694. */
  60695. scale(scale: number): Matrix;
  60696. /**
  60697. * Scale the current matrix values by a factor to a given result matrix
  60698. * @param scale defines the scale factor
  60699. * @param result defines the matrix to store the result
  60700. * @returns the current matrix
  60701. */
  60702. scaleToRef(scale: number, result: Matrix): Matrix;
  60703. /**
  60704. * Scale the current matrix values by a factor and add the result to a given matrix
  60705. * @param scale defines the scale factor
  60706. * @param result defines the Matrix to store the result
  60707. * @returns the current matrix
  60708. */
  60709. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  60710. /**
  60711. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  60712. * @param ref matrix to store the result
  60713. */
  60714. toNormalMatrix(ref: Matrix): void;
  60715. /**
  60716. * Gets only rotation part of the current matrix
  60717. * @returns a new matrix sets to the extracted rotation matrix from the current one
  60718. */
  60719. getRotationMatrix(): Matrix;
  60720. /**
  60721. * Extracts the rotation matrix from the current one and sets it as the given "result"
  60722. * @param result defines the target matrix to store data to
  60723. * @returns the current matrix
  60724. */
  60725. getRotationMatrixToRef(result: Matrix): Matrix;
  60726. /**
  60727. * Toggles model matrix from being right handed to left handed in place and vice versa
  60728. */
  60729. toggleModelMatrixHandInPlace(): void;
  60730. /**
  60731. * Toggles projection matrix from being right handed to left handed in place and vice versa
  60732. */
  60733. toggleProjectionMatrixHandInPlace(): void;
  60734. /**
  60735. * Creates a matrix from an array
  60736. * @param array defines the source array
  60737. * @param offset defines an offset in the source array
  60738. * @returns a new Matrix set from the starting index of the given array
  60739. */
  60740. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  60741. /**
  60742. * Copy the content of an array into a given matrix
  60743. * @param array defines the source array
  60744. * @param offset defines an offset in the source array
  60745. * @param result defines the target matrix
  60746. */
  60747. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  60748. /**
  60749. * Stores an array into a matrix after having multiplied each component by a given factor
  60750. * @param array defines the source array
  60751. * @param offset defines the offset in the source array
  60752. * @param scale defines the scaling factor
  60753. * @param result defines the target matrix
  60754. */
  60755. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  60756. /**
  60757. * Gets an identity matrix that must not be updated
  60758. */
  60759. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  60760. /**
  60761. * Stores a list of values (16) inside a given matrix
  60762. * @param initialM11 defines 1st value of 1st row
  60763. * @param initialM12 defines 2nd value of 1st row
  60764. * @param initialM13 defines 3rd value of 1st row
  60765. * @param initialM14 defines 4th value of 1st row
  60766. * @param initialM21 defines 1st value of 2nd row
  60767. * @param initialM22 defines 2nd value of 2nd row
  60768. * @param initialM23 defines 3rd value of 2nd row
  60769. * @param initialM24 defines 4th value of 2nd row
  60770. * @param initialM31 defines 1st value of 3rd row
  60771. * @param initialM32 defines 2nd value of 3rd row
  60772. * @param initialM33 defines 3rd value of 3rd row
  60773. * @param initialM34 defines 4th value of 3rd row
  60774. * @param initialM41 defines 1st value of 4th row
  60775. * @param initialM42 defines 2nd value of 4th row
  60776. * @param initialM43 defines 3rd value of 4th row
  60777. * @param initialM44 defines 4th value of 4th row
  60778. * @param result defines the target matrix
  60779. */
  60780. 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;
  60781. /**
  60782. * Creates new matrix from a list of values (16)
  60783. * @param initialM11 defines 1st value of 1st row
  60784. * @param initialM12 defines 2nd value of 1st row
  60785. * @param initialM13 defines 3rd value of 1st row
  60786. * @param initialM14 defines 4th value of 1st row
  60787. * @param initialM21 defines 1st value of 2nd row
  60788. * @param initialM22 defines 2nd value of 2nd row
  60789. * @param initialM23 defines 3rd value of 2nd row
  60790. * @param initialM24 defines 4th value of 2nd row
  60791. * @param initialM31 defines 1st value of 3rd row
  60792. * @param initialM32 defines 2nd value of 3rd row
  60793. * @param initialM33 defines 3rd value of 3rd row
  60794. * @param initialM34 defines 4th value of 3rd row
  60795. * @param initialM41 defines 1st value of 4th row
  60796. * @param initialM42 defines 2nd value of 4th row
  60797. * @param initialM43 defines 3rd value of 4th row
  60798. * @param initialM44 defines 4th value of 4th row
  60799. * @returns the new matrix
  60800. */
  60801. 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;
  60802. /**
  60803. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60804. * @param scale defines the scale vector3
  60805. * @param rotation defines the rotation quaternion
  60806. * @param translation defines the translation vector3
  60807. * @returns a new matrix
  60808. */
  60809. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  60810. /**
  60811. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  60812. * @param scale defines the scale vector3
  60813. * @param rotation defines the rotation quaternion
  60814. * @param translation defines the translation vector3
  60815. * @param result defines the target matrix
  60816. */
  60817. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  60818. /**
  60819. * Creates a new identity matrix
  60820. * @returns a new identity matrix
  60821. */
  60822. static Identity(): Matrix;
  60823. /**
  60824. * Creates a new identity matrix and stores the result in a given matrix
  60825. * @param result defines the target matrix
  60826. */
  60827. static IdentityToRef(result: Matrix): void;
  60828. /**
  60829. * Creates a new zero matrix
  60830. * @returns a new zero matrix
  60831. */
  60832. static Zero(): Matrix;
  60833. /**
  60834. * Creates a new rotation matrix for "angle" radians around the X axis
  60835. * @param angle defines the angle (in radians) to use
  60836. * @return the new matrix
  60837. */
  60838. static RotationX(angle: number): Matrix;
  60839. /**
  60840. * Creates a new matrix as the invert of a given matrix
  60841. * @param source defines the source matrix
  60842. * @returns the new matrix
  60843. */
  60844. static Invert(source: DeepImmutable<Matrix>): Matrix;
  60845. /**
  60846. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  60847. * @param angle defines the angle (in radians) to use
  60848. * @param result defines the target matrix
  60849. */
  60850. static RotationXToRef(angle: number, result: Matrix): void;
  60851. /**
  60852. * Creates a new rotation matrix for "angle" radians around the Y axis
  60853. * @param angle defines the angle (in radians) to use
  60854. * @return the new matrix
  60855. */
  60856. static RotationY(angle: number): Matrix;
  60857. /**
  60858. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  60859. * @param angle defines the angle (in radians) to use
  60860. * @param result defines the target matrix
  60861. */
  60862. static RotationYToRef(angle: number, result: Matrix): void;
  60863. /**
  60864. * Creates a new rotation matrix for "angle" radians around the Z axis
  60865. * @param angle defines the angle (in radians) to use
  60866. * @return the new matrix
  60867. */
  60868. static RotationZ(angle: number): Matrix;
  60869. /**
  60870. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  60871. * @param angle defines the angle (in radians) to use
  60872. * @param result defines the target matrix
  60873. */
  60874. static RotationZToRef(angle: number, result: Matrix): void;
  60875. /**
  60876. * Creates a new rotation matrix for "angle" radians around the given axis
  60877. * @param axis defines the axis to use
  60878. * @param angle defines the angle (in radians) to use
  60879. * @return the new matrix
  60880. */
  60881. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  60882. /**
  60883. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  60884. * @param axis defines the axis to use
  60885. * @param angle defines the angle (in radians) to use
  60886. * @param result defines the target matrix
  60887. */
  60888. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  60889. /**
  60890. * Creates a rotation matrix
  60891. * @param yaw defines the yaw angle in radians (Y axis)
  60892. * @param pitch defines the pitch angle in radians (X axis)
  60893. * @param roll defines the roll angle in radians (X axis)
  60894. * @returns the new rotation matrix
  60895. */
  60896. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  60897. /**
  60898. * Creates a rotation matrix and stores it in a given matrix
  60899. * @param yaw defines the yaw angle in radians (Y axis)
  60900. * @param pitch defines the pitch angle in radians (X axis)
  60901. * @param roll defines the roll angle in radians (X axis)
  60902. * @param result defines the target matrix
  60903. */
  60904. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  60905. /**
  60906. * Creates a scaling matrix
  60907. * @param x defines the scale factor on X axis
  60908. * @param y defines the scale factor on Y axis
  60909. * @param z defines the scale factor on Z axis
  60910. * @returns the new matrix
  60911. */
  60912. static Scaling(x: number, y: number, z: number): Matrix;
  60913. /**
  60914. * Creates a scaling matrix and stores it in a given matrix
  60915. * @param x defines the scale factor on X axis
  60916. * @param y defines the scale factor on Y axis
  60917. * @param z defines the scale factor on Z axis
  60918. * @param result defines the target matrix
  60919. */
  60920. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  60921. /**
  60922. * Creates a translation matrix
  60923. * @param x defines the translation on X axis
  60924. * @param y defines the translation on Y axis
  60925. * @param z defines the translationon Z axis
  60926. * @returns the new matrix
  60927. */
  60928. static Translation(x: number, y: number, z: number): Matrix;
  60929. /**
  60930. * Creates a translation matrix and stores it in a given matrix
  60931. * @param x defines the translation on X axis
  60932. * @param y defines the translation on Y axis
  60933. * @param z defines the translationon Z axis
  60934. * @param result defines the target matrix
  60935. */
  60936. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  60937. /**
  60938. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60939. * @param startValue defines the start value
  60940. * @param endValue defines the end value
  60941. * @param gradient defines the gradient factor
  60942. * @returns the new matrix
  60943. */
  60944. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60945. /**
  60946. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  60947. * @param startValue defines the start value
  60948. * @param endValue defines the end value
  60949. * @param gradient defines the gradient factor
  60950. * @param result defines the Matrix object where to store data
  60951. */
  60952. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60953. /**
  60954. * Builds a new matrix whose values are computed by:
  60955. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60956. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60957. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60958. * @param startValue defines the first matrix
  60959. * @param endValue defines the second matrix
  60960. * @param gradient defines the gradient between the two matrices
  60961. * @returns the new matrix
  60962. */
  60963. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  60964. /**
  60965. * Update a matrix to values which are computed by:
  60966. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  60967. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  60968. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  60969. * @param startValue defines the first matrix
  60970. * @param endValue defines the second matrix
  60971. * @param gradient defines the gradient between the two matrices
  60972. * @param result defines the target matrix
  60973. */
  60974. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  60975. /**
  60976. * 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"
  60977. * This function works in left handed mode
  60978. * @param eye defines the final position of the entity
  60979. * @param target defines where the entity should look at
  60980. * @param up defines the up vector for the entity
  60981. * @returns the new matrix
  60982. */
  60983. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  60984. /**
  60985. * 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".
  60986. * This function works in left handed mode
  60987. * @param eye defines the final position of the entity
  60988. * @param target defines where the entity should look at
  60989. * @param up defines the up vector for the entity
  60990. * @param result defines the target matrix
  60991. */
  60992. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  60993. /**
  60994. * 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"
  60995. * This function works in right handed mode
  60996. * @param eye defines the final position of the entity
  60997. * @param target defines where the entity should look at
  60998. * @param up defines the up vector for the entity
  60999. * @returns the new matrix
  61000. */
  61001. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61002. /**
  61003. * 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".
  61004. * This function works in right handed mode
  61005. * @param eye defines the final position of the entity
  61006. * @param target defines where the entity should look at
  61007. * @param up defines the up vector for the entity
  61008. * @param result defines the target matrix
  61009. */
  61010. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61011. /**
  61012. * Create a left-handed orthographic projection matrix
  61013. * @param width defines the viewport width
  61014. * @param height defines the viewport height
  61015. * @param znear defines the near clip plane
  61016. * @param zfar defines the far clip plane
  61017. * @returns a new matrix as a left-handed orthographic projection matrix
  61018. */
  61019. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61020. /**
  61021. * Store a left-handed orthographic projection to a given matrix
  61022. * @param width defines the viewport width
  61023. * @param height defines the viewport height
  61024. * @param znear defines the near clip plane
  61025. * @param zfar defines the far clip plane
  61026. * @param result defines the target matrix
  61027. */
  61028. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61029. /**
  61030. * Create a left-handed orthographic projection matrix
  61031. * @param left defines the viewport left coordinate
  61032. * @param right defines the viewport right coordinate
  61033. * @param bottom defines the viewport bottom coordinate
  61034. * @param top defines the viewport top coordinate
  61035. * @param znear defines the near clip plane
  61036. * @param zfar defines the far clip plane
  61037. * @returns a new matrix as a left-handed orthographic projection matrix
  61038. */
  61039. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61040. /**
  61041. * Stores a left-handed orthographic projection into a given matrix
  61042. * @param left defines the viewport left coordinate
  61043. * @param right defines the viewport right coordinate
  61044. * @param bottom defines the viewport bottom coordinate
  61045. * @param top defines the viewport top coordinate
  61046. * @param znear defines the near clip plane
  61047. * @param zfar defines the far clip plane
  61048. * @param result defines the target matrix
  61049. */
  61050. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61051. /**
  61052. * Creates a right-handed orthographic projection matrix
  61053. * @param left defines the viewport left coordinate
  61054. * @param right defines the viewport right coordinate
  61055. * @param bottom defines the viewport bottom coordinate
  61056. * @param top defines the viewport top coordinate
  61057. * @param znear defines the near clip plane
  61058. * @param zfar defines the far clip plane
  61059. * @returns a new matrix as a right-handed orthographic projection matrix
  61060. */
  61061. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61062. /**
  61063. * Stores a right-handed orthographic projection into a given matrix
  61064. * @param left defines the viewport left coordinate
  61065. * @param right defines the viewport right coordinate
  61066. * @param bottom defines the viewport bottom coordinate
  61067. * @param top defines the viewport top coordinate
  61068. * @param znear defines the near clip plane
  61069. * @param zfar defines the far clip plane
  61070. * @param result defines the target matrix
  61071. */
  61072. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61073. /**
  61074. * Creates a left-handed perspective projection matrix
  61075. * @param width defines the viewport width
  61076. * @param height defines the viewport height
  61077. * @param znear defines the near clip plane
  61078. * @param zfar defines the far clip plane
  61079. * @returns a new matrix as a left-handed perspective projection matrix
  61080. */
  61081. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61082. /**
  61083. * Creates a left-handed perspective projection matrix
  61084. * @param fov defines the horizontal field of view
  61085. * @param aspect defines the aspect ratio
  61086. * @param znear defines the near clip plane
  61087. * @param zfar defines the far clip plane
  61088. * @returns a new matrix as a left-handed perspective projection matrix
  61089. */
  61090. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61091. /**
  61092. * Stores a left-handed perspective projection into a given matrix
  61093. * @param fov defines the horizontal field of view
  61094. * @param aspect defines the aspect ratio
  61095. * @param znear defines the near clip plane
  61096. * @param zfar defines the far clip plane
  61097. * @param result defines the target matrix
  61098. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61099. */
  61100. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61101. /**
  61102. * Creates a right-handed perspective projection matrix
  61103. * @param fov defines the horizontal field of view
  61104. * @param aspect defines the aspect ratio
  61105. * @param znear defines the near clip plane
  61106. * @param zfar defines the far clip plane
  61107. * @returns a new matrix as a right-handed perspective projection matrix
  61108. */
  61109. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61110. /**
  61111. * Stores a right-handed perspective projection into a given matrix
  61112. * @param fov defines the horizontal field of view
  61113. * @param aspect defines the aspect ratio
  61114. * @param znear defines the near clip plane
  61115. * @param zfar defines the far clip plane
  61116. * @param result defines the target matrix
  61117. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61118. */
  61119. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61120. /**
  61121. * Stores a perspective projection for WebVR info a given matrix
  61122. * @param fov defines the field of view
  61123. * @param znear defines the near clip plane
  61124. * @param zfar defines the far clip plane
  61125. * @param result defines the target matrix
  61126. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61127. */
  61128. static PerspectiveFovWebVRToRef(fov: {
  61129. upDegrees: number;
  61130. downDegrees: number;
  61131. leftDegrees: number;
  61132. rightDegrees: number;
  61133. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61134. /**
  61135. * Computes a complete transformation matrix
  61136. * @param viewport defines the viewport to use
  61137. * @param world defines the world matrix
  61138. * @param view defines the view matrix
  61139. * @param projection defines the projection matrix
  61140. * @param zmin defines the near clip plane
  61141. * @param zmax defines the far clip plane
  61142. * @returns the transformation matrix
  61143. */
  61144. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61145. /**
  61146. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61147. * @param matrix defines the matrix to use
  61148. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61149. */
  61150. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61151. /**
  61152. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61153. * @param matrix defines the matrix to use
  61154. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61155. */
  61156. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61157. /**
  61158. * Compute the transpose of a given matrix
  61159. * @param matrix defines the matrix to transpose
  61160. * @returns the new matrix
  61161. */
  61162. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61163. /**
  61164. * Compute the transpose of a matrix and store it in a target matrix
  61165. * @param matrix defines the matrix to transpose
  61166. * @param result defines the target matrix
  61167. */
  61168. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61169. /**
  61170. * Computes a reflection matrix from a plane
  61171. * @param plane defines the reflection plane
  61172. * @returns a new matrix
  61173. */
  61174. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61175. /**
  61176. * Computes a reflection matrix from a plane
  61177. * @param plane defines the reflection plane
  61178. * @param result defines the target matrix
  61179. */
  61180. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61181. /**
  61182. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61183. * @param xaxis defines the value of the 1st axis
  61184. * @param yaxis defines the value of the 2nd axis
  61185. * @param zaxis defines the value of the 3rd axis
  61186. * @param result defines the target matrix
  61187. */
  61188. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61189. /**
  61190. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61191. * @param quat defines the quaternion to use
  61192. * @param result defines the target matrix
  61193. */
  61194. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61195. }
  61196. /**
  61197. * Represens a plane by the equation ax + by + cz + d = 0
  61198. */
  61199. export class Plane {
  61200. /**
  61201. * Normal of the plane (a,b,c)
  61202. */
  61203. normal: Vector3;
  61204. /**
  61205. * d component of the plane
  61206. */
  61207. d: number;
  61208. /**
  61209. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61210. * @param a a component of the plane
  61211. * @param b b component of the plane
  61212. * @param c c component of the plane
  61213. * @param d d component of the plane
  61214. */
  61215. constructor(a: number, b: number, c: number, d: number);
  61216. /**
  61217. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61218. */
  61219. asArray(): number[];
  61220. /**
  61221. * @returns a new plane copied from the current Plane.
  61222. */
  61223. clone(): Plane;
  61224. /**
  61225. * @returns the string "Plane".
  61226. */
  61227. getClassName(): string;
  61228. /**
  61229. * @returns the Plane hash code.
  61230. */
  61231. getHashCode(): number;
  61232. /**
  61233. * Normalize the current Plane in place.
  61234. * @returns the updated Plane.
  61235. */
  61236. normalize(): Plane;
  61237. /**
  61238. * Applies a transformation the plane and returns the result
  61239. * @param transformation the transformation matrix to be applied to the plane
  61240. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61241. */
  61242. transform(transformation: DeepImmutable<Matrix>): Plane;
  61243. /**
  61244. * Calcualtte the dot product between the point and the plane normal
  61245. * @param point point to calculate the dot product with
  61246. * @returns the dot product (float) of the point coordinates and the plane normal.
  61247. */
  61248. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61249. /**
  61250. * Updates the current Plane from the plane defined by the three given points.
  61251. * @param point1 one of the points used to contruct the plane
  61252. * @param point2 one of the points used to contruct the plane
  61253. * @param point3 one of the points used to contruct the plane
  61254. * @returns the updated Plane.
  61255. */
  61256. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61257. /**
  61258. * Checks if the plane is facing a given direction
  61259. * @param direction the direction to check if the plane is facing
  61260. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61261. * @returns True is the vector "direction" is the same side than the plane normal.
  61262. */
  61263. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61264. /**
  61265. * Calculates the distance to a point
  61266. * @param point point to calculate distance to
  61267. * @returns the signed distance (float) from the given point to the Plane.
  61268. */
  61269. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61270. /**
  61271. * Creates a plane from an array
  61272. * @param array the array to create a plane from
  61273. * @returns a new Plane from the given array.
  61274. */
  61275. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  61276. /**
  61277. * Creates a plane from three points
  61278. * @param point1 point used to create the plane
  61279. * @param point2 point used to create the plane
  61280. * @param point3 point used to create the plane
  61281. * @returns a new Plane defined by the three given points.
  61282. */
  61283. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61284. /**
  61285. * Creates a plane from an origin point and a normal
  61286. * @param origin origin of the plane to be constructed
  61287. * @param normal normal of the plane to be constructed
  61288. * @returns a new Plane the normal vector to this plane at the given origin point.
  61289. * Note : the vector "normal" is updated because normalized.
  61290. */
  61291. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  61292. /**
  61293. * Calculates the distance from a plane and a point
  61294. * @param origin origin of the plane to be constructed
  61295. * @param normal normal of the plane to be constructed
  61296. * @param point point to calculate distance to
  61297. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  61298. */
  61299. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  61300. }
  61301. /**
  61302. * Class used to represent a viewport on screen
  61303. */
  61304. export class Viewport {
  61305. /** viewport left coordinate */
  61306. x: number;
  61307. /** viewport top coordinate */
  61308. y: number;
  61309. /**viewport width */
  61310. width: number;
  61311. /** viewport height */
  61312. height: number;
  61313. /**
  61314. * Creates a Viewport object located at (x, y) and sized (width, height)
  61315. * @param x defines viewport left coordinate
  61316. * @param y defines viewport top coordinate
  61317. * @param width defines the viewport width
  61318. * @param height defines the viewport height
  61319. */
  61320. constructor(
  61321. /** viewport left coordinate */
  61322. x: number,
  61323. /** viewport top coordinate */
  61324. y: number,
  61325. /**viewport width */
  61326. width: number,
  61327. /** viewport height */
  61328. height: number);
  61329. /**
  61330. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  61331. * @param renderWidth defines the rendering width
  61332. * @param renderHeight defines the rendering height
  61333. * @returns a new Viewport
  61334. */
  61335. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  61336. /**
  61337. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  61338. * @param renderWidth defines the rendering width
  61339. * @param renderHeight defines the rendering height
  61340. * @param ref defines the target viewport
  61341. * @returns the current viewport
  61342. */
  61343. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  61344. /**
  61345. * Returns a new Viewport copied from the current one
  61346. * @returns a new Viewport
  61347. */
  61348. clone(): Viewport;
  61349. }
  61350. /**
  61351. * Reprasents a camera frustum
  61352. */
  61353. export class Frustum {
  61354. /**
  61355. * Gets the planes representing the frustum
  61356. * @param transform matrix to be applied to the returned planes
  61357. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  61358. */
  61359. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  61360. /**
  61361. * Gets the near frustum plane transformed by the transform matrix
  61362. * @param transform transformation matrix to be applied to the resulting frustum plane
  61363. * @param frustumPlane the resuling frustum plane
  61364. */
  61365. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61366. /**
  61367. * Gets the far frustum plane transformed by the transform matrix
  61368. * @param transform transformation matrix to be applied to the resulting frustum plane
  61369. * @param frustumPlane the resuling frustum plane
  61370. */
  61371. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61372. /**
  61373. * Gets the left frustum plane transformed by the transform matrix
  61374. * @param transform transformation matrix to be applied to the resulting frustum plane
  61375. * @param frustumPlane the resuling frustum plane
  61376. */
  61377. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61378. /**
  61379. * Gets the right frustum plane transformed by the transform matrix
  61380. * @param transform transformation matrix to be applied to the resulting frustum plane
  61381. * @param frustumPlane the resuling frustum plane
  61382. */
  61383. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61384. /**
  61385. * Gets the top frustum plane transformed by the transform matrix
  61386. * @param transform transformation matrix to be applied to the resulting frustum plane
  61387. * @param frustumPlane the resuling frustum plane
  61388. */
  61389. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61390. /**
  61391. * Gets the bottom frustum plane transformed by the transform matrix
  61392. * @param transform transformation matrix to be applied to the resulting frustum plane
  61393. * @param frustumPlane the resuling frustum plane
  61394. */
  61395. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  61396. /**
  61397. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  61398. * @param transform transformation matrix to be applied to the resulting frustum planes
  61399. * @param frustumPlanes the resuling frustum planes
  61400. */
  61401. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  61402. }
  61403. /** Defines supported spaces */
  61404. export enum Space {
  61405. /** Local (object) space */
  61406. LOCAL = 0,
  61407. /** World space */
  61408. WORLD = 1,
  61409. /** Bone space */
  61410. BONE = 2
  61411. }
  61412. /** Defines the 3 main axes */
  61413. export class Axis {
  61414. /** X axis */
  61415. static X: Vector3;
  61416. /** Y axis */
  61417. static Y: Vector3;
  61418. /** Z axis */
  61419. static Z: Vector3;
  61420. }
  61421. /** Class used to represent a Bezier curve */
  61422. export class BezierCurve {
  61423. /**
  61424. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  61425. * @param t defines the time
  61426. * @param x1 defines the left coordinate on X axis
  61427. * @param y1 defines the left coordinate on Y axis
  61428. * @param x2 defines the right coordinate on X axis
  61429. * @param y2 defines the right coordinate on Y axis
  61430. * @returns the interpolated value
  61431. */
  61432. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  61433. }
  61434. /**
  61435. * Defines potential orientation for back face culling
  61436. */
  61437. export enum Orientation {
  61438. /**
  61439. * Clockwise
  61440. */
  61441. CW = 0,
  61442. /** Counter clockwise */
  61443. CCW = 1
  61444. }
  61445. /**
  61446. * Defines angle representation
  61447. */
  61448. export class Angle {
  61449. private _radians;
  61450. /**
  61451. * Creates an Angle object of "radians" radians (float).
  61452. * @param radians the angle in radians
  61453. */
  61454. constructor(radians: number);
  61455. /**
  61456. * Get value in degrees
  61457. * @returns the Angle value in degrees (float)
  61458. */
  61459. degrees(): number;
  61460. /**
  61461. * Get value in radians
  61462. * @returns the Angle value in radians (float)
  61463. */
  61464. radians(): number;
  61465. /**
  61466. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  61467. * @param a defines first vector
  61468. * @param b defines second vector
  61469. * @returns a new Angle
  61470. */
  61471. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  61472. /**
  61473. * Gets a new Angle object from the given float in radians
  61474. * @param radians defines the angle value in radians
  61475. * @returns a new Angle
  61476. */
  61477. static FromRadians(radians: number): Angle;
  61478. /**
  61479. * Gets a new Angle object from the given float in degrees
  61480. * @param degrees defines the angle value in degrees
  61481. * @returns a new Angle
  61482. */
  61483. static FromDegrees(degrees: number): Angle;
  61484. }
  61485. /**
  61486. * This represents an arc in a 2d space.
  61487. */
  61488. export class Arc2 {
  61489. /** Defines the start point of the arc */
  61490. startPoint: Vector2;
  61491. /** Defines the mid point of the arc */
  61492. midPoint: Vector2;
  61493. /** Defines the end point of the arc */
  61494. endPoint: Vector2;
  61495. /**
  61496. * Defines the center point of the arc.
  61497. */
  61498. centerPoint: Vector2;
  61499. /**
  61500. * Defines the radius of the arc.
  61501. */
  61502. radius: number;
  61503. /**
  61504. * Defines the angle of the arc (from mid point to end point).
  61505. */
  61506. angle: Angle;
  61507. /**
  61508. * Defines the start angle of the arc (from start point to middle point).
  61509. */
  61510. startAngle: Angle;
  61511. /**
  61512. * Defines the orientation of the arc (clock wise/counter clock wise).
  61513. */
  61514. orientation: Orientation;
  61515. /**
  61516. * Creates an Arc object from the three given points : start, middle and end.
  61517. * @param startPoint Defines the start point of the arc
  61518. * @param midPoint Defines the midlle point of the arc
  61519. * @param endPoint Defines the end point of the arc
  61520. */
  61521. constructor(
  61522. /** Defines the start point of the arc */
  61523. startPoint: Vector2,
  61524. /** Defines the mid point of the arc */
  61525. midPoint: Vector2,
  61526. /** Defines the end point of the arc */
  61527. endPoint: Vector2);
  61528. }
  61529. /**
  61530. * Represents a 2D path made up of multiple 2D points
  61531. */
  61532. export class Path2 {
  61533. private _points;
  61534. private _length;
  61535. /**
  61536. * If the path start and end point are the same
  61537. */
  61538. closed: boolean;
  61539. /**
  61540. * Creates a Path2 object from the starting 2D coordinates x and y.
  61541. * @param x the starting points x value
  61542. * @param y the starting points y value
  61543. */
  61544. constructor(x: number, y: number);
  61545. /**
  61546. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  61547. * @param x the added points x value
  61548. * @param y the added points y value
  61549. * @returns the updated Path2.
  61550. */
  61551. addLineTo(x: number, y: number): Path2;
  61552. /**
  61553. * 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.
  61554. * @param midX middle point x value
  61555. * @param midY middle point y value
  61556. * @param endX end point x value
  61557. * @param endY end point y value
  61558. * @param numberOfSegments (default: 36)
  61559. * @returns the updated Path2.
  61560. */
  61561. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  61562. /**
  61563. * Closes the Path2.
  61564. * @returns the Path2.
  61565. */
  61566. close(): Path2;
  61567. /**
  61568. * Gets the sum of the distance between each sequential point in the path
  61569. * @returns the Path2 total length (float).
  61570. */
  61571. length(): number;
  61572. /**
  61573. * Gets the points which construct the path
  61574. * @returns the Path2 internal array of points.
  61575. */
  61576. getPoints(): Vector2[];
  61577. /**
  61578. * Retreives the point at the distance aways from the starting point
  61579. * @param normalizedLengthPosition the length along the path to retreive the point from
  61580. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  61581. */
  61582. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  61583. /**
  61584. * Creates a new path starting from an x and y position
  61585. * @param x starting x value
  61586. * @param y starting y value
  61587. * @returns a new Path2 starting at the coordinates (x, y).
  61588. */
  61589. static StartingAt(x: number, y: number): Path2;
  61590. }
  61591. /**
  61592. * Represents a 3D path made up of multiple 3D points
  61593. */
  61594. export class Path3D {
  61595. /**
  61596. * an array of Vector3, the curve axis of the Path3D
  61597. */
  61598. path: Vector3[];
  61599. private _curve;
  61600. private _distances;
  61601. private _tangents;
  61602. private _normals;
  61603. private _binormals;
  61604. private _raw;
  61605. /**
  61606. * new Path3D(path, normal, raw)
  61607. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  61608. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  61609. * @param path an array of Vector3, the curve axis of the Path3D
  61610. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  61611. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  61612. */
  61613. constructor(
  61614. /**
  61615. * an array of Vector3, the curve axis of the Path3D
  61616. */
  61617. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  61618. /**
  61619. * Returns the Path3D array of successive Vector3 designing its curve.
  61620. * @returns the Path3D array of successive Vector3 designing its curve.
  61621. */
  61622. getCurve(): Vector3[];
  61623. /**
  61624. * Returns an array populated with tangent vectors on each Path3D curve point.
  61625. * @returns an array populated with tangent vectors on each Path3D curve point.
  61626. */
  61627. getTangents(): Vector3[];
  61628. /**
  61629. * Returns an array populated with normal vectors on each Path3D curve point.
  61630. * @returns an array populated with normal vectors on each Path3D curve point.
  61631. */
  61632. getNormals(): Vector3[];
  61633. /**
  61634. * Returns an array populated with binormal vectors on each Path3D curve point.
  61635. * @returns an array populated with binormal vectors on each Path3D curve point.
  61636. */
  61637. getBinormals(): Vector3[];
  61638. /**
  61639. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  61640. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  61641. */
  61642. getDistances(): number[];
  61643. /**
  61644. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  61645. * @param path path which all values are copied into the curves points
  61646. * @param firstNormal which should be projected onto the curve
  61647. * @returns the same object updated.
  61648. */
  61649. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  61650. private _compute;
  61651. private _getFirstNonNullVector;
  61652. private _getLastNonNullVector;
  61653. private _normalVector;
  61654. }
  61655. /**
  61656. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61657. * A Curve3 is designed from a series of successive Vector3.
  61658. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  61659. */
  61660. export class Curve3 {
  61661. private _points;
  61662. private _length;
  61663. /**
  61664. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  61665. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  61666. * @param v1 (Vector3) the control point
  61667. * @param v2 (Vector3) the end point of the Quadratic Bezier
  61668. * @param nbPoints (integer) the wanted number of points in the curve
  61669. * @returns the created Curve3
  61670. */
  61671. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61672. /**
  61673. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  61674. * @param v0 (Vector3) the origin point of the Cubic Bezier
  61675. * @param v1 (Vector3) the first control point
  61676. * @param v2 (Vector3) the second control point
  61677. * @param v3 (Vector3) the end point of the Cubic Bezier
  61678. * @param nbPoints (integer) the wanted number of points in the curve
  61679. * @returns the created Curve3
  61680. */
  61681. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61682. /**
  61683. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  61684. * @param p1 (Vector3) the origin point of the Hermite Spline
  61685. * @param t1 (Vector3) the tangent vector at the origin point
  61686. * @param p2 (Vector3) the end point of the Hermite Spline
  61687. * @param t2 (Vector3) the tangent vector at the end point
  61688. * @param nbPoints (integer) the wanted number of points in the curve
  61689. * @returns the created Curve3
  61690. */
  61691. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  61692. /**
  61693. * Returns a Curve3 object along a CatmullRom Spline curve :
  61694. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  61695. * @param nbPoints (integer) the wanted number of points between each curve control points
  61696. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  61697. * @returns the created Curve3
  61698. */
  61699. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  61700. /**
  61701. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  61702. * A Curve3 is designed from a series of successive Vector3.
  61703. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  61704. * @param points points which make up the curve
  61705. */
  61706. constructor(points: Vector3[]);
  61707. /**
  61708. * @returns the Curve3 stored array of successive Vector3
  61709. */
  61710. getPoints(): Vector3[];
  61711. /**
  61712. * @returns the computed length (float) of the curve.
  61713. */
  61714. length(): number;
  61715. /**
  61716. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  61717. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  61718. * curveA and curveB keep unchanged.
  61719. * @param curve the curve to continue from this curve
  61720. * @returns the newly constructed curve
  61721. */
  61722. continue(curve: DeepImmutable<Curve3>): Curve3;
  61723. private _computeLength;
  61724. }
  61725. /**
  61726. * Contains position and normal vectors for a vertex
  61727. */
  61728. export class PositionNormalVertex {
  61729. /** the position of the vertex (defaut: 0,0,0) */
  61730. position: Vector3;
  61731. /** the normal of the vertex (defaut: 0,1,0) */
  61732. normal: Vector3;
  61733. /**
  61734. * Creates a PositionNormalVertex
  61735. * @param position the position of the vertex (defaut: 0,0,0)
  61736. * @param normal the normal of the vertex (defaut: 0,1,0)
  61737. */
  61738. constructor(
  61739. /** the position of the vertex (defaut: 0,0,0) */
  61740. position?: Vector3,
  61741. /** the normal of the vertex (defaut: 0,1,0) */
  61742. normal?: Vector3);
  61743. /**
  61744. * Clones the PositionNormalVertex
  61745. * @returns the cloned PositionNormalVertex
  61746. */
  61747. clone(): PositionNormalVertex;
  61748. }
  61749. /**
  61750. * Contains position, normal and uv vectors for a vertex
  61751. */
  61752. export class PositionNormalTextureVertex {
  61753. /** the position of the vertex (defaut: 0,0,0) */
  61754. position: Vector3;
  61755. /** the normal of the vertex (defaut: 0,1,0) */
  61756. normal: Vector3;
  61757. /** the uv of the vertex (default: 0,0) */
  61758. uv: Vector2;
  61759. /**
  61760. * Creates a PositionNormalTextureVertex
  61761. * @param position the position of the vertex (defaut: 0,0,0)
  61762. * @param normal the normal of the vertex (defaut: 0,1,0)
  61763. * @param uv the uv of the vertex (default: 0,0)
  61764. */
  61765. constructor(
  61766. /** the position of the vertex (defaut: 0,0,0) */
  61767. position?: Vector3,
  61768. /** the normal of the vertex (defaut: 0,1,0) */
  61769. normal?: Vector3,
  61770. /** the uv of the vertex (default: 0,0) */
  61771. uv?: Vector2);
  61772. /**
  61773. * Clones the PositionNormalTextureVertex
  61774. * @returns the cloned PositionNormalTextureVertex
  61775. */
  61776. clone(): PositionNormalTextureVertex;
  61777. }
  61778. /**
  61779. * @hidden
  61780. */
  61781. export class Tmp {
  61782. static Color3: Color3[];
  61783. static Color4: Color4[];
  61784. static Vector2: Vector2[];
  61785. static Vector3: Vector3[];
  61786. static Vector4: Vector4[];
  61787. static Quaternion: Quaternion[];
  61788. static Matrix: Matrix[];
  61789. }
  61790. }
  61791. declare module BABYLON {
  61792. /**
  61793. * Class used to enable access to offline support
  61794. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61795. */
  61796. export interface IOfflineProvider {
  61797. /**
  61798. * Gets a boolean indicating if scene must be saved in the database
  61799. */
  61800. enableSceneOffline: boolean;
  61801. /**
  61802. * Gets a boolean indicating if textures must be saved in the database
  61803. */
  61804. enableTexturesOffline: boolean;
  61805. /**
  61806. * Open the offline support and make it available
  61807. * @param successCallback defines the callback to call on success
  61808. * @param errorCallback defines the callback to call on error
  61809. */
  61810. open(successCallback: () => void, errorCallback: () => void): void;
  61811. /**
  61812. * Loads an image from the offline support
  61813. * @param url defines the url to load from
  61814. * @param image defines the target DOM image
  61815. */
  61816. loadImage(url: string, image: HTMLImageElement): void;
  61817. /**
  61818. * Loads a file from offline support
  61819. * @param url defines the URL to load from
  61820. * @param sceneLoaded defines a callback to call on success
  61821. * @param progressCallBack defines a callback to call when progress changed
  61822. * @param errorCallback defines a callback to call on error
  61823. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61824. */
  61825. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61826. }
  61827. }
  61828. declare module BABYLON {
  61829. /**
  61830. * A class serves as a medium between the observable and its observers
  61831. */
  61832. export class EventState {
  61833. /**
  61834. * Create a new EventState
  61835. * @param mask defines the mask associated with this state
  61836. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61837. * @param target defines the original target of the state
  61838. * @param currentTarget defines the current target of the state
  61839. */
  61840. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  61841. /**
  61842. * Initialize the current event state
  61843. * @param mask defines the mask associated with this state
  61844. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  61845. * @param target defines the original target of the state
  61846. * @param currentTarget defines the current target of the state
  61847. * @returns the current event state
  61848. */
  61849. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  61850. /**
  61851. * An Observer can set this property to true to prevent subsequent observers of being notified
  61852. */
  61853. skipNextObservers: boolean;
  61854. /**
  61855. * Get the mask value that were used to trigger the event corresponding to this EventState object
  61856. */
  61857. mask: number;
  61858. /**
  61859. * The object that originally notified the event
  61860. */
  61861. target?: any;
  61862. /**
  61863. * The current object in the bubbling phase
  61864. */
  61865. currentTarget?: any;
  61866. /**
  61867. * This will be populated with the return value of the last function that was executed.
  61868. * If it is the first function in the callback chain it will be the event data.
  61869. */
  61870. lastReturnValue?: any;
  61871. }
  61872. /**
  61873. * Represent an Observer registered to a given Observable object.
  61874. */
  61875. export class Observer<T> {
  61876. /**
  61877. * Defines the callback to call when the observer is notified
  61878. */
  61879. callback: (eventData: T, eventState: EventState) => void;
  61880. /**
  61881. * Defines the mask of the observer (used to filter notifications)
  61882. */
  61883. mask: number;
  61884. /**
  61885. * Defines the current scope used to restore the JS context
  61886. */
  61887. scope: any;
  61888. /** @hidden */
  61889. _willBeUnregistered: boolean;
  61890. /**
  61891. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  61892. */
  61893. unregisterOnNextCall: boolean;
  61894. /**
  61895. * Creates a new observer
  61896. * @param callback defines the callback to call when the observer is notified
  61897. * @param mask defines the mask of the observer (used to filter notifications)
  61898. * @param scope defines the current scope used to restore the JS context
  61899. */
  61900. constructor(
  61901. /**
  61902. * Defines the callback to call when the observer is notified
  61903. */
  61904. callback: (eventData: T, eventState: EventState) => void,
  61905. /**
  61906. * Defines the mask of the observer (used to filter notifications)
  61907. */
  61908. mask: number,
  61909. /**
  61910. * Defines the current scope used to restore the JS context
  61911. */
  61912. scope?: any);
  61913. }
  61914. /**
  61915. * Represent a list of observers registered to multiple Observables object.
  61916. */
  61917. export class MultiObserver<T> {
  61918. private _observers;
  61919. private _observables;
  61920. /**
  61921. * Release associated resources
  61922. */
  61923. dispose(): void;
  61924. /**
  61925. * Raise a callback when one of the observable will notify
  61926. * @param observables defines a list of observables to watch
  61927. * @param callback defines the callback to call on notification
  61928. * @param mask defines the mask used to filter notifications
  61929. * @param scope defines the current scope used to restore the JS context
  61930. * @returns the new MultiObserver
  61931. */
  61932. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  61933. }
  61934. /**
  61935. * The Observable class is a simple implementation of the Observable pattern.
  61936. *
  61937. * 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.
  61938. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  61939. * 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).
  61940. * 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.
  61941. */
  61942. export class Observable<T> {
  61943. private _observers;
  61944. private _eventState;
  61945. private _onObserverAdded;
  61946. /**
  61947. * Creates a new observable
  61948. * @param onObserverAdded defines a callback to call when a new observer is added
  61949. */
  61950. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  61951. /**
  61952. * Create a new Observer with the specified callback
  61953. * @param callback the callback that will be executed for that Observer
  61954. * @param mask the mask used to filter observers
  61955. * @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.
  61956. * @param scope optional scope for the callback to be called from
  61957. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  61958. * @returns the new observer created for the callback
  61959. */
  61960. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  61961. /**
  61962. * Create a new Observer with the specified callback and unregisters after the next notification
  61963. * @param callback the callback that will be executed for that Observer
  61964. * @returns the new observer created for the callback
  61965. */
  61966. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  61967. /**
  61968. * Remove an Observer from the Observable object
  61969. * @param observer the instance of the Observer to remove
  61970. * @returns false if it doesn't belong to this Observable
  61971. */
  61972. remove(observer: Nullable<Observer<T>>): boolean;
  61973. /**
  61974. * Remove a callback from the Observable object
  61975. * @param callback the callback to remove
  61976. * @param scope optional scope. If used only the callbacks with this scope will be removed
  61977. * @returns false if it doesn't belong to this Observable
  61978. */
  61979. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  61980. private _deferUnregister;
  61981. private _remove;
  61982. /**
  61983. * Notify all Observers by calling their respective callback with the given data
  61984. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  61985. * @param eventData defines the data to send to all observers
  61986. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  61987. * @param target defines the original target of the state
  61988. * @param currentTarget defines the current target of the state
  61989. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  61990. */
  61991. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  61992. /**
  61993. * Calling this will execute each callback, expecting it to be a promise or return a value.
  61994. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  61995. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  61996. * and it is crucial that all callbacks will be executed.
  61997. * The order of the callbacks is kept, callbacks are not executed parallel.
  61998. *
  61999. * @param eventData The data to be sent to each callback
  62000. * @param mask is used to filter observers defaults to -1
  62001. * @param target defines the callback target (see EventState)
  62002. * @param currentTarget defines he current object in the bubbling phase
  62003. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62004. */
  62005. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62006. /**
  62007. * Notify a specific observer
  62008. * @param observer defines the observer to notify
  62009. * @param eventData defines the data to be sent to each callback
  62010. * @param mask is used to filter observers defaults to -1
  62011. */
  62012. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62013. /**
  62014. * Gets a boolean indicating if the observable has at least one observer
  62015. * @returns true is the Observable has at least one Observer registered
  62016. */
  62017. hasObservers(): boolean;
  62018. /**
  62019. * Clear the list of observers
  62020. */
  62021. clear(): void;
  62022. /**
  62023. * Clone the current observable
  62024. * @returns a new observable
  62025. */
  62026. clone(): Observable<T>;
  62027. /**
  62028. * Does this observable handles observer registered with a given mask
  62029. * @param mask defines the mask to be tested
  62030. * @return whether or not one observer registered with the given mask is handeled
  62031. **/
  62032. hasSpecificMask(mask?: number): boolean;
  62033. }
  62034. }
  62035. declare module BABYLON {
  62036. /**
  62037. * Class used to help managing file picking and drag'n'drop
  62038. * File Storage
  62039. */
  62040. export class FilesInputStore {
  62041. /**
  62042. * List of files ready to be loaded
  62043. */
  62044. static FilesToLoad: {
  62045. [key: string]: File;
  62046. };
  62047. }
  62048. }
  62049. declare module BABYLON {
  62050. /** Defines the cross module used constants to avoid circular dependncies */
  62051. export class Constants {
  62052. /** Defines that alpha blending is disabled */
  62053. static readonly ALPHA_DISABLE: number;
  62054. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62055. static readonly ALPHA_ADD: number;
  62056. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62057. static readonly ALPHA_COMBINE: number;
  62058. /** Defines that alpha blending to DEST - SRC * DEST */
  62059. static readonly ALPHA_SUBTRACT: number;
  62060. /** Defines that alpha blending to SRC * DEST */
  62061. static readonly ALPHA_MULTIPLY: number;
  62062. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62063. static readonly ALPHA_MAXIMIZED: number;
  62064. /** Defines that alpha blending to SRC + DEST */
  62065. static readonly ALPHA_ONEONE: number;
  62066. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62067. static readonly ALPHA_PREMULTIPLIED: number;
  62068. /**
  62069. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62070. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62071. */
  62072. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62073. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62074. static readonly ALPHA_INTERPOLATE: number;
  62075. /**
  62076. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62077. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62078. */
  62079. static readonly ALPHA_SCREENMODE: number;
  62080. /** Defines that the ressource is not delayed*/
  62081. static readonly DELAYLOADSTATE_NONE: number;
  62082. /** Defines that the ressource was successfully delay loaded */
  62083. static readonly DELAYLOADSTATE_LOADED: number;
  62084. /** Defines that the ressource is currently delay loading */
  62085. static readonly DELAYLOADSTATE_LOADING: number;
  62086. /** Defines that the ressource is delayed and has not started loading */
  62087. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62089. static readonly NEVER: number;
  62090. /** 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 */
  62091. static readonly ALWAYS: number;
  62092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62093. static readonly LESS: number;
  62094. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62095. static readonly EQUAL: number;
  62096. /** 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 */
  62097. static readonly LEQUAL: number;
  62098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62099. static readonly GREATER: number;
  62100. /** 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 */
  62101. static readonly GEQUAL: number;
  62102. /** 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 */
  62103. static readonly NOTEQUAL: number;
  62104. /** Passed to stencilOperation to specify that stencil value must be kept */
  62105. static readonly KEEP: number;
  62106. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62107. static readonly REPLACE: number;
  62108. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62109. static readonly INCR: number;
  62110. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62111. static readonly DECR: number;
  62112. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62113. static readonly INVERT: number;
  62114. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62115. static readonly INCR_WRAP: number;
  62116. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62117. static readonly DECR_WRAP: number;
  62118. /** Texture is not repeating outside of 0..1 UVs */
  62119. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62120. /** Texture is repeating outside of 0..1 UVs */
  62121. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62122. /** Texture is repeating and mirrored */
  62123. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62124. /** ALPHA */
  62125. static readonly TEXTUREFORMAT_ALPHA: number;
  62126. /** LUMINANCE */
  62127. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62128. /** LUMINANCE_ALPHA */
  62129. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62130. /** RGB */
  62131. static readonly TEXTUREFORMAT_RGB: number;
  62132. /** RGBA */
  62133. static readonly TEXTUREFORMAT_RGBA: number;
  62134. /** RED */
  62135. static readonly TEXTUREFORMAT_RED: number;
  62136. /** RED (2nd reference) */
  62137. static readonly TEXTUREFORMAT_R: number;
  62138. /** RG */
  62139. static readonly TEXTUREFORMAT_RG: number;
  62140. /** RED_INTEGER */
  62141. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62142. /** RED_INTEGER (2nd reference) */
  62143. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62144. /** RG_INTEGER */
  62145. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62146. /** RGB_INTEGER */
  62147. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62148. /** RGBA_INTEGER */
  62149. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62150. /** UNSIGNED_BYTE */
  62151. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62152. /** UNSIGNED_BYTE (2nd reference) */
  62153. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62154. /** FLOAT */
  62155. static readonly TEXTURETYPE_FLOAT: number;
  62156. /** HALF_FLOAT */
  62157. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62158. /** BYTE */
  62159. static readonly TEXTURETYPE_BYTE: number;
  62160. /** SHORT */
  62161. static readonly TEXTURETYPE_SHORT: number;
  62162. /** UNSIGNED_SHORT */
  62163. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62164. /** INT */
  62165. static readonly TEXTURETYPE_INT: number;
  62166. /** UNSIGNED_INT */
  62167. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62168. /** UNSIGNED_SHORT_4_4_4_4 */
  62169. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62170. /** UNSIGNED_SHORT_5_5_5_1 */
  62171. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62172. /** UNSIGNED_SHORT_5_6_5 */
  62173. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62174. /** UNSIGNED_INT_2_10_10_10_REV */
  62175. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62176. /** UNSIGNED_INT_24_8 */
  62177. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62178. /** UNSIGNED_INT_10F_11F_11F_REV */
  62179. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62180. /** UNSIGNED_INT_5_9_9_9_REV */
  62181. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62182. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62183. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62184. /** nearest is mag = nearest and min = nearest and mip = linear */
  62185. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62186. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62187. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62188. /** Trilinear is mag = linear and min = linear and mip = linear */
  62189. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62190. /** nearest is mag = nearest and min = nearest and mip = linear */
  62191. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62192. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62193. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62194. /** Trilinear is mag = linear and min = linear and mip = linear */
  62195. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62196. /** mag = nearest and min = nearest and mip = nearest */
  62197. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62198. /** mag = nearest and min = linear and mip = nearest */
  62199. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62200. /** mag = nearest and min = linear and mip = linear */
  62201. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62202. /** mag = nearest and min = linear and mip = none */
  62203. static readonly TEXTURE_NEAREST_LINEAR: number;
  62204. /** mag = nearest and min = nearest and mip = none */
  62205. static readonly TEXTURE_NEAREST_NEAREST: number;
  62206. /** mag = linear and min = nearest and mip = nearest */
  62207. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62208. /** mag = linear and min = nearest and mip = linear */
  62209. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62210. /** mag = linear and min = linear and mip = none */
  62211. static readonly TEXTURE_LINEAR_LINEAR: number;
  62212. /** mag = linear and min = nearest and mip = none */
  62213. static readonly TEXTURE_LINEAR_NEAREST: number;
  62214. /** Explicit coordinates mode */
  62215. static readonly TEXTURE_EXPLICIT_MODE: number;
  62216. /** Spherical coordinates mode */
  62217. static readonly TEXTURE_SPHERICAL_MODE: number;
  62218. /** Planar coordinates mode */
  62219. static readonly TEXTURE_PLANAR_MODE: number;
  62220. /** Cubic coordinates mode */
  62221. static readonly TEXTURE_CUBIC_MODE: number;
  62222. /** Projection coordinates mode */
  62223. static readonly TEXTURE_PROJECTION_MODE: number;
  62224. /** Skybox coordinates mode */
  62225. static readonly TEXTURE_SKYBOX_MODE: number;
  62226. /** Inverse Cubic coordinates mode */
  62227. static readonly TEXTURE_INVCUBIC_MODE: number;
  62228. /** Equirectangular coordinates mode */
  62229. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62230. /** Equirectangular Fixed coordinates mode */
  62231. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62232. /** Equirectangular Fixed Mirrored coordinates mode */
  62233. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62234. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62235. static readonly SCALEMODE_FLOOR: number;
  62236. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62237. static readonly SCALEMODE_NEAREST: number;
  62238. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62239. static readonly SCALEMODE_CEILING: number;
  62240. /**
  62241. * The dirty texture flag value
  62242. */
  62243. static readonly MATERIAL_TextureDirtyFlag: number;
  62244. /**
  62245. * The dirty light flag value
  62246. */
  62247. static readonly MATERIAL_LightDirtyFlag: number;
  62248. /**
  62249. * The dirty fresnel flag value
  62250. */
  62251. static readonly MATERIAL_FresnelDirtyFlag: number;
  62252. /**
  62253. * The dirty attribute flag value
  62254. */
  62255. static readonly MATERIAL_AttributesDirtyFlag: number;
  62256. /**
  62257. * The dirty misc flag value
  62258. */
  62259. static readonly MATERIAL_MiscDirtyFlag: number;
  62260. /**
  62261. * The all dirty flag value
  62262. */
  62263. static readonly MATERIAL_AllDirtyFlag: number;
  62264. /**
  62265. * Returns the triangle fill mode
  62266. */
  62267. static readonly MATERIAL_TriangleFillMode: number;
  62268. /**
  62269. * Returns the wireframe mode
  62270. */
  62271. static readonly MATERIAL_WireFrameFillMode: number;
  62272. /**
  62273. * Returns the point fill mode
  62274. */
  62275. static readonly MATERIAL_PointFillMode: number;
  62276. /**
  62277. * Returns the point list draw mode
  62278. */
  62279. static readonly MATERIAL_PointListDrawMode: number;
  62280. /**
  62281. * Returns the line list draw mode
  62282. */
  62283. static readonly MATERIAL_LineListDrawMode: number;
  62284. /**
  62285. * Returns the line loop draw mode
  62286. */
  62287. static readonly MATERIAL_LineLoopDrawMode: number;
  62288. /**
  62289. * Returns the line strip draw mode
  62290. */
  62291. static readonly MATERIAL_LineStripDrawMode: number;
  62292. /**
  62293. * Returns the triangle strip draw mode
  62294. */
  62295. static readonly MATERIAL_TriangleStripDrawMode: number;
  62296. /**
  62297. * Returns the triangle fan draw mode
  62298. */
  62299. static readonly MATERIAL_TriangleFanDrawMode: number;
  62300. /**
  62301. * Stores the clock-wise side orientation
  62302. */
  62303. static readonly MATERIAL_ClockWiseSideOrientation: number;
  62304. /**
  62305. * Stores the counter clock-wise side orientation
  62306. */
  62307. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  62308. /**
  62309. * Nothing
  62310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62311. */
  62312. static readonly ACTION_NothingTrigger: number;
  62313. /**
  62314. * On pick
  62315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62316. */
  62317. static readonly ACTION_OnPickTrigger: number;
  62318. /**
  62319. * On left pick
  62320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62321. */
  62322. static readonly ACTION_OnLeftPickTrigger: number;
  62323. /**
  62324. * On right pick
  62325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62326. */
  62327. static readonly ACTION_OnRightPickTrigger: number;
  62328. /**
  62329. * On center pick
  62330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62331. */
  62332. static readonly ACTION_OnCenterPickTrigger: number;
  62333. /**
  62334. * On pick down
  62335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62336. */
  62337. static readonly ACTION_OnPickDownTrigger: number;
  62338. /**
  62339. * On double pick
  62340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62341. */
  62342. static readonly ACTION_OnDoublePickTrigger: number;
  62343. /**
  62344. * On pick up
  62345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62346. */
  62347. static readonly ACTION_OnPickUpTrigger: number;
  62348. /**
  62349. * On pick out.
  62350. * This trigger will only be raised if you also declared a OnPickDown
  62351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62352. */
  62353. static readonly ACTION_OnPickOutTrigger: number;
  62354. /**
  62355. * On long press
  62356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62357. */
  62358. static readonly ACTION_OnLongPressTrigger: number;
  62359. /**
  62360. * On pointer over
  62361. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62362. */
  62363. static readonly ACTION_OnPointerOverTrigger: number;
  62364. /**
  62365. * On pointer out
  62366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62367. */
  62368. static readonly ACTION_OnPointerOutTrigger: number;
  62369. /**
  62370. * On every frame
  62371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62372. */
  62373. static readonly ACTION_OnEveryFrameTrigger: number;
  62374. /**
  62375. * On intersection enter
  62376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62377. */
  62378. static readonly ACTION_OnIntersectionEnterTrigger: number;
  62379. /**
  62380. * On intersection exit
  62381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62382. */
  62383. static readonly ACTION_OnIntersectionExitTrigger: number;
  62384. /**
  62385. * On key down
  62386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62387. */
  62388. static readonly ACTION_OnKeyDownTrigger: number;
  62389. /**
  62390. * On key up
  62391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  62392. */
  62393. static readonly ACTION_OnKeyUpTrigger: number;
  62394. /**
  62395. * Billboard mode will only apply to Y axis
  62396. */
  62397. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  62398. /**
  62399. * Billboard mode will apply to all axes
  62400. */
  62401. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  62402. /**
  62403. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  62404. */
  62405. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  62406. /**
  62407. * Gets or sets base Assets URL
  62408. */
  62409. static readonly PARTICLES_BaseAssetsUrl: string;
  62410. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  62411. * Test order :
  62412. * Is the bounding sphere outside the frustum ?
  62413. * If not, are the bounding box vertices outside the frustum ?
  62414. * It not, then the cullable object is in the frustum.
  62415. */
  62416. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  62417. /** Culling strategy : Bounding Sphere Only.
  62418. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  62419. * It's also less accurate than the standard because some not visible objects can still be selected.
  62420. * Test : is the bounding sphere outside the frustum ?
  62421. * If not, then the cullable object is in the frustum.
  62422. */
  62423. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  62424. /** Culling strategy : Optimistic Inclusion.
  62425. * This in an inclusion test first, then the standard exclusion test.
  62426. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  62427. * 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.
  62428. * Anyway, it's as accurate as the standard strategy.
  62429. * Test :
  62430. * Is the cullable object bounding sphere center in the frustum ?
  62431. * If not, apply the default culling strategy.
  62432. */
  62433. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  62434. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  62435. * This in an inclusion test first, then the bounding sphere only exclusion test.
  62436. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  62437. * 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.
  62438. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  62439. * Test :
  62440. * Is the cullable object bounding sphere center in the frustum ?
  62441. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  62442. */
  62443. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  62444. /**
  62445. * No logging while loading
  62446. */
  62447. static readonly SCENELOADER_NO_LOGGING: number;
  62448. /**
  62449. * Minimal logging while loading
  62450. */
  62451. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  62452. /**
  62453. * Summary logging while loading
  62454. */
  62455. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  62456. /**
  62457. * Detailled logging while loading
  62458. */
  62459. static readonly SCENELOADER_DETAILED_LOGGING: number;
  62460. }
  62461. }
  62462. declare module BABYLON {
  62463. /**
  62464. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  62465. * Babylon.js
  62466. */
  62467. export class DomManagement {
  62468. /**
  62469. * Checks if the window object exists
  62470. * @returns true if the window object exists
  62471. */
  62472. static IsWindowObjectExist(): boolean;
  62473. /**
  62474. * Extracts text content from a DOM element hierarchy
  62475. * @param element defines the root element
  62476. * @returns a string
  62477. */
  62478. static GetDOMTextContent(element: HTMLElement): string;
  62479. }
  62480. }
  62481. declare module BABYLON {
  62482. /**
  62483. * Logger used througouht the application to allow configuration of
  62484. * the log level required for the messages.
  62485. */
  62486. export class Logger {
  62487. /**
  62488. * No log
  62489. */
  62490. static readonly NoneLogLevel: number;
  62491. /**
  62492. * Only message logs
  62493. */
  62494. static readonly MessageLogLevel: number;
  62495. /**
  62496. * Only warning logs
  62497. */
  62498. static readonly WarningLogLevel: number;
  62499. /**
  62500. * Only error logs
  62501. */
  62502. static readonly ErrorLogLevel: number;
  62503. /**
  62504. * All logs
  62505. */
  62506. static readonly AllLogLevel: number;
  62507. private static _LogCache;
  62508. /**
  62509. * Gets a value indicating the number of loading errors
  62510. * @ignorenaming
  62511. */
  62512. static errorsCount: number;
  62513. /**
  62514. * Callback called when a new log is added
  62515. */
  62516. static OnNewCacheEntry: (entry: string) => void;
  62517. private static _AddLogEntry;
  62518. private static _FormatMessage;
  62519. private static _LogDisabled;
  62520. private static _LogEnabled;
  62521. private static _WarnDisabled;
  62522. private static _WarnEnabled;
  62523. private static _ErrorDisabled;
  62524. private static _ErrorEnabled;
  62525. /**
  62526. * Log a message to the console
  62527. */
  62528. static Log: (message: string) => void;
  62529. /**
  62530. * Write a warning message to the console
  62531. */
  62532. static Warn: (message: string) => void;
  62533. /**
  62534. * Write an error message to the console
  62535. */
  62536. static Error: (message: string) => void;
  62537. /**
  62538. * Gets current log cache (list of logs)
  62539. */
  62540. static readonly LogCache: string;
  62541. /**
  62542. * Clears the log cache
  62543. */
  62544. static ClearLogCache(): void;
  62545. /**
  62546. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  62547. */
  62548. static LogLevels: number;
  62549. }
  62550. }
  62551. declare module BABYLON {
  62552. /** @hidden */
  62553. export class _TypeStore {
  62554. /** @hidden */
  62555. static RegisteredTypes: {
  62556. [key: string]: Object;
  62557. };
  62558. /** @hidden */
  62559. static GetClass(fqdn: string): any;
  62560. }
  62561. }
  62562. declare module BABYLON {
  62563. /**
  62564. * Class containing a set of static utilities functions for deep copy.
  62565. */
  62566. export class DeepCopier {
  62567. /**
  62568. * Tries to copy an object by duplicating every property
  62569. * @param source defines the source object
  62570. * @param destination defines the target object
  62571. * @param doNotCopyList defines a list of properties to avoid
  62572. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  62573. */
  62574. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  62575. }
  62576. }
  62577. declare module BABYLON {
  62578. /**
  62579. * Class containing a set of static utilities functions for precision date
  62580. */
  62581. export class PrecisionDate {
  62582. /**
  62583. * Gets either window.performance.now() if supported or Date.now() else
  62584. */
  62585. static readonly Now: number;
  62586. }
  62587. }
  62588. declare module BABYLON {
  62589. /** @hidden */
  62590. export class _DevTools {
  62591. static WarnImport(name: string): string;
  62592. }
  62593. }
  62594. declare module BABYLON {
  62595. /**
  62596. * Class used to evalaute queries containing `and` and `or` operators
  62597. */
  62598. export class AndOrNotEvaluator {
  62599. /**
  62600. * Evaluate a query
  62601. * @param query defines the query to evaluate
  62602. * @param evaluateCallback defines the callback used to filter result
  62603. * @returns true if the query matches
  62604. */
  62605. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  62606. private static _HandleParenthesisContent;
  62607. private static _SimplifyNegation;
  62608. }
  62609. }
  62610. declare module BABYLON {
  62611. /**
  62612. * Class used to store custom tags
  62613. */
  62614. export class Tags {
  62615. /**
  62616. * Adds support for tags on the given object
  62617. * @param obj defines the object to use
  62618. */
  62619. static EnableFor(obj: any): void;
  62620. /**
  62621. * Removes tags support
  62622. * @param obj defines the object to use
  62623. */
  62624. static DisableFor(obj: any): void;
  62625. /**
  62626. * Gets a boolean indicating if the given object has tags
  62627. * @param obj defines the object to use
  62628. * @returns a boolean
  62629. */
  62630. static HasTags(obj: any): boolean;
  62631. /**
  62632. * Gets the tags available on a given object
  62633. * @param obj defines the object to use
  62634. * @param asString defines if the tags must be returned as a string instead of an array of strings
  62635. * @returns the tags
  62636. */
  62637. static GetTags(obj: any, asString?: boolean): any;
  62638. /**
  62639. * Adds tags to an object
  62640. * @param obj defines the object to use
  62641. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  62642. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  62643. */
  62644. static AddTagsTo(obj: any, tagsString: string): void;
  62645. /**
  62646. * @hidden
  62647. */
  62648. static _AddTagTo(obj: any, tag: string): void;
  62649. /**
  62650. * Removes specific tags from a specific object
  62651. * @param obj defines the object to use
  62652. * @param tagsString defines the tags to remove
  62653. */
  62654. static RemoveTagsFrom(obj: any, tagsString: string): void;
  62655. /**
  62656. * @hidden
  62657. */
  62658. static _RemoveTagFrom(obj: any, tag: string): void;
  62659. /**
  62660. * Defines if tags hosted on an object match a given query
  62661. * @param obj defines the object to use
  62662. * @param tagsQuery defines the tag query
  62663. * @returns a boolean
  62664. */
  62665. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  62666. }
  62667. }
  62668. declare module BABYLON {
  62669. /**
  62670. * Manages the defines for the Material
  62671. */
  62672. export class MaterialDefines {
  62673. private _keys;
  62674. private _isDirty;
  62675. /** @hidden */
  62676. _renderId: number;
  62677. /** @hidden */
  62678. _areLightsDirty: boolean;
  62679. /** @hidden */
  62680. _areAttributesDirty: boolean;
  62681. /** @hidden */
  62682. _areTexturesDirty: boolean;
  62683. /** @hidden */
  62684. _areFresnelDirty: boolean;
  62685. /** @hidden */
  62686. _areMiscDirty: boolean;
  62687. /** @hidden */
  62688. _areImageProcessingDirty: boolean;
  62689. /** @hidden */
  62690. _normals: boolean;
  62691. /** @hidden */
  62692. _uvs: boolean;
  62693. /** @hidden */
  62694. _needNormals: boolean;
  62695. /** @hidden */
  62696. _needUVs: boolean;
  62697. /**
  62698. * Specifies if the material needs to be re-calculated
  62699. */
  62700. readonly isDirty: boolean;
  62701. /**
  62702. * Marks the material to indicate that it has been re-calculated
  62703. */
  62704. markAsProcessed(): void;
  62705. /**
  62706. * Marks the material to indicate that it needs to be re-calculated
  62707. */
  62708. markAsUnprocessed(): void;
  62709. /**
  62710. * Marks the material to indicate all of its defines need to be re-calculated
  62711. */
  62712. markAllAsDirty(): void;
  62713. /**
  62714. * Marks the material to indicate that image processing needs to be re-calculated
  62715. */
  62716. markAsImageProcessingDirty(): void;
  62717. /**
  62718. * Marks the material to indicate the lights need to be re-calculated
  62719. */
  62720. markAsLightDirty(): void;
  62721. /**
  62722. * Marks the attribute state as changed
  62723. */
  62724. markAsAttributesDirty(): void;
  62725. /**
  62726. * Marks the texture state as changed
  62727. */
  62728. markAsTexturesDirty(): void;
  62729. /**
  62730. * Marks the fresnel state as changed
  62731. */
  62732. markAsFresnelDirty(): void;
  62733. /**
  62734. * Marks the misc state as changed
  62735. */
  62736. markAsMiscDirty(): void;
  62737. /**
  62738. * Rebuilds the material defines
  62739. */
  62740. rebuild(): void;
  62741. /**
  62742. * Specifies if two material defines are equal
  62743. * @param other - A material define instance to compare to
  62744. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  62745. */
  62746. isEqual(other: MaterialDefines): boolean;
  62747. /**
  62748. * Clones this instance's defines to another instance
  62749. * @param other - material defines to clone values to
  62750. */
  62751. cloneTo(other: MaterialDefines): void;
  62752. /**
  62753. * Resets the material define values
  62754. */
  62755. reset(): void;
  62756. /**
  62757. * Converts the material define values to a string
  62758. * @returns - String of material define information
  62759. */
  62760. toString(): string;
  62761. }
  62762. }
  62763. declare module BABYLON {
  62764. /**
  62765. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  62766. */
  62767. export class PerformanceMonitor {
  62768. private _enabled;
  62769. private _rollingFrameTime;
  62770. private _lastFrameTimeMs;
  62771. /**
  62772. * constructor
  62773. * @param frameSampleSize The number of samples required to saturate the sliding window
  62774. */
  62775. constructor(frameSampleSize?: number);
  62776. /**
  62777. * Samples current frame
  62778. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  62779. */
  62780. sampleFrame(timeMs?: number): void;
  62781. /**
  62782. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62783. */
  62784. readonly averageFrameTime: number;
  62785. /**
  62786. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  62787. */
  62788. readonly averageFrameTimeVariance: number;
  62789. /**
  62790. * Returns the frame time of the most recent frame
  62791. */
  62792. readonly instantaneousFrameTime: number;
  62793. /**
  62794. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  62795. */
  62796. readonly averageFPS: number;
  62797. /**
  62798. * Returns the average framerate in frames per second using the most recent frame time
  62799. */
  62800. readonly instantaneousFPS: number;
  62801. /**
  62802. * Returns true if enough samples have been taken to completely fill the sliding window
  62803. */
  62804. readonly isSaturated: boolean;
  62805. /**
  62806. * Enables contributions to the sliding window sample set
  62807. */
  62808. enable(): void;
  62809. /**
  62810. * Disables contributions to the sliding window sample set
  62811. * Samples will not be interpolated over the disabled period
  62812. */
  62813. disable(): void;
  62814. /**
  62815. * Returns true if sampling is enabled
  62816. */
  62817. readonly isEnabled: boolean;
  62818. /**
  62819. * Resets performance monitor
  62820. */
  62821. reset(): void;
  62822. }
  62823. /**
  62824. * RollingAverage
  62825. *
  62826. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  62827. */
  62828. export class RollingAverage {
  62829. /**
  62830. * Current average
  62831. */
  62832. average: number;
  62833. /**
  62834. * Current variance
  62835. */
  62836. variance: number;
  62837. protected _samples: Array<number>;
  62838. protected _sampleCount: number;
  62839. protected _pos: number;
  62840. protected _m2: number;
  62841. /**
  62842. * constructor
  62843. * @param length The number of samples required to saturate the sliding window
  62844. */
  62845. constructor(length: number);
  62846. /**
  62847. * Adds a sample to the sample set
  62848. * @param v The sample value
  62849. */
  62850. add(v: number): void;
  62851. /**
  62852. * Returns previously added values or null if outside of history or outside the sliding window domain
  62853. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  62854. * @return Value previously recorded with add() or null if outside of range
  62855. */
  62856. history(i: number): number;
  62857. /**
  62858. * Returns true if enough samples have been taken to completely fill the sliding window
  62859. * @return true if sample-set saturated
  62860. */
  62861. isSaturated(): boolean;
  62862. /**
  62863. * Resets the rolling average (equivalent to 0 samples taken so far)
  62864. */
  62865. reset(): void;
  62866. /**
  62867. * Wraps a value around the sample range boundaries
  62868. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  62869. * @return Wrapped position in sample range
  62870. */
  62871. protected _wrapPosition(i: number): number;
  62872. }
  62873. }
  62874. declare module BABYLON {
  62875. /**
  62876. * This class implement a typical dictionary using a string as key and the generic type T as value.
  62877. * The underlying implementation relies on an associative array to ensure the best performances.
  62878. * The value can be anything including 'null' but except 'undefined'
  62879. */
  62880. export class StringDictionary<T> {
  62881. /**
  62882. * This will clear this dictionary and copy the content from the 'source' one.
  62883. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  62884. * @param source the dictionary to take the content from and copy to this dictionary
  62885. */
  62886. copyFrom(source: StringDictionary<T>): void;
  62887. /**
  62888. * Get a value based from its key
  62889. * @param key the given key to get the matching value from
  62890. * @return the value if found, otherwise undefined is returned
  62891. */
  62892. get(key: string): T | undefined;
  62893. /**
  62894. * Get a value from its key or add it if it doesn't exist.
  62895. * This method will ensure you that a given key/data will be present in the dictionary.
  62896. * @param key the given key to get the matching value from
  62897. * @param factory the factory that will create the value if the key is not present in the dictionary.
  62898. * The factory will only be invoked if there's no data for the given key.
  62899. * @return the value corresponding to the key.
  62900. */
  62901. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  62902. /**
  62903. * Get a value from its key if present in the dictionary otherwise add it
  62904. * @param key the key to get the value from
  62905. * @param val if there's no such key/value pair in the dictionary add it with this value
  62906. * @return the value corresponding to the key
  62907. */
  62908. getOrAdd(key: string, val: T): T;
  62909. /**
  62910. * Check if there's a given key in the dictionary
  62911. * @param key the key to check for
  62912. * @return true if the key is present, false otherwise
  62913. */
  62914. contains(key: string): boolean;
  62915. /**
  62916. * Add a new key and its corresponding value
  62917. * @param key the key to add
  62918. * @param value the value corresponding to the key
  62919. * @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
  62920. */
  62921. add(key: string, value: T): boolean;
  62922. /**
  62923. * Update a specific value associated to a key
  62924. * @param key defines the key to use
  62925. * @param value defines the value to store
  62926. * @returns true if the value was updated (or false if the key was not found)
  62927. */
  62928. set(key: string, value: T): boolean;
  62929. /**
  62930. * Get the element of the given key and remove it from the dictionary
  62931. * @param key defines the key to search
  62932. * @returns the value associated with the key or null if not found
  62933. */
  62934. getAndRemove(key: string): Nullable<T>;
  62935. /**
  62936. * Remove a key/value from the dictionary.
  62937. * @param key the key to remove
  62938. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  62939. */
  62940. remove(key: string): boolean;
  62941. /**
  62942. * Clear the whole content of the dictionary
  62943. */
  62944. clear(): void;
  62945. /**
  62946. * Gets the current count
  62947. */
  62948. readonly count: number;
  62949. /**
  62950. * Execute a callback on each key/val of the dictionary.
  62951. * Note that you can remove any element in this dictionary in the callback implementation
  62952. * @param callback the callback to execute on a given key/value pair
  62953. */
  62954. forEach(callback: (key: string, val: T) => void): void;
  62955. /**
  62956. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  62957. * If the callback returns null or undefined the method will iterate to the next key/value pair
  62958. * Note that you can remove any element in this dictionary in the callback implementation
  62959. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  62960. * @returns the first item
  62961. */
  62962. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  62963. private _count;
  62964. private _data;
  62965. }
  62966. }
  62967. declare module BABYLON {
  62968. /**
  62969. * Helper class that provides a small promise polyfill
  62970. */
  62971. export class PromisePolyfill {
  62972. /**
  62973. * Static function used to check if the polyfill is required
  62974. * If this is the case then the function will inject the polyfill to window.Promise
  62975. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  62976. */
  62977. static Apply(force?: boolean): void;
  62978. }
  62979. }
  62980. declare module BABYLON {
  62981. /**
  62982. * Class used to store data that will be store in GPU memory
  62983. */
  62984. export class Buffer {
  62985. private _engine;
  62986. private _buffer;
  62987. /** @hidden */
  62988. _data: Nullable<DataArray>;
  62989. private _updatable;
  62990. private _instanced;
  62991. /**
  62992. * Gets the byte stride.
  62993. */
  62994. readonly byteStride: number;
  62995. /**
  62996. * Constructor
  62997. * @param engine the engine
  62998. * @param data the data to use for this buffer
  62999. * @param updatable whether the data is updatable
  63000. * @param stride the stride (optional)
  63001. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63002. * @param instanced whether the buffer is instanced (optional)
  63003. * @param useBytes set to true if the stride in in bytes (optional)
  63004. */
  63005. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63006. /**
  63007. * Create a new VertexBuffer based on the current buffer
  63008. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63009. * @param offset defines offset in the buffer (0 by default)
  63010. * @param size defines the size in floats of attributes (position is 3 for instance)
  63011. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63012. * @param instanced defines if the vertex buffer contains indexed data
  63013. * @param useBytes defines if the offset and stride are in bytes
  63014. * @returns the new vertex buffer
  63015. */
  63016. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63017. /**
  63018. * Gets a boolean indicating if the Buffer is updatable?
  63019. * @returns true if the buffer is updatable
  63020. */
  63021. isUpdatable(): boolean;
  63022. /**
  63023. * Gets current buffer's data
  63024. * @returns a DataArray or null
  63025. */
  63026. getData(): Nullable<DataArray>;
  63027. /**
  63028. * Gets underlying native buffer
  63029. * @returns underlying native buffer
  63030. */
  63031. getBuffer(): Nullable<WebGLBuffer>;
  63032. /**
  63033. * Gets the stride in float32 units (i.e. byte stride / 4).
  63034. * May not be an integer if the byte stride is not divisible by 4.
  63035. * DEPRECATED. Use byteStride instead.
  63036. * @returns the stride in float32 units
  63037. */
  63038. getStrideSize(): number;
  63039. /**
  63040. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63041. * @param data defines the data to store
  63042. */
  63043. create(data?: Nullable<DataArray>): void;
  63044. /** @hidden */
  63045. _rebuild(): void;
  63046. /**
  63047. * Update current buffer data
  63048. * @param data defines the data to store
  63049. */
  63050. update(data: DataArray): void;
  63051. /**
  63052. * Updates the data directly.
  63053. * @param data the new data
  63054. * @param offset the new offset
  63055. * @param vertexCount the vertex count (optional)
  63056. * @param useBytes set to true if the offset is in bytes
  63057. */
  63058. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63059. /**
  63060. * Release all resources
  63061. */
  63062. dispose(): void;
  63063. }
  63064. /**
  63065. * Specialized buffer used to store vertex data
  63066. */
  63067. export class VertexBuffer {
  63068. /** @hidden */
  63069. _buffer: Buffer;
  63070. private _kind;
  63071. private _size;
  63072. private _ownsBuffer;
  63073. private _instanced;
  63074. private _instanceDivisor;
  63075. /**
  63076. * The byte type.
  63077. */
  63078. static readonly BYTE: number;
  63079. /**
  63080. * The unsigned byte type.
  63081. */
  63082. static readonly UNSIGNED_BYTE: number;
  63083. /**
  63084. * The short type.
  63085. */
  63086. static readonly SHORT: number;
  63087. /**
  63088. * The unsigned short type.
  63089. */
  63090. static readonly UNSIGNED_SHORT: number;
  63091. /**
  63092. * The integer type.
  63093. */
  63094. static readonly INT: number;
  63095. /**
  63096. * The unsigned integer type.
  63097. */
  63098. static readonly UNSIGNED_INT: number;
  63099. /**
  63100. * The float type.
  63101. */
  63102. static readonly FLOAT: number;
  63103. /**
  63104. * Gets or sets the instance divisor when in instanced mode
  63105. */
  63106. instanceDivisor: number;
  63107. /**
  63108. * Gets the byte stride.
  63109. */
  63110. readonly byteStride: number;
  63111. /**
  63112. * Gets the byte offset.
  63113. */
  63114. readonly byteOffset: number;
  63115. /**
  63116. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63117. */
  63118. readonly normalized: boolean;
  63119. /**
  63120. * Gets the data type of each component in the array.
  63121. */
  63122. readonly type: number;
  63123. /**
  63124. * Constructor
  63125. * @param engine the engine
  63126. * @param data the data to use for this vertex buffer
  63127. * @param kind the vertex buffer kind
  63128. * @param updatable whether the data is updatable
  63129. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63130. * @param stride the stride (optional)
  63131. * @param instanced whether the buffer is instanced (optional)
  63132. * @param offset the offset of the data (optional)
  63133. * @param size the number of components (optional)
  63134. * @param type the type of the component (optional)
  63135. * @param normalized whether the data contains normalized data (optional)
  63136. * @param useBytes set to true if stride and offset are in bytes (optional)
  63137. */
  63138. 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);
  63139. /** @hidden */
  63140. _rebuild(): void;
  63141. /**
  63142. * Returns the kind of the VertexBuffer (string)
  63143. * @returns a string
  63144. */
  63145. getKind(): string;
  63146. /**
  63147. * Gets a boolean indicating if the VertexBuffer is updatable?
  63148. * @returns true if the buffer is updatable
  63149. */
  63150. isUpdatable(): boolean;
  63151. /**
  63152. * Gets current buffer's data
  63153. * @returns a DataArray or null
  63154. */
  63155. getData(): Nullable<DataArray>;
  63156. /**
  63157. * Gets underlying native buffer
  63158. * @returns underlying native buffer
  63159. */
  63160. getBuffer(): Nullable<WebGLBuffer>;
  63161. /**
  63162. * Gets the stride in float32 units (i.e. byte stride / 4).
  63163. * May not be an integer if the byte stride is not divisible by 4.
  63164. * DEPRECATED. Use byteStride instead.
  63165. * @returns the stride in float32 units
  63166. */
  63167. getStrideSize(): number;
  63168. /**
  63169. * Returns the offset as a multiple of the type byte length.
  63170. * DEPRECATED. Use byteOffset instead.
  63171. * @returns the offset in bytes
  63172. */
  63173. getOffset(): number;
  63174. /**
  63175. * Returns the number of components per vertex attribute (integer)
  63176. * @returns the size in float
  63177. */
  63178. getSize(): number;
  63179. /**
  63180. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63181. * @returns true if this buffer is instanced
  63182. */
  63183. getIsInstanced(): boolean;
  63184. /**
  63185. * Returns the instancing divisor, zero for non-instanced (integer).
  63186. * @returns a number
  63187. */
  63188. getInstanceDivisor(): number;
  63189. /**
  63190. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63191. * @param data defines the data to store
  63192. */
  63193. create(data?: DataArray): void;
  63194. /**
  63195. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  63196. * This function will create a new buffer if the current one is not updatable
  63197. * @param data defines the data to store
  63198. */
  63199. update(data: DataArray): void;
  63200. /**
  63201. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  63202. * Returns the directly updated WebGLBuffer.
  63203. * @param data the new data
  63204. * @param offset the new offset
  63205. * @param useBytes set to true if the offset is in bytes
  63206. */
  63207. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  63208. /**
  63209. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  63210. */
  63211. dispose(): void;
  63212. /**
  63213. * Enumerates each value of this vertex buffer as numbers.
  63214. * @param count the number of values to enumerate
  63215. * @param callback the callback function called for each value
  63216. */
  63217. forEach(count: number, callback: (value: number, index: number) => void): void;
  63218. /**
  63219. * Positions
  63220. */
  63221. static readonly PositionKind: string;
  63222. /**
  63223. * Normals
  63224. */
  63225. static readonly NormalKind: string;
  63226. /**
  63227. * Tangents
  63228. */
  63229. static readonly TangentKind: string;
  63230. /**
  63231. * Texture coordinates
  63232. */
  63233. static readonly UVKind: string;
  63234. /**
  63235. * Texture coordinates 2
  63236. */
  63237. static readonly UV2Kind: string;
  63238. /**
  63239. * Texture coordinates 3
  63240. */
  63241. static readonly UV3Kind: string;
  63242. /**
  63243. * Texture coordinates 4
  63244. */
  63245. static readonly UV4Kind: string;
  63246. /**
  63247. * Texture coordinates 5
  63248. */
  63249. static readonly UV5Kind: string;
  63250. /**
  63251. * Texture coordinates 6
  63252. */
  63253. static readonly UV6Kind: string;
  63254. /**
  63255. * Colors
  63256. */
  63257. static readonly ColorKind: string;
  63258. /**
  63259. * Matrix indices (for bones)
  63260. */
  63261. static readonly MatricesIndicesKind: string;
  63262. /**
  63263. * Matrix weights (for bones)
  63264. */
  63265. static readonly MatricesWeightsKind: string;
  63266. /**
  63267. * Additional matrix indices (for bones)
  63268. */
  63269. static readonly MatricesIndicesExtraKind: string;
  63270. /**
  63271. * Additional matrix weights (for bones)
  63272. */
  63273. static readonly MatricesWeightsExtraKind: string;
  63274. /**
  63275. * Deduces the stride given a kind.
  63276. * @param kind The kind string to deduce
  63277. * @returns The deduced stride
  63278. */
  63279. static DeduceStride(kind: string): number;
  63280. /**
  63281. * Gets the byte length of the given type.
  63282. * @param type the type
  63283. * @returns the number of bytes
  63284. */
  63285. static GetTypeByteLength(type: number): number;
  63286. /**
  63287. * Enumerates each value of the given parameters as numbers.
  63288. * @param data the data to enumerate
  63289. * @param byteOffset the byte offset of the data
  63290. * @param byteStride the byte stride of the data
  63291. * @param componentCount the number of components per element
  63292. * @param componentType the type of the component
  63293. * @param count the total number of components
  63294. * @param normalized whether the data is normalized
  63295. * @param callback the callback function called for each value
  63296. */
  63297. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  63298. private static _GetFloatValue;
  63299. }
  63300. }
  63301. declare module BABYLON {
  63302. /**
  63303. * Class representing spherical polynomial coefficients to the 3rd degree
  63304. */
  63305. export class SphericalPolynomial {
  63306. /**
  63307. * The x coefficients of the spherical polynomial
  63308. */
  63309. x: Vector3;
  63310. /**
  63311. * The y coefficients of the spherical polynomial
  63312. */
  63313. y: Vector3;
  63314. /**
  63315. * The z coefficients of the spherical polynomial
  63316. */
  63317. z: Vector3;
  63318. /**
  63319. * The xx coefficients of the spherical polynomial
  63320. */
  63321. xx: Vector3;
  63322. /**
  63323. * The yy coefficients of the spherical polynomial
  63324. */
  63325. yy: Vector3;
  63326. /**
  63327. * The zz coefficients of the spherical polynomial
  63328. */
  63329. zz: Vector3;
  63330. /**
  63331. * The xy coefficients of the spherical polynomial
  63332. */
  63333. xy: Vector3;
  63334. /**
  63335. * The yz coefficients of the spherical polynomial
  63336. */
  63337. yz: Vector3;
  63338. /**
  63339. * The zx coefficients of the spherical polynomial
  63340. */
  63341. zx: Vector3;
  63342. /**
  63343. * Adds an ambient color to the spherical polynomial
  63344. * @param color the color to add
  63345. */
  63346. addAmbient(color: Color3): void;
  63347. /**
  63348. * Scales the spherical polynomial by the given amount
  63349. * @param scale the amount to scale
  63350. */
  63351. scale(scale: number): void;
  63352. /**
  63353. * Gets the spherical polynomial from harmonics
  63354. * @param harmonics the spherical harmonics
  63355. * @returns the spherical polynomial
  63356. */
  63357. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  63358. /**
  63359. * Constructs a spherical polynomial from an array.
  63360. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  63361. * @returns the spherical polynomial
  63362. */
  63363. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  63364. }
  63365. /**
  63366. * Class representing spherical harmonics coefficients to the 3rd degree
  63367. */
  63368. export class SphericalHarmonics {
  63369. /**
  63370. * The l0,0 coefficients of the spherical harmonics
  63371. */
  63372. l00: Vector3;
  63373. /**
  63374. * The l1,-1 coefficients of the spherical harmonics
  63375. */
  63376. l1_1: Vector3;
  63377. /**
  63378. * The l1,0 coefficients of the spherical harmonics
  63379. */
  63380. l10: Vector3;
  63381. /**
  63382. * The l1,1 coefficients of the spherical harmonics
  63383. */
  63384. l11: Vector3;
  63385. /**
  63386. * The l2,-2 coefficients of the spherical harmonics
  63387. */
  63388. l2_2: Vector3;
  63389. /**
  63390. * The l2,-1 coefficients of the spherical harmonics
  63391. */
  63392. l2_1: Vector3;
  63393. /**
  63394. * The l2,0 coefficients of the spherical harmonics
  63395. */
  63396. l20: Vector3;
  63397. /**
  63398. * The l2,1 coefficients of the spherical harmonics
  63399. */
  63400. l21: Vector3;
  63401. /**
  63402. * The l2,2 coefficients of the spherical harmonics
  63403. */
  63404. lL22: Vector3;
  63405. /**
  63406. * Adds a light to the spherical harmonics
  63407. * @param direction the direction of the light
  63408. * @param color the color of the light
  63409. * @param deltaSolidAngle the delta solid angle of the light
  63410. */
  63411. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  63412. /**
  63413. * Scales the spherical harmonics by the given amount
  63414. * @param scale the amount to scale
  63415. */
  63416. scale(scale: number): void;
  63417. /**
  63418. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  63419. *
  63420. * ```
  63421. * E_lm = A_l * L_lm
  63422. * ```
  63423. *
  63424. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  63425. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  63426. * the scaling factors are given in equation 9.
  63427. */
  63428. convertIncidentRadianceToIrradiance(): void;
  63429. /**
  63430. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  63431. *
  63432. * ```
  63433. * L = (1/pi) * E * rho
  63434. * ```
  63435. *
  63436. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  63437. */
  63438. convertIrradianceToLambertianRadiance(): void;
  63439. /**
  63440. * Gets the spherical harmonics from polynomial
  63441. * @param polynomial the spherical polynomial
  63442. * @returns the spherical harmonics
  63443. */
  63444. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  63445. /**
  63446. * Constructs a spherical harmonics from an array.
  63447. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  63448. * @returns the spherical harmonics
  63449. */
  63450. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  63451. }
  63452. }
  63453. declare module BABYLON {
  63454. /**
  63455. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  63456. */
  63457. export interface CubeMapInfo {
  63458. /**
  63459. * The pixel array for the front face.
  63460. * This is stored in format, left to right, up to down format.
  63461. */
  63462. front: Nullable<ArrayBufferView>;
  63463. /**
  63464. * The pixel array for the back face.
  63465. * This is stored in format, left to right, up to down format.
  63466. */
  63467. back: Nullable<ArrayBufferView>;
  63468. /**
  63469. * The pixel array for the left face.
  63470. * This is stored in format, left to right, up to down format.
  63471. */
  63472. left: Nullable<ArrayBufferView>;
  63473. /**
  63474. * The pixel array for the right face.
  63475. * This is stored in format, left to right, up to down format.
  63476. */
  63477. right: Nullable<ArrayBufferView>;
  63478. /**
  63479. * The pixel array for the up face.
  63480. * This is stored in format, left to right, up to down format.
  63481. */
  63482. up: Nullable<ArrayBufferView>;
  63483. /**
  63484. * The pixel array for the down face.
  63485. * This is stored in format, left to right, up to down format.
  63486. */
  63487. down: Nullable<ArrayBufferView>;
  63488. /**
  63489. * The size of the cubemap stored.
  63490. *
  63491. * Each faces will be size * size pixels.
  63492. */
  63493. size: number;
  63494. /**
  63495. * The format of the texture.
  63496. *
  63497. * RGBA, RGB.
  63498. */
  63499. format: number;
  63500. /**
  63501. * The type of the texture data.
  63502. *
  63503. * UNSIGNED_INT, FLOAT.
  63504. */
  63505. type: number;
  63506. /**
  63507. * Specifies whether the texture is in gamma space.
  63508. */
  63509. gammaSpace: boolean;
  63510. }
  63511. /**
  63512. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  63513. */
  63514. export class PanoramaToCubeMapTools {
  63515. private static FACE_FRONT;
  63516. private static FACE_BACK;
  63517. private static FACE_RIGHT;
  63518. private static FACE_LEFT;
  63519. private static FACE_DOWN;
  63520. private static FACE_UP;
  63521. /**
  63522. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  63523. *
  63524. * @param float32Array The source data.
  63525. * @param inputWidth The width of the input panorama.
  63526. * @param inputHeight The height of the input panorama.
  63527. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  63528. * @return The cubemap data
  63529. */
  63530. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  63531. private static CreateCubemapTexture;
  63532. private static CalcProjectionSpherical;
  63533. }
  63534. }
  63535. declare module BABYLON {
  63536. /**
  63537. * Helper class dealing with the extraction of spherical polynomial dataArray
  63538. * from a cube map.
  63539. */
  63540. export class CubeMapToSphericalPolynomialTools {
  63541. private static FileFaces;
  63542. /**
  63543. * Converts a texture to the according Spherical Polynomial data.
  63544. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63545. *
  63546. * @param texture The texture to extract the information from.
  63547. * @return The Spherical Polynomial data.
  63548. */
  63549. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  63550. /**
  63551. * Converts a cubemap to the according Spherical Polynomial data.
  63552. * This extracts the first 3 orders only as they are the only one used in the lighting.
  63553. *
  63554. * @param cubeInfo The Cube map to extract the information from.
  63555. * @return The Spherical Polynomial data.
  63556. */
  63557. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  63558. }
  63559. }
  63560. declare module BABYLON {
  63561. /**
  63562. * The engine store class is responsible to hold all the instances of Engine and Scene created
  63563. * during the life time of the application.
  63564. */
  63565. export class EngineStore {
  63566. /** Gets the list of created engines */
  63567. static Instances: Engine[];
  63568. /**
  63569. * Gets the latest created engine
  63570. */
  63571. static readonly LastCreatedEngine: Nullable<Engine>;
  63572. /**
  63573. * Gets the latest created scene
  63574. */
  63575. static readonly LastCreatedScene: Nullable<Scene>;
  63576. }
  63577. }
  63578. declare module BABYLON {
  63579. /**
  63580. * Define options used to create a render target texture
  63581. */
  63582. export class RenderTargetCreationOptions {
  63583. /**
  63584. * Specifies is mipmaps must be generated
  63585. */
  63586. generateMipMaps?: boolean;
  63587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  63588. generateDepthBuffer?: boolean;
  63589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  63590. generateStencilBuffer?: boolean;
  63591. /** Defines texture type (int by default) */
  63592. type?: number;
  63593. /** Defines sampling mode (trilinear by default) */
  63594. samplingMode?: number;
  63595. /** Defines format (RGBA by default) */
  63596. format?: number;
  63597. }
  63598. }
  63599. declare module BABYLON {
  63600. /**
  63601. * @hidden
  63602. **/
  63603. export class _AlphaState {
  63604. private _isAlphaBlendDirty;
  63605. private _isBlendFunctionParametersDirty;
  63606. private _isBlendEquationParametersDirty;
  63607. private _isBlendConstantsDirty;
  63608. private _alphaBlend;
  63609. private _blendFunctionParameters;
  63610. private _blendEquationParameters;
  63611. private _blendConstants;
  63612. /**
  63613. * Initializes the state.
  63614. */
  63615. constructor();
  63616. readonly isDirty: boolean;
  63617. alphaBlend: boolean;
  63618. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  63619. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  63620. setAlphaEquationParameters(rgb: number, alpha: number): void;
  63621. reset(): void;
  63622. apply(gl: WebGLRenderingContext): void;
  63623. }
  63624. }
  63625. declare module BABYLON {
  63626. /**
  63627. * @hidden
  63628. **/
  63629. export class _DepthCullingState {
  63630. private _isDepthTestDirty;
  63631. private _isDepthMaskDirty;
  63632. private _isDepthFuncDirty;
  63633. private _isCullFaceDirty;
  63634. private _isCullDirty;
  63635. private _isZOffsetDirty;
  63636. private _isFrontFaceDirty;
  63637. private _depthTest;
  63638. private _depthMask;
  63639. private _depthFunc;
  63640. private _cull;
  63641. private _cullFace;
  63642. private _zOffset;
  63643. private _frontFace;
  63644. /**
  63645. * Initializes the state.
  63646. */
  63647. constructor();
  63648. readonly isDirty: boolean;
  63649. zOffset: number;
  63650. cullFace: Nullable<number>;
  63651. cull: Nullable<boolean>;
  63652. depthFunc: Nullable<number>;
  63653. depthMask: boolean;
  63654. depthTest: boolean;
  63655. frontFace: Nullable<number>;
  63656. reset(): void;
  63657. apply(gl: WebGLRenderingContext): void;
  63658. }
  63659. }
  63660. declare module BABYLON {
  63661. /**
  63662. * @hidden
  63663. **/
  63664. export class _StencilState {
  63665. /** 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 */
  63666. static readonly ALWAYS: number;
  63667. /** Passed to stencilOperation to specify that stencil value must be kept */
  63668. static readonly KEEP: number;
  63669. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63670. static readonly REPLACE: number;
  63671. private _isStencilTestDirty;
  63672. private _isStencilMaskDirty;
  63673. private _isStencilFuncDirty;
  63674. private _isStencilOpDirty;
  63675. private _stencilTest;
  63676. private _stencilMask;
  63677. private _stencilFunc;
  63678. private _stencilFuncRef;
  63679. private _stencilFuncMask;
  63680. private _stencilOpStencilFail;
  63681. private _stencilOpDepthFail;
  63682. private _stencilOpStencilDepthPass;
  63683. readonly isDirty: boolean;
  63684. stencilFunc: number;
  63685. stencilFuncRef: number;
  63686. stencilFuncMask: number;
  63687. stencilOpStencilFail: number;
  63688. stencilOpDepthFail: number;
  63689. stencilOpStencilDepthPass: number;
  63690. stencilMask: number;
  63691. stencilTest: boolean;
  63692. constructor();
  63693. reset(): void;
  63694. apply(gl: WebGLRenderingContext): void;
  63695. }
  63696. }
  63697. declare module BABYLON {
  63698. /**
  63699. * @hidden
  63700. **/
  63701. export class _TimeToken {
  63702. _startTimeQuery: Nullable<WebGLQuery>;
  63703. _endTimeQuery: Nullable<WebGLQuery>;
  63704. _timeElapsedQuery: Nullable<WebGLQuery>;
  63705. _timeElapsedQueryEnded: boolean;
  63706. }
  63707. }
  63708. declare module BABYLON {
  63709. /**
  63710. * Internal interface used to track InternalTexture already bound to the GL context
  63711. */
  63712. export interface IInternalTextureTracker {
  63713. /**
  63714. * Gets or set the previous tracker in the list
  63715. */
  63716. previous: Nullable<IInternalTextureTracker>;
  63717. /**
  63718. * Gets or set the next tracker in the list
  63719. */
  63720. next: Nullable<IInternalTextureTracker>;
  63721. }
  63722. /**
  63723. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  63724. */
  63725. export class DummyInternalTextureTracker {
  63726. /**
  63727. * Gets or set the previous tracker in the list
  63728. */
  63729. previous: Nullable<IInternalTextureTracker>;
  63730. /**
  63731. * Gets or set the next tracker in the list
  63732. */
  63733. next: Nullable<IInternalTextureTracker>;
  63734. }
  63735. }
  63736. declare module BABYLON {
  63737. /**
  63738. * Class used to store data associated with WebGL texture data for the engine
  63739. * This class should not be used directly
  63740. */
  63741. export class InternalTexture implements IInternalTextureTracker {
  63742. /** hidden */
  63743. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  63744. /**
  63745. * The source of the texture data is unknown
  63746. */
  63747. static DATASOURCE_UNKNOWN: number;
  63748. /**
  63749. * Texture data comes from an URL
  63750. */
  63751. static DATASOURCE_URL: number;
  63752. /**
  63753. * Texture data is only used for temporary storage
  63754. */
  63755. static DATASOURCE_TEMP: number;
  63756. /**
  63757. * Texture data comes from raw data (ArrayBuffer)
  63758. */
  63759. static DATASOURCE_RAW: number;
  63760. /**
  63761. * Texture content is dynamic (video or dynamic texture)
  63762. */
  63763. static DATASOURCE_DYNAMIC: number;
  63764. /**
  63765. * Texture content is generated by rendering to it
  63766. */
  63767. static DATASOURCE_RENDERTARGET: number;
  63768. /**
  63769. * Texture content is part of a multi render target process
  63770. */
  63771. static DATASOURCE_MULTIRENDERTARGET: number;
  63772. /**
  63773. * Texture data comes from a cube data file
  63774. */
  63775. static DATASOURCE_CUBE: number;
  63776. /**
  63777. * Texture data comes from a raw cube data
  63778. */
  63779. static DATASOURCE_CUBERAW: number;
  63780. /**
  63781. * Texture data come from a prefiltered cube data file
  63782. */
  63783. static DATASOURCE_CUBEPREFILTERED: number;
  63784. /**
  63785. * Texture content is raw 3D data
  63786. */
  63787. static DATASOURCE_RAW3D: number;
  63788. /**
  63789. * Texture content is a depth texture
  63790. */
  63791. static DATASOURCE_DEPTHTEXTURE: number;
  63792. /**
  63793. * Texture data comes from a raw cube data encoded with RGBD
  63794. */
  63795. static DATASOURCE_CUBERAW_RGBD: number;
  63796. /**
  63797. * Defines if the texture is ready
  63798. */
  63799. isReady: boolean;
  63800. /**
  63801. * Defines if the texture is a cube texture
  63802. */
  63803. isCube: boolean;
  63804. /**
  63805. * Defines if the texture contains 3D data
  63806. */
  63807. is3D: boolean;
  63808. /**
  63809. * Gets the URL used to load this texture
  63810. */
  63811. url: string;
  63812. /**
  63813. * Gets the sampling mode of the texture
  63814. */
  63815. samplingMode: number;
  63816. /**
  63817. * Gets a boolean indicating if the texture needs mipmaps generation
  63818. */
  63819. generateMipMaps: boolean;
  63820. /**
  63821. * Gets the number of samples used by the texture (WebGL2+ only)
  63822. */
  63823. samples: number;
  63824. /**
  63825. * Gets the type of the texture (int, float...)
  63826. */
  63827. type: number;
  63828. /**
  63829. * Gets the format of the texture (RGB, RGBA...)
  63830. */
  63831. format: number;
  63832. /**
  63833. * Observable called when the texture is loaded
  63834. */
  63835. onLoadedObservable: Observable<InternalTexture>;
  63836. /**
  63837. * Gets the width of the texture
  63838. */
  63839. width: number;
  63840. /**
  63841. * Gets the height of the texture
  63842. */
  63843. height: number;
  63844. /**
  63845. * Gets the depth of the texture
  63846. */
  63847. depth: number;
  63848. /**
  63849. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  63850. */
  63851. baseWidth: number;
  63852. /**
  63853. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  63854. */
  63855. baseHeight: number;
  63856. /**
  63857. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  63858. */
  63859. baseDepth: number;
  63860. /**
  63861. * Gets a boolean indicating if the texture is inverted on Y axis
  63862. */
  63863. invertY: boolean;
  63864. /**
  63865. * Gets or set the previous tracker in the list
  63866. */
  63867. previous: Nullable<IInternalTextureTracker>;
  63868. /**
  63869. * Gets or set the next tracker in the list
  63870. */
  63871. next: Nullable<IInternalTextureTracker>;
  63872. /** @hidden */
  63873. _invertVScale: boolean;
  63874. /** @hidden */
  63875. _initialSlot: number;
  63876. /** @hidden */
  63877. _designatedSlot: number;
  63878. /** @hidden */
  63879. _dataSource: number;
  63880. /** @hidden */
  63881. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  63882. /** @hidden */
  63883. _bufferView: Nullable<ArrayBufferView>;
  63884. /** @hidden */
  63885. _bufferViewArray: Nullable<ArrayBufferView[]>;
  63886. /** @hidden */
  63887. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  63888. /** @hidden */
  63889. _size: number;
  63890. /** @hidden */
  63891. _extension: string;
  63892. /** @hidden */
  63893. _files: Nullable<string[]>;
  63894. /** @hidden */
  63895. _workingCanvas: HTMLCanvasElement;
  63896. /** @hidden */
  63897. _workingContext: CanvasRenderingContext2D;
  63898. /** @hidden */
  63899. _framebuffer: Nullable<WebGLFramebuffer>;
  63900. /** @hidden */
  63901. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  63902. /** @hidden */
  63903. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  63904. /** @hidden */
  63905. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  63906. /** @hidden */
  63907. _attachments: Nullable<number[]>;
  63908. /** @hidden */
  63909. _cachedCoordinatesMode: Nullable<number>;
  63910. /** @hidden */
  63911. _cachedWrapU: Nullable<number>;
  63912. /** @hidden */
  63913. _cachedWrapV: Nullable<number>;
  63914. /** @hidden */
  63915. _cachedWrapR: Nullable<number>;
  63916. /** @hidden */
  63917. _cachedAnisotropicFilteringLevel: Nullable<number>;
  63918. /** @hidden */
  63919. _isDisabled: boolean;
  63920. /** @hidden */
  63921. _compression: Nullable<string>;
  63922. /** @hidden */
  63923. _generateStencilBuffer: boolean;
  63924. /** @hidden */
  63925. _generateDepthBuffer: boolean;
  63926. /** @hidden */
  63927. _comparisonFunction: number;
  63928. /** @hidden */
  63929. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  63930. /** @hidden */
  63931. _lodGenerationScale: number;
  63932. /** @hidden */
  63933. _lodGenerationOffset: number;
  63934. /** @hidden */
  63935. _lodTextureHigh: BaseTexture;
  63936. /** @hidden */
  63937. _lodTextureMid: BaseTexture;
  63938. /** @hidden */
  63939. _lodTextureLow: BaseTexture;
  63940. /** @hidden */
  63941. _isRGBD: boolean;
  63942. /** @hidden */
  63943. _webGLTexture: Nullable<WebGLTexture>;
  63944. /** @hidden */
  63945. _references: number;
  63946. private _engine;
  63947. /**
  63948. * Gets the Engine the texture belongs to.
  63949. * @returns The babylon engine
  63950. */
  63951. getEngine(): Engine;
  63952. /**
  63953. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  63954. */
  63955. readonly dataSource: number;
  63956. /**
  63957. * Creates a new InternalTexture
  63958. * @param engine defines the engine to use
  63959. * @param dataSource defines the type of data that will be used
  63960. * @param delayAllocation if the texture allocation should be delayed (default: false)
  63961. */
  63962. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  63963. /**
  63964. * Increments the number of references (ie. the number of Texture that point to it)
  63965. */
  63966. incrementReferences(): void;
  63967. /**
  63968. * Change the size of the texture (not the size of the content)
  63969. * @param width defines the new width
  63970. * @param height defines the new height
  63971. * @param depth defines the new depth (1 by default)
  63972. */
  63973. updateSize(width: int, height: int, depth?: int): void;
  63974. /** @hidden */
  63975. _rebuild(): void;
  63976. /** @hidden */
  63977. _swapAndDie(target: InternalTexture): void;
  63978. /**
  63979. * Dispose the current allocated resources
  63980. */
  63981. dispose(): void;
  63982. }
  63983. }
  63984. declare module BABYLON {
  63985. /**
  63986. * This represents the main contract an easing function should follow.
  63987. * Easing functions are used throughout the animation system.
  63988. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  63989. */
  63990. export interface IEasingFunction {
  63991. /**
  63992. * Given an input gradient between 0 and 1, this returns the corrseponding value
  63993. * of the easing function.
  63994. * The link below provides some of the most common examples of easing functions.
  63995. * @see https://easings.net/
  63996. * @param gradient Defines the value between 0 and 1 we want the easing value for
  63997. * @returns the corresponding value on the curve defined by the easing function
  63998. */
  63999. ease(gradient: number): number;
  64000. }
  64001. /**
  64002. * Base class used for every default easing function.
  64003. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64004. */
  64005. export class EasingFunction implements IEasingFunction {
  64006. /**
  64007. * Interpolation follows the mathematical formula associated with the easing function.
  64008. */
  64009. static readonly EASINGMODE_EASEIN: number;
  64010. /**
  64011. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64012. */
  64013. static readonly EASINGMODE_EASEOUT: number;
  64014. /**
  64015. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64016. */
  64017. static readonly EASINGMODE_EASEINOUT: number;
  64018. private _easingMode;
  64019. /**
  64020. * Sets the easing mode of the current function.
  64021. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64022. */
  64023. setEasingMode(easingMode: number): void;
  64024. /**
  64025. * Gets the current easing mode.
  64026. * @returns the easing mode
  64027. */
  64028. getEasingMode(): number;
  64029. /**
  64030. * @hidden
  64031. */
  64032. easeInCore(gradient: number): number;
  64033. /**
  64034. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64035. * of the easing function.
  64036. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64037. * @returns the corresponding value on the curve defined by the easing function
  64038. */
  64039. ease(gradient: number): number;
  64040. }
  64041. /**
  64042. * Easing function with a circle shape (see link below).
  64043. * @see https://easings.net/#easeInCirc
  64044. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64045. */
  64046. export class CircleEase extends EasingFunction implements IEasingFunction {
  64047. /** @hidden */
  64048. easeInCore(gradient: number): number;
  64049. }
  64050. /**
  64051. * Easing function with a ease back shape (see link below).
  64052. * @see https://easings.net/#easeInBack
  64053. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64054. */
  64055. export class BackEase extends EasingFunction implements IEasingFunction {
  64056. /** Defines the amplitude of the function */
  64057. amplitude: number;
  64058. /**
  64059. * Instantiates a back ease easing
  64060. * @see https://easings.net/#easeInBack
  64061. * @param amplitude Defines the amplitude of the function
  64062. */
  64063. constructor(
  64064. /** Defines the amplitude of the function */
  64065. amplitude?: number);
  64066. /** @hidden */
  64067. easeInCore(gradient: number): number;
  64068. }
  64069. /**
  64070. * Easing function with a bouncing shape (see link below).
  64071. * @see https://easings.net/#easeInBounce
  64072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64073. */
  64074. export class BounceEase extends EasingFunction implements IEasingFunction {
  64075. /** Defines the number of bounces */
  64076. bounces: number;
  64077. /** Defines the amplitude of the bounce */
  64078. bounciness: number;
  64079. /**
  64080. * Instantiates a bounce easing
  64081. * @see https://easings.net/#easeInBounce
  64082. * @param bounces Defines the number of bounces
  64083. * @param bounciness Defines the amplitude of the bounce
  64084. */
  64085. constructor(
  64086. /** Defines the number of bounces */
  64087. bounces?: number,
  64088. /** Defines the amplitude of the bounce */
  64089. bounciness?: number);
  64090. /** @hidden */
  64091. easeInCore(gradient: number): number;
  64092. }
  64093. /**
  64094. * Easing function with a power of 3 shape (see link below).
  64095. * @see https://easings.net/#easeInCubic
  64096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64097. */
  64098. export class CubicEase extends EasingFunction implements IEasingFunction {
  64099. /** @hidden */
  64100. easeInCore(gradient: number): number;
  64101. }
  64102. /**
  64103. * Easing function with an elastic shape (see link below).
  64104. * @see https://easings.net/#easeInElastic
  64105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64106. */
  64107. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64108. /** Defines the number of oscillations*/
  64109. oscillations: number;
  64110. /** Defines the amplitude of the oscillations*/
  64111. springiness: number;
  64112. /**
  64113. * Instantiates an elastic easing function
  64114. * @see https://easings.net/#easeInElastic
  64115. * @param oscillations Defines the number of oscillations
  64116. * @param springiness Defines the amplitude of the oscillations
  64117. */
  64118. constructor(
  64119. /** Defines the number of oscillations*/
  64120. oscillations?: number,
  64121. /** Defines the amplitude of the oscillations*/
  64122. springiness?: number);
  64123. /** @hidden */
  64124. easeInCore(gradient: number): number;
  64125. }
  64126. /**
  64127. * Easing function with an exponential shape (see link below).
  64128. * @see https://easings.net/#easeInExpo
  64129. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64130. */
  64131. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64132. /** Defines the exponent of the function */
  64133. exponent: number;
  64134. /**
  64135. * Instantiates an exponential easing function
  64136. * @see https://easings.net/#easeInExpo
  64137. * @param exponent Defines the exponent of the function
  64138. */
  64139. constructor(
  64140. /** Defines the exponent of the function */
  64141. exponent?: number);
  64142. /** @hidden */
  64143. easeInCore(gradient: number): number;
  64144. }
  64145. /**
  64146. * Easing function with a power shape (see link below).
  64147. * @see https://easings.net/#easeInQuad
  64148. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64149. */
  64150. export class PowerEase extends EasingFunction implements IEasingFunction {
  64151. /** Defines the power of the function */
  64152. power: number;
  64153. /**
  64154. * Instantiates an power base easing function
  64155. * @see https://easings.net/#easeInQuad
  64156. * @param power Defines the power of the function
  64157. */
  64158. constructor(
  64159. /** Defines the power of the function */
  64160. power?: number);
  64161. /** @hidden */
  64162. easeInCore(gradient: number): number;
  64163. }
  64164. /**
  64165. * Easing function with a power of 2 shape (see link below).
  64166. * @see https://easings.net/#easeInQuad
  64167. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64168. */
  64169. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64170. /** @hidden */
  64171. easeInCore(gradient: number): number;
  64172. }
  64173. /**
  64174. * Easing function with a power of 4 shape (see link below).
  64175. * @see https://easings.net/#easeInQuart
  64176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64177. */
  64178. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64179. /** @hidden */
  64180. easeInCore(gradient: number): number;
  64181. }
  64182. /**
  64183. * Easing function with a power of 5 shape (see link below).
  64184. * @see https://easings.net/#easeInQuint
  64185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64186. */
  64187. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64188. /** @hidden */
  64189. easeInCore(gradient: number): number;
  64190. }
  64191. /**
  64192. * Easing function with a sin shape (see link below).
  64193. * @see https://easings.net/#easeInSine
  64194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64195. */
  64196. export class SineEase extends EasingFunction implements IEasingFunction {
  64197. /** @hidden */
  64198. easeInCore(gradient: number): number;
  64199. }
  64200. /**
  64201. * Easing function with a bezier shape (see link below).
  64202. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64203. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64204. */
  64205. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  64206. /** Defines the x component of the start tangent in the bezier curve */
  64207. x1: number;
  64208. /** Defines the y component of the start tangent in the bezier curve */
  64209. y1: number;
  64210. /** Defines the x component of the end tangent in the bezier curve */
  64211. x2: number;
  64212. /** Defines the y component of the end tangent in the bezier curve */
  64213. y2: number;
  64214. /**
  64215. * Instantiates a bezier function
  64216. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  64217. * @param x1 Defines the x component of the start tangent in the bezier curve
  64218. * @param y1 Defines the y component of the start tangent in the bezier curve
  64219. * @param x2 Defines the x component of the end tangent in the bezier curve
  64220. * @param y2 Defines the y component of the end tangent in the bezier curve
  64221. */
  64222. constructor(
  64223. /** Defines the x component of the start tangent in the bezier curve */
  64224. x1?: number,
  64225. /** Defines the y component of the start tangent in the bezier curve */
  64226. y1?: number,
  64227. /** Defines the x component of the end tangent in the bezier curve */
  64228. x2?: number,
  64229. /** Defines the y component of the end tangent in the bezier curve */
  64230. y2?: number);
  64231. /** @hidden */
  64232. easeInCore(gradient: number): number;
  64233. }
  64234. }
  64235. declare module BABYLON {
  64236. /**
  64237. * Defines an interface which represents an animation key frame
  64238. */
  64239. export interface IAnimationKey {
  64240. /**
  64241. * Frame of the key frame
  64242. */
  64243. frame: number;
  64244. /**
  64245. * Value at the specifies key frame
  64246. */
  64247. value: any;
  64248. /**
  64249. * The input tangent for the cubic hermite spline
  64250. */
  64251. inTangent?: any;
  64252. /**
  64253. * The output tangent for the cubic hermite spline
  64254. */
  64255. outTangent?: any;
  64256. /**
  64257. * The animation interpolation type
  64258. */
  64259. interpolation?: AnimationKeyInterpolation;
  64260. }
  64261. /**
  64262. * Enum for the animation key frame interpolation type
  64263. */
  64264. export enum AnimationKeyInterpolation {
  64265. /**
  64266. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  64267. */
  64268. STEP = 1
  64269. }
  64270. }
  64271. declare module BABYLON {
  64272. /**
  64273. * Represents the range of an animation
  64274. */
  64275. export class AnimationRange {
  64276. /**The name of the animation range**/
  64277. name: string;
  64278. /**The starting frame of the animation */
  64279. from: number;
  64280. /**The ending frame of the animation*/
  64281. to: number;
  64282. /**
  64283. * Initializes the range of an animation
  64284. * @param name The name of the animation range
  64285. * @param from The starting frame of the animation
  64286. * @param to The ending frame of the animation
  64287. */
  64288. constructor(
  64289. /**The name of the animation range**/
  64290. name: string,
  64291. /**The starting frame of the animation */
  64292. from: number,
  64293. /**The ending frame of the animation*/
  64294. to: number);
  64295. /**
  64296. * Makes a copy of the animation range
  64297. * @returns A copy of the animation range
  64298. */
  64299. clone(): AnimationRange;
  64300. }
  64301. }
  64302. declare module BABYLON {
  64303. /**
  64304. * Composed of a frame, and an action function
  64305. */
  64306. export class AnimationEvent {
  64307. /** The frame for which the event is triggered **/
  64308. frame: number;
  64309. /** The event to perform when triggered **/
  64310. action: (currentFrame: number) => void;
  64311. /** Specifies if the event should be triggered only once**/
  64312. onlyOnce?: boolean | undefined;
  64313. /**
  64314. * Specifies if the animation event is done
  64315. */
  64316. isDone: boolean;
  64317. /**
  64318. * Initializes the animation event
  64319. * @param frame The frame for which the event is triggered
  64320. * @param action The event to perform when triggered
  64321. * @param onlyOnce Specifies if the event should be triggered only once
  64322. */
  64323. constructor(
  64324. /** The frame for which the event is triggered **/
  64325. frame: number,
  64326. /** The event to perform when triggered **/
  64327. action: (currentFrame: number) => void,
  64328. /** Specifies if the event should be triggered only once**/
  64329. onlyOnce?: boolean | undefined);
  64330. /** @hidden */
  64331. _clone(): AnimationEvent;
  64332. }
  64333. }
  64334. declare module BABYLON {
  64335. /**
  64336. * Interface used to define a behavior
  64337. */
  64338. export interface Behavior<T> {
  64339. /** gets or sets behavior's name */
  64340. name: string;
  64341. /**
  64342. * Function called when the behavior needs to be initialized (after attaching it to a target)
  64343. */
  64344. init(): void;
  64345. /**
  64346. * Called when the behavior is attached to a target
  64347. * @param target defines the target where the behavior is attached to
  64348. */
  64349. attach(target: T): void;
  64350. /**
  64351. * Called when the behavior is detached from its target
  64352. */
  64353. detach(): void;
  64354. }
  64355. /**
  64356. * Interface implemented by classes supporting behaviors
  64357. */
  64358. export interface IBehaviorAware<T> {
  64359. /**
  64360. * Attach a behavior
  64361. * @param behavior defines the behavior to attach
  64362. * @returns the current host
  64363. */
  64364. addBehavior(behavior: Behavior<T>): T;
  64365. /**
  64366. * Remove a behavior from the current object
  64367. * @param behavior defines the behavior to detach
  64368. * @returns the current host
  64369. */
  64370. removeBehavior(behavior: Behavior<T>): T;
  64371. /**
  64372. * Gets a behavior using its name to search
  64373. * @param name defines the name to search
  64374. * @returns the behavior or null if not found
  64375. */
  64376. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  64377. }
  64378. }
  64379. declare module BABYLON {
  64380. /**
  64381. * @hidden
  64382. */
  64383. export class IntersectionInfo {
  64384. bu: Nullable<number>;
  64385. bv: Nullable<number>;
  64386. distance: number;
  64387. faceId: number;
  64388. subMeshId: number;
  64389. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  64390. }
  64391. }
  64392. declare module BABYLON {
  64393. /**
  64394. * Class used to store bounding sphere information
  64395. */
  64396. export class BoundingSphere {
  64397. /**
  64398. * Gets the center of the bounding sphere in local space
  64399. */
  64400. readonly center: Vector3;
  64401. /**
  64402. * Radius of the bounding sphere in local space
  64403. */
  64404. radius: number;
  64405. /**
  64406. * Gets the center of the bounding sphere in world space
  64407. */
  64408. readonly centerWorld: Vector3;
  64409. /**
  64410. * Radius of the bounding sphere in world space
  64411. */
  64412. radiusWorld: number;
  64413. /**
  64414. * Gets the minimum vector in local space
  64415. */
  64416. readonly minimum: Vector3;
  64417. /**
  64418. * Gets the maximum vector in local space
  64419. */
  64420. readonly maximum: Vector3;
  64421. private _worldMatrix;
  64422. private static readonly TmpVector3;
  64423. /**
  64424. * Creates a new bounding sphere
  64425. * @param min defines the minimum vector (in local space)
  64426. * @param max defines the maximum vector (in local space)
  64427. * @param worldMatrix defines the new world matrix
  64428. */
  64429. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64430. /**
  64431. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  64432. * @param min defines the new minimum vector (in local space)
  64433. * @param max defines the new maximum vector (in local space)
  64434. * @param worldMatrix defines the new world matrix
  64435. */
  64436. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64437. /**
  64438. * Scale the current bounding sphere by applying a scale factor
  64439. * @param factor defines the scale factor to apply
  64440. * @returns the current bounding box
  64441. */
  64442. scale(factor: number): BoundingSphere;
  64443. /**
  64444. * Gets the world matrix of the bounding box
  64445. * @returns a matrix
  64446. */
  64447. getWorldMatrix(): DeepImmutable<Matrix>;
  64448. /** @hidden */
  64449. _update(worldMatrix: DeepImmutable<Matrix>): void;
  64450. /**
  64451. * Tests if the bounding sphere is intersecting the frustum planes
  64452. * @param frustumPlanes defines the frustum planes to test
  64453. * @returns true if there is an intersection
  64454. */
  64455. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64456. /**
  64457. * Tests if the bounding sphere center is in between the frustum planes.
  64458. * Used for optimistic fast inclusion.
  64459. * @param frustumPlanes defines the frustum planes to test
  64460. * @returns true if the sphere center is in between the frustum planes
  64461. */
  64462. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64463. /**
  64464. * Tests if a point is inside the bounding sphere
  64465. * @param point defines the point to test
  64466. * @returns true if the point is inside the bounding sphere
  64467. */
  64468. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64469. /**
  64470. * Checks if two sphere intersct
  64471. * @param sphere0 sphere 0
  64472. * @param sphere1 sphere 1
  64473. * @returns true if the speres intersect
  64474. */
  64475. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  64476. }
  64477. }
  64478. declare module BABYLON {
  64479. /**
  64480. * Class used to store bounding box information
  64481. */
  64482. export class BoundingBox implements ICullable {
  64483. /**
  64484. * Gets the 8 vectors representing the bounding box in local space
  64485. */
  64486. readonly vectors: Vector3[];
  64487. /**
  64488. * Gets the center of the bounding box in local space
  64489. */
  64490. readonly center: Vector3;
  64491. /**
  64492. * Gets the center of the bounding box in world space
  64493. */
  64494. readonly centerWorld: Vector3;
  64495. /**
  64496. * Gets the extend size in local space
  64497. */
  64498. readonly extendSize: Vector3;
  64499. /**
  64500. * Gets the extend size in world space
  64501. */
  64502. readonly extendSizeWorld: Vector3;
  64503. /**
  64504. * Gets the OBB (object bounding box) directions
  64505. */
  64506. readonly directions: Vector3[];
  64507. /**
  64508. * Gets the 8 vectors representing the bounding box in world space
  64509. */
  64510. readonly vectorsWorld: Vector3[];
  64511. /**
  64512. * Gets the minimum vector in world space
  64513. */
  64514. readonly minimumWorld: Vector3;
  64515. /**
  64516. * Gets the maximum vector in world space
  64517. */
  64518. readonly maximumWorld: Vector3;
  64519. /**
  64520. * Gets the minimum vector in local space
  64521. */
  64522. readonly minimum: Vector3;
  64523. /**
  64524. * Gets the maximum vector in local space
  64525. */
  64526. readonly maximum: Vector3;
  64527. private _worldMatrix;
  64528. private static readonly TmpVector3;
  64529. /**
  64530. * @hidden
  64531. */
  64532. _tag: number;
  64533. /**
  64534. * Creates a new bounding box
  64535. * @param min defines the minimum vector (in local space)
  64536. * @param max defines the maximum vector (in local space)
  64537. * @param worldMatrix defines the new world matrix
  64538. */
  64539. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64540. /**
  64541. * Recreates the entire bounding box from scratch as if we call the constructor in place
  64542. * @param min defines the new minimum vector (in local space)
  64543. * @param max defines the new maximum vector (in local space)
  64544. * @param worldMatrix defines the new world matrix
  64545. */
  64546. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64547. /**
  64548. * Scale the current bounding box by applying a scale factor
  64549. * @param factor defines the scale factor to apply
  64550. * @returns the current bounding box
  64551. */
  64552. scale(factor: number): BoundingBox;
  64553. /**
  64554. * Gets the world matrix of the bounding box
  64555. * @returns a matrix
  64556. */
  64557. getWorldMatrix(): DeepImmutable<Matrix>;
  64558. /** @hidden */
  64559. _update(world: DeepImmutable<Matrix>): void;
  64560. /**
  64561. * Tests if the bounding box is intersecting the frustum planes
  64562. * @param frustumPlanes defines the frustum planes to test
  64563. * @returns true if there is an intersection
  64564. */
  64565. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64566. /**
  64567. * Tests if the bounding box is entirely inside the frustum planes
  64568. * @param frustumPlanes defines the frustum planes to test
  64569. * @returns true if there is an inclusion
  64570. */
  64571. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64572. /**
  64573. * Tests if a point is inside the bounding box
  64574. * @param point defines the point to test
  64575. * @returns true if the point is inside the bounding box
  64576. */
  64577. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64578. /**
  64579. * Tests if the bounding box intersects with a bounding sphere
  64580. * @param sphere defines the sphere to test
  64581. * @returns true if there is an intersection
  64582. */
  64583. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  64584. /**
  64585. * Tests if the bounding box intersects with a box defined by a min and max vectors
  64586. * @param min defines the min vector to use
  64587. * @param max defines the max vector to use
  64588. * @returns true if there is an intersection
  64589. */
  64590. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  64591. /**
  64592. * Tests if two bounding boxes are intersections
  64593. * @param box0 defines the first box to test
  64594. * @param box1 defines the second box to test
  64595. * @returns true if there is an intersection
  64596. */
  64597. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  64598. /**
  64599. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  64600. * @param minPoint defines the minimum vector of the bounding box
  64601. * @param maxPoint defines the maximum vector of the bounding box
  64602. * @param sphereCenter defines the sphere center
  64603. * @param sphereRadius defines the sphere radius
  64604. * @returns true if there is an intersection
  64605. */
  64606. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  64607. /**
  64608. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  64609. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64610. * @param frustumPlanes defines the frustum planes to test
  64611. * @return true if there is an inclusion
  64612. */
  64613. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64614. /**
  64615. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  64616. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  64617. * @param frustumPlanes defines the frustum planes to test
  64618. * @return true if there is an intersection
  64619. */
  64620. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64621. }
  64622. }
  64623. declare module BABYLON {
  64624. /** @hidden */
  64625. export class Collider {
  64626. /** Define if a collision was found */
  64627. collisionFound: boolean;
  64628. /**
  64629. * Define last intersection point in local space
  64630. */
  64631. intersectionPoint: Vector3;
  64632. /**
  64633. * Define last collided mesh
  64634. */
  64635. collidedMesh: Nullable<AbstractMesh>;
  64636. private _collisionPoint;
  64637. private _planeIntersectionPoint;
  64638. private _tempVector;
  64639. private _tempVector2;
  64640. private _tempVector3;
  64641. private _tempVector4;
  64642. private _edge;
  64643. private _baseToVertex;
  64644. private _destinationPoint;
  64645. private _slidePlaneNormal;
  64646. private _displacementVector;
  64647. /** @hidden */
  64648. _radius: Vector3;
  64649. /** @hidden */
  64650. _retry: number;
  64651. private _velocity;
  64652. private _basePoint;
  64653. private _epsilon;
  64654. /** @hidden */
  64655. _velocityWorldLength: number;
  64656. /** @hidden */
  64657. _basePointWorld: Vector3;
  64658. private _velocityWorld;
  64659. private _normalizedVelocity;
  64660. /** @hidden */
  64661. _initialVelocity: Vector3;
  64662. /** @hidden */
  64663. _initialPosition: Vector3;
  64664. private _nearestDistance;
  64665. private _collisionMask;
  64666. collisionMask: number;
  64667. /**
  64668. * Gets the plane normal used to compute the sliding response (in local space)
  64669. */
  64670. readonly slidePlaneNormal: Vector3;
  64671. /** @hidden */
  64672. _initialize(source: Vector3, dir: Vector3, e: number): void;
  64673. /** @hidden */
  64674. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  64675. /** @hidden */
  64676. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  64677. /** @hidden */
  64678. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  64679. /** @hidden */
  64680. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  64681. /** @hidden */
  64682. _getResponse(pos: Vector3, vel: Vector3): void;
  64683. }
  64684. }
  64685. declare module BABYLON {
  64686. /**
  64687. * Interface for cullable objects
  64688. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  64689. */
  64690. export interface ICullable {
  64691. /**
  64692. * Checks if the object or part of the object is in the frustum
  64693. * @param frustumPlanes Camera near/planes
  64694. * @returns true if the object is in frustum otherwise false
  64695. */
  64696. isInFrustum(frustumPlanes: Plane[]): boolean;
  64697. /**
  64698. * Checks if a cullable object (mesh...) is in the camera frustum
  64699. * Unlike isInFrustum this cheks the full bounding box
  64700. * @param frustumPlanes Camera near/planes
  64701. * @returns true if the object is in frustum otherwise false
  64702. */
  64703. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  64704. }
  64705. /**
  64706. * Info for a bounding data of a mesh
  64707. */
  64708. export class BoundingInfo implements ICullable {
  64709. /**
  64710. * Bounding box for the mesh
  64711. */
  64712. readonly boundingBox: BoundingBox;
  64713. /**
  64714. * Bounding sphere for the mesh
  64715. */
  64716. readonly boundingSphere: BoundingSphere;
  64717. private _isLocked;
  64718. private static readonly TmpVector3;
  64719. /**
  64720. * Constructs bounding info
  64721. * @param minimum min vector of the bounding box/sphere
  64722. * @param maximum max vector of the bounding box/sphere
  64723. * @param worldMatrix defines the new world matrix
  64724. */
  64725. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  64726. /**
  64727. * Recreates the entire bounding info from scratch as if we call the constructor in place
  64728. * @param min defines the new minimum vector (in local space)
  64729. * @param max defines the new maximum vector (in local space)
  64730. * @param worldMatrix defines the new world matrix
  64731. */
  64732. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  64733. /**
  64734. * min vector of the bounding box/sphere
  64735. */
  64736. readonly minimum: Vector3;
  64737. /**
  64738. * max vector of the bounding box/sphere
  64739. */
  64740. readonly maximum: Vector3;
  64741. /**
  64742. * If the info is locked and won't be updated to avoid perf overhead
  64743. */
  64744. isLocked: boolean;
  64745. /**
  64746. * Updates the bounding sphere and box
  64747. * @param world world matrix to be used to update
  64748. */
  64749. update(world: DeepImmutable<Matrix>): void;
  64750. /**
  64751. * Recreate the bounding info to be centered around a specific point given a specific extend.
  64752. * @param center New center of the bounding info
  64753. * @param extend New extend of the bounding info
  64754. * @returns the current bounding info
  64755. */
  64756. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  64757. /**
  64758. * Scale the current bounding info by applying a scale factor
  64759. * @param factor defines the scale factor to apply
  64760. * @returns the current bounding info
  64761. */
  64762. scale(factor: number): BoundingInfo;
  64763. /**
  64764. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  64765. * @param frustumPlanes defines the frustum to test
  64766. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  64767. * @returns true if the bounding info is in the frustum planes
  64768. */
  64769. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  64770. /**
  64771. * Gets the world distance between the min and max points of the bounding box
  64772. */
  64773. readonly diagonalLength: number;
  64774. /**
  64775. * Checks if a cullable object (mesh...) is in the camera frustum
  64776. * Unlike isInFrustum this cheks the full bounding box
  64777. * @param frustumPlanes Camera near/planes
  64778. * @returns true if the object is in frustum otherwise false
  64779. */
  64780. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  64781. /** @hidden */
  64782. _checkCollision(collider: Collider): boolean;
  64783. /**
  64784. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  64785. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64786. * @param point the point to check intersection with
  64787. * @returns if the point intersects
  64788. */
  64789. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  64790. /**
  64791. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  64792. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  64793. * @param boundingInfo the bounding info to check intersection with
  64794. * @param precise if the intersection should be done using OBB
  64795. * @returns if the bounding info intersects
  64796. */
  64797. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  64798. }
  64799. }
  64800. declare module BABYLON {
  64801. /**
  64802. * Defines an array and its length.
  64803. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  64804. */
  64805. export interface ISmartArrayLike<T> {
  64806. /**
  64807. * The data of the array.
  64808. */
  64809. data: Array<T>;
  64810. /**
  64811. * The active length of the array.
  64812. */
  64813. length: number;
  64814. }
  64815. /**
  64816. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64817. */
  64818. export class SmartArray<T> implements ISmartArrayLike<T> {
  64819. /**
  64820. * The full set of data from the array.
  64821. */
  64822. data: Array<T>;
  64823. /**
  64824. * The active length of the array.
  64825. */
  64826. length: number;
  64827. protected _id: number;
  64828. /**
  64829. * Instantiates a Smart Array.
  64830. * @param capacity defines the default capacity of the array.
  64831. */
  64832. constructor(capacity: number);
  64833. /**
  64834. * Pushes a value at the end of the active data.
  64835. * @param value defines the object to push in the array.
  64836. */
  64837. push(value: T): void;
  64838. /**
  64839. * Iterates over the active data and apply the lambda to them.
  64840. * @param func defines the action to apply on each value.
  64841. */
  64842. forEach(func: (content: T) => void): void;
  64843. /**
  64844. * Sorts the full sets of data.
  64845. * @param compareFn defines the comparison function to apply.
  64846. */
  64847. sort(compareFn: (a: T, b: T) => number): void;
  64848. /**
  64849. * Resets the active data to an empty array.
  64850. */
  64851. reset(): void;
  64852. /**
  64853. * Releases all the data from the array as well as the array.
  64854. */
  64855. dispose(): void;
  64856. /**
  64857. * Concats the active data with a given array.
  64858. * @param array defines the data to concatenate with.
  64859. */
  64860. concat(array: any): void;
  64861. /**
  64862. * Returns the position of a value in the active data.
  64863. * @param value defines the value to find the index for
  64864. * @returns the index if found in the active data otherwise -1
  64865. */
  64866. indexOf(value: T): number;
  64867. /**
  64868. * Returns whether an element is part of the active data.
  64869. * @param value defines the value to look for
  64870. * @returns true if found in the active data otherwise false
  64871. */
  64872. contains(value: T): boolean;
  64873. private static _GlobalId;
  64874. }
  64875. /**
  64876. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  64877. * The data in this array can only be present once
  64878. */
  64879. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  64880. private _duplicateId;
  64881. /**
  64882. * Pushes a value at the end of the active data.
  64883. * THIS DOES NOT PREVENT DUPPLICATE DATA
  64884. * @param value defines the object to push in the array.
  64885. */
  64886. push(value: T): void;
  64887. /**
  64888. * Pushes a value at the end of the active data.
  64889. * If the data is already present, it won t be added again
  64890. * @param value defines the object to push in the array.
  64891. * @returns true if added false if it was already present
  64892. */
  64893. pushNoDuplicate(value: T): boolean;
  64894. /**
  64895. * Resets the active data to an empty array.
  64896. */
  64897. reset(): void;
  64898. /**
  64899. * Concats the active data with a given array.
  64900. * This ensures no dupplicate will be present in the result.
  64901. * @param array defines the data to concatenate with.
  64902. */
  64903. concatWithNoDuplicate(array: any): void;
  64904. }
  64905. }
  64906. declare module BABYLON {
  64907. /**
  64908. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64909. * separate meshes. This can be use to improve performances.
  64910. * @see http://doc.babylonjs.com/how_to/multi_materials
  64911. */
  64912. export class MultiMaterial extends Material {
  64913. private _subMaterials;
  64914. /**
  64915. * Gets or Sets the list of Materials used within the multi material.
  64916. * They need to be ordered according to the submeshes order in the associated mesh
  64917. */
  64918. subMaterials: Nullable<Material>[];
  64919. /**
  64920. * Function used to align with Node.getChildren()
  64921. * @returns the list of Materials used within the multi material
  64922. */
  64923. getChildren(): Nullable<Material>[];
  64924. /**
  64925. * Instantiates a new Multi Material
  64926. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64927. * separate meshes. This can be use to improve performances.
  64928. * @see http://doc.babylonjs.com/how_to/multi_materials
  64929. * @param name Define the name in the scene
  64930. * @param scene Define the scene the material belongs to
  64931. */
  64932. constructor(name: string, scene: Scene);
  64933. private _hookArray;
  64934. /**
  64935. * Get one of the submaterial by its index in the submaterials array
  64936. * @param index The index to look the sub material at
  64937. * @returns The Material if the index has been defined
  64938. */
  64939. getSubMaterial(index: number): Nullable<Material>;
  64940. /**
  64941. * Get the list of active textures for the whole sub materials list.
  64942. * @returns All the textures that will be used during the rendering
  64943. */
  64944. getActiveTextures(): BaseTexture[];
  64945. /**
  64946. * Gets the current class name of the material e.g. "MultiMaterial"
  64947. * Mainly use in serialization.
  64948. * @returns the class name
  64949. */
  64950. getClassName(): string;
  64951. /**
  64952. * Checks if the material is ready to render the requested sub mesh
  64953. * @param mesh Define the mesh the submesh belongs to
  64954. * @param subMesh Define the sub mesh to look readyness for
  64955. * @param useInstances Define whether or not the material is used with instances
  64956. * @returns true if ready, otherwise false
  64957. */
  64958. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  64959. /**
  64960. * Clones the current material and its related sub materials
  64961. * @param name Define the name of the newly cloned material
  64962. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64963. * @returns the cloned material
  64964. */
  64965. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  64966. /**
  64967. * Serializes the materials into a JSON representation.
  64968. * @returns the JSON representation
  64969. */
  64970. serialize(): any;
  64971. /**
  64972. * Dispose the material and release its associated resources
  64973. * @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)
  64974. * @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)
  64975. * @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)
  64976. */
  64977. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  64978. /**
  64979. * Creates a MultiMaterial from parsed MultiMaterial data.
  64980. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64981. * @param scene defines the hosting scene
  64982. * @returns a new MultiMaterial
  64983. */
  64984. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  64985. }
  64986. }
  64987. declare module BABYLON {
  64988. /**
  64989. * Class used to represent data loading progression
  64990. */
  64991. export class SceneLoaderFlags {
  64992. private static _ForceFullSceneLoadingForIncremental;
  64993. private static _ShowLoadingScreen;
  64994. private static _CleanBoneMatrixWeights;
  64995. private static _loggingLevel;
  64996. /**
  64997. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  64998. */
  64999. static ForceFullSceneLoadingForIncremental: boolean;
  65000. /**
  65001. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65002. */
  65003. static ShowLoadingScreen: boolean;
  65004. /**
  65005. * Defines the current logging level (while loading the scene)
  65006. * @ignorenaming
  65007. */
  65008. static loggingLevel: number;
  65009. /**
  65010. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65011. */
  65012. static CleanBoneMatrixWeights: boolean;
  65013. }
  65014. }
  65015. declare module BABYLON {
  65016. /**
  65017. * 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.
  65018. * @see https://doc.babylonjs.com/how_to/transformnode
  65019. */
  65020. export class TransformNode extends Node {
  65021. /**
  65022. * Object will not rotate to face the camera
  65023. */
  65024. static BILLBOARDMODE_NONE: number;
  65025. /**
  65026. * Object will rotate to face the camera but only on the x axis
  65027. */
  65028. static BILLBOARDMODE_X: number;
  65029. /**
  65030. * Object will rotate to face the camera but only on the y axis
  65031. */
  65032. static BILLBOARDMODE_Y: number;
  65033. /**
  65034. * Object will rotate to face the camera but only on the z axis
  65035. */
  65036. static BILLBOARDMODE_Z: number;
  65037. /**
  65038. * Object will rotate to face the camera
  65039. */
  65040. static BILLBOARDMODE_ALL: number;
  65041. private _forward;
  65042. private _forwardInverted;
  65043. private _up;
  65044. private _right;
  65045. private _rightInverted;
  65046. private _position;
  65047. private _rotation;
  65048. private _rotationQuaternion;
  65049. protected _scaling: Vector3;
  65050. protected _isDirty: boolean;
  65051. private _transformToBoneReferal;
  65052. /**
  65053. * Set the billboard mode. Default is 0.
  65054. *
  65055. * | Value | Type | Description |
  65056. * | --- | --- | --- |
  65057. * | 0 | BILLBOARDMODE_NONE | |
  65058. * | 1 | BILLBOARDMODE_X | |
  65059. * | 2 | BILLBOARDMODE_Y | |
  65060. * | 4 | BILLBOARDMODE_Z | |
  65061. * | 7 | BILLBOARDMODE_ALL | |
  65062. *
  65063. */
  65064. billboardMode: number;
  65065. /**
  65066. * 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
  65067. */
  65068. scalingDeterminant: number;
  65069. /**
  65070. * Sets the distance of the object to max, often used by skybox
  65071. */
  65072. infiniteDistance: boolean;
  65073. /**
  65074. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65075. * By default the system will update normals to compensate
  65076. */
  65077. ignoreNonUniformScaling: boolean;
  65078. /** @hidden */
  65079. _poseMatrix: Matrix;
  65080. /** @hidden */
  65081. _localMatrix: Matrix;
  65082. private _absolutePosition;
  65083. private _pivotMatrix;
  65084. private _pivotMatrixInverse;
  65085. protected _postMultiplyPivotMatrix: boolean;
  65086. private _tempMatrix;
  65087. protected _isWorldMatrixFrozen: boolean;
  65088. /** @hidden */
  65089. _indexInSceneTransformNodesArray: number;
  65090. /**
  65091. * An event triggered after the world matrix is updated
  65092. */
  65093. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65094. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65095. /**
  65096. * Gets a string identifying the name of the class
  65097. * @returns "TransformNode" string
  65098. */
  65099. getClassName(): string;
  65100. /**
  65101. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65102. */
  65103. position: Vector3;
  65104. /**
  65105. * 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)).
  65106. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65107. */
  65108. rotation: Vector3;
  65109. /**
  65110. * 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)).
  65111. */
  65112. scaling: Vector3;
  65113. /**
  65114. * 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).
  65115. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65116. */
  65117. rotationQuaternion: Nullable<Quaternion>;
  65118. /**
  65119. * The forward direction of that transform in world space.
  65120. */
  65121. readonly forward: Vector3;
  65122. /**
  65123. * The up direction of that transform in world space.
  65124. */
  65125. readonly up: Vector3;
  65126. /**
  65127. * The right direction of that transform in world space.
  65128. */
  65129. readonly right: Vector3;
  65130. /**
  65131. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65132. * @param matrix the matrix to copy the pose from
  65133. * @returns this TransformNode.
  65134. */
  65135. updatePoseMatrix(matrix: Matrix): TransformNode;
  65136. /**
  65137. * Returns the mesh Pose matrix.
  65138. * @returns the pose matrix
  65139. */
  65140. getPoseMatrix(): Matrix;
  65141. /** @hidden */
  65142. _isSynchronized(): boolean;
  65143. /** @hidden */
  65144. _initCache(): void;
  65145. /**
  65146. * Flag the transform node as dirty (Forcing it to update everything)
  65147. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65148. * @returns this transform node
  65149. */
  65150. markAsDirty(property: string): TransformNode;
  65151. /**
  65152. * Returns the current mesh absolute position.
  65153. * Returns a Vector3.
  65154. */
  65155. readonly absolutePosition: Vector3;
  65156. /**
  65157. * Sets a new matrix to apply before all other transformation
  65158. * @param matrix defines the transform matrix
  65159. * @returns the current TransformNode
  65160. */
  65161. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65162. /**
  65163. * Sets a new pivot matrix to the current node
  65164. * @param matrix defines the new pivot matrix to use
  65165. * @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
  65166. * @returns the current TransformNode
  65167. */
  65168. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65169. /**
  65170. * Returns the mesh pivot matrix.
  65171. * Default : Identity.
  65172. * @returns the matrix
  65173. */
  65174. getPivotMatrix(): Matrix;
  65175. /**
  65176. * Prevents the World matrix to be computed any longer.
  65177. * @returns the TransformNode.
  65178. */
  65179. freezeWorldMatrix(): TransformNode;
  65180. /**
  65181. * Allows back the World matrix computation.
  65182. * @returns the TransformNode.
  65183. */
  65184. unfreezeWorldMatrix(): this;
  65185. /**
  65186. * True if the World matrix has been frozen.
  65187. */
  65188. readonly isWorldMatrixFrozen: boolean;
  65189. /**
  65190. * Retuns the mesh absolute position in the World.
  65191. * @returns a Vector3.
  65192. */
  65193. getAbsolutePosition(): Vector3;
  65194. /**
  65195. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65196. * @param absolutePosition the absolute position to set
  65197. * @returns the TransformNode.
  65198. */
  65199. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65200. /**
  65201. * Sets the mesh position in its local space.
  65202. * @param vector3 the position to set in localspace
  65203. * @returns the TransformNode.
  65204. */
  65205. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65206. /**
  65207. * Returns the mesh position in the local space from the current World matrix values.
  65208. * @returns a new Vector3.
  65209. */
  65210. getPositionExpressedInLocalSpace(): Vector3;
  65211. /**
  65212. * Translates the mesh along the passed Vector3 in its local space.
  65213. * @param vector3 the distance to translate in localspace
  65214. * @returns the TransformNode.
  65215. */
  65216. locallyTranslate(vector3: Vector3): TransformNode;
  65217. private static _lookAtVectorCache;
  65218. /**
  65219. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65220. * @param targetPoint the position (must be in same space as current mesh) to look at
  65221. * @param yawCor optional yaw (y-axis) correction in radians
  65222. * @param pitchCor optional pitch (x-axis) correction in radians
  65223. * @param rollCor optional roll (z-axis) correction in radians
  65224. * @param space the choosen space of the target
  65225. * @returns the TransformNode.
  65226. */
  65227. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65228. /**
  65229. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65230. * This Vector3 is expressed in the World space.
  65231. * @param localAxis axis to rotate
  65232. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65233. */
  65234. getDirection(localAxis: Vector3): Vector3;
  65235. /**
  65236. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65237. * localAxis is expressed in the mesh local space.
  65238. * result is computed in the Wordl space from the mesh World matrix.
  65239. * @param localAxis axis to rotate
  65240. * @param result the resulting transformnode
  65241. * @returns this TransformNode.
  65242. */
  65243. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65244. /**
  65245. * Sets this transform node rotation to the given local axis.
  65246. * @param localAxis the axis in local space
  65247. * @param yawCor optional yaw (y-axis) correction in radians
  65248. * @param pitchCor optional pitch (x-axis) correction in radians
  65249. * @param rollCor optional roll (z-axis) correction in radians
  65250. * @returns this TransformNode
  65251. */
  65252. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65253. /**
  65254. * Sets a new pivot point to the current node
  65255. * @param point defines the new pivot point to use
  65256. * @param space defines if the point is in world or local space (local by default)
  65257. * @returns the current TransformNode
  65258. */
  65259. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65260. /**
  65261. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65262. * @returns the pivot point
  65263. */
  65264. getPivotPoint(): Vector3;
  65265. /**
  65266. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65267. * @param result the vector3 to store the result
  65268. * @returns this TransformNode.
  65269. */
  65270. getPivotPointToRef(result: Vector3): TransformNode;
  65271. /**
  65272. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65273. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65274. */
  65275. getAbsolutePivotPoint(): Vector3;
  65276. /**
  65277. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65278. * @param result vector3 to store the result
  65279. * @returns this TransformNode.
  65280. */
  65281. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65282. /**
  65283. * Defines the passed node as the parent of the current node.
  65284. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65285. * @param node the node ot set as the parent
  65286. * @returns this TransformNode.
  65287. */
  65288. setParent(node: Nullable<Node>): TransformNode;
  65289. private _nonUniformScaling;
  65290. /**
  65291. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65292. */
  65293. readonly nonUniformScaling: boolean;
  65294. /** @hidden */
  65295. _updateNonUniformScalingState(value: boolean): boolean;
  65296. /**
  65297. * Attach the current TransformNode to another TransformNode associated with a bone
  65298. * @param bone Bone affecting the TransformNode
  65299. * @param affectedTransformNode TransformNode associated with the bone
  65300. * @returns this object
  65301. */
  65302. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65303. /**
  65304. * Detach the transform node if its associated with a bone
  65305. * @returns this object
  65306. */
  65307. detachFromBone(): TransformNode;
  65308. private static _rotationAxisCache;
  65309. /**
  65310. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65311. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65312. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65313. * The passed axis is also normalized.
  65314. * @param axis the axis to rotate around
  65315. * @param amount the amount to rotate in radians
  65316. * @param space Space to rotate in (Default: local)
  65317. * @returns the TransformNode.
  65318. */
  65319. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65320. /**
  65321. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65322. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65323. * The passed axis is also normalized. .
  65324. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65325. * @param point the point to rotate around
  65326. * @param axis the axis to rotate around
  65327. * @param amount the amount to rotate in radians
  65328. * @returns the TransformNode
  65329. */
  65330. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65331. /**
  65332. * Translates the mesh along the axis vector for the passed distance in the given space.
  65333. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65334. * @param axis the axis to translate in
  65335. * @param distance the distance to translate
  65336. * @param space Space to rotate in (Default: local)
  65337. * @returns the TransformNode.
  65338. */
  65339. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65340. /**
  65341. * Adds a rotation step to the mesh current rotation.
  65342. * x, y, z are Euler angles expressed in radians.
  65343. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65344. * This means this rotation is made in the mesh local space only.
  65345. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65346. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65347. * ```javascript
  65348. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65349. * ```
  65350. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65351. * 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.
  65352. * @param x Rotation to add
  65353. * @param y Rotation to add
  65354. * @param z Rotation to add
  65355. * @returns the TransformNode.
  65356. */
  65357. addRotation(x: number, y: number, z: number): TransformNode;
  65358. /**
  65359. * Computes the world matrix of the node
  65360. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65361. * @returns the world matrix
  65362. */
  65363. computeWorldMatrix(force?: boolean): Matrix;
  65364. protected _afterComputeWorldMatrix(): void;
  65365. /**
  65366. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65367. * @param func callback function to add
  65368. *
  65369. * @returns the TransformNode.
  65370. */
  65371. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65372. /**
  65373. * Removes a registered callback function.
  65374. * @param func callback function to remove
  65375. * @returns the TransformNode.
  65376. */
  65377. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65378. /**
  65379. * Gets the position of the current mesh in camera space
  65380. * @param camera defines the camera to use
  65381. * @returns a position
  65382. */
  65383. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65384. /**
  65385. * Returns the distance from the mesh to the active camera
  65386. * @param camera defines the camera to use
  65387. * @returns the distance
  65388. */
  65389. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65390. /**
  65391. * Clone the current transform node
  65392. * @param name Name of the new clone
  65393. * @param newParent New parent for the clone
  65394. * @param doNotCloneChildren Do not clone children hierarchy
  65395. * @returns the new transform node
  65396. */
  65397. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65398. /**
  65399. * Serializes the objects information.
  65400. * @param currentSerializationObject defines the object to serialize in
  65401. * @returns the serialized object
  65402. */
  65403. serialize(currentSerializationObject?: any): any;
  65404. /**
  65405. * Returns a new TransformNode object parsed from the source provided.
  65406. * @param parsedTransformNode is the source.
  65407. * @param scene the scne the object belongs to
  65408. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65409. * @returns a new TransformNode object parsed from the source provided.
  65410. */
  65411. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65412. /**
  65413. * Get all child-transformNodes of this node
  65414. * @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
  65415. * @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
  65416. * @returns an array of TransformNode
  65417. */
  65418. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65419. /**
  65420. * Releases resources associated with this transform node.
  65421. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65422. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65423. */
  65424. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65425. }
  65426. }
  65427. declare module BABYLON {
  65428. /**
  65429. * Class used to override all child animations of a given target
  65430. */
  65431. export class AnimationPropertiesOverride {
  65432. /**
  65433. * Gets or sets a value indicating if animation blending must be used
  65434. */
  65435. enableBlending: boolean;
  65436. /**
  65437. * Gets or sets the blending speed to use when enableBlending is true
  65438. */
  65439. blendingSpeed: number;
  65440. /**
  65441. * Gets or sets the default loop mode to use
  65442. */
  65443. loopMode: number;
  65444. }
  65445. }
  65446. declare module BABYLON {
  65447. /**
  65448. * Class used to store bone information
  65449. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  65450. */
  65451. export class Bone extends Node {
  65452. /**
  65453. * defines the bone name
  65454. */
  65455. name: string;
  65456. private static _tmpVecs;
  65457. private static _tmpQuat;
  65458. private static _tmpMats;
  65459. /**
  65460. * Gets the list of child bones
  65461. */
  65462. children: Bone[];
  65463. /** Gets the animations associated with this bone */
  65464. animations: Animation[];
  65465. /**
  65466. * Gets or sets bone length
  65467. */
  65468. length: number;
  65469. /**
  65470. * @hidden Internal only
  65471. * Set this value to map this bone to a different index in the transform matrices
  65472. * Set this value to -1 to exclude the bone from the transform matrices
  65473. */
  65474. _index: Nullable<number>;
  65475. private _skeleton;
  65476. private _localMatrix;
  65477. private _restPose;
  65478. private _baseMatrix;
  65479. private _absoluteTransform;
  65480. private _invertedAbsoluteTransform;
  65481. private _parent;
  65482. private _scalingDeterminant;
  65483. private _worldTransform;
  65484. private _localScaling;
  65485. private _localRotation;
  65486. private _localPosition;
  65487. private _needToDecompose;
  65488. private _needToCompose;
  65489. /** @hidden */
  65490. _linkedTransformNode: Nullable<TransformNode>;
  65491. /** @hidden */
  65492. /** @hidden */
  65493. _matrix: Matrix;
  65494. /**
  65495. * Create a new bone
  65496. * @param name defines the bone name
  65497. * @param skeleton defines the parent skeleton
  65498. * @param parentBone defines the parent (can be null if the bone is the root)
  65499. * @param localMatrix defines the local matrix
  65500. * @param restPose defines the rest pose matrix
  65501. * @param baseMatrix defines the base matrix
  65502. * @param index defines index of the bone in the hiearchy
  65503. */
  65504. constructor(
  65505. /**
  65506. * defines the bone name
  65507. */
  65508. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  65509. /**
  65510. * Gets the current object class name.
  65511. * @return the class name
  65512. */
  65513. getClassName(): string;
  65514. /**
  65515. * Gets the parent skeleton
  65516. * @returns a skeleton
  65517. */
  65518. getSkeleton(): Skeleton;
  65519. /**
  65520. * Gets parent bone
  65521. * @returns a bone or null if the bone is the root of the bone hierarchy
  65522. */
  65523. getParent(): Nullable<Bone>;
  65524. /**
  65525. * Returns an array containing the root bones
  65526. * @returns an array containing the root bones
  65527. */
  65528. getChildren(): Array<Bone>;
  65529. /**
  65530. * Sets the parent bone
  65531. * @param parent defines the parent (can be null if the bone is the root)
  65532. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65533. */
  65534. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  65535. /**
  65536. * Gets the local matrix
  65537. * @returns a matrix
  65538. */
  65539. getLocalMatrix(): Matrix;
  65540. /**
  65541. * Gets the base matrix (initial matrix which remains unchanged)
  65542. * @returns a matrix
  65543. */
  65544. getBaseMatrix(): Matrix;
  65545. /**
  65546. * Gets the rest pose matrix
  65547. * @returns a matrix
  65548. */
  65549. getRestPose(): Matrix;
  65550. /**
  65551. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  65552. */
  65553. getWorldMatrix(): Matrix;
  65554. /**
  65555. * Sets the local matrix to rest pose matrix
  65556. */
  65557. returnToRest(): void;
  65558. /**
  65559. * Gets the inverse of the absolute transform matrix.
  65560. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  65561. * @returns a matrix
  65562. */
  65563. getInvertedAbsoluteTransform(): Matrix;
  65564. /**
  65565. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  65566. * @returns a matrix
  65567. */
  65568. getAbsoluteTransform(): Matrix;
  65569. /**
  65570. * Links with the given transform node.
  65571. * The local matrix of this bone is copied from the transform node every frame.
  65572. * @param transformNode defines the transform node to link to
  65573. */
  65574. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  65575. /** Gets or sets current position (in local space) */
  65576. position: Vector3;
  65577. /** Gets or sets current rotation (in local space) */
  65578. rotation: Vector3;
  65579. /** Gets or sets current rotation quaternion (in local space) */
  65580. rotationQuaternion: Quaternion;
  65581. /** Gets or sets current scaling (in local space) */
  65582. scaling: Vector3;
  65583. /**
  65584. * Gets the animation properties override
  65585. */
  65586. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  65587. private _decompose;
  65588. private _compose;
  65589. /**
  65590. * Update the base and local matrices
  65591. * @param matrix defines the new base or local matrix
  65592. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  65593. * @param updateLocalMatrix defines if the local matrix should be updated
  65594. */
  65595. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  65596. /** @hidden */
  65597. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  65598. /**
  65599. * Flag the bone as dirty (Forcing it to update everything)
  65600. */
  65601. markAsDirty(): void;
  65602. private _markAsDirtyAndCompose;
  65603. private _markAsDirtyAndDecompose;
  65604. /**
  65605. * Translate the bone in local or world space
  65606. * @param vec The amount to translate the bone
  65607. * @param space The space that the translation is in
  65608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65609. */
  65610. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65611. /**
  65612. * Set the postion of the bone in local or world space
  65613. * @param position The position to set the bone
  65614. * @param space The space that the position is in
  65615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65616. */
  65617. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65618. /**
  65619. * Set the absolute position of the bone (world space)
  65620. * @param position The position to set the bone
  65621. * @param mesh The mesh that this bone is attached to
  65622. */
  65623. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  65624. /**
  65625. * Scale the bone on the x, y and z axes (in local space)
  65626. * @param x The amount to scale the bone on the x axis
  65627. * @param y The amount to scale the bone on the y axis
  65628. * @param z The amount to scale the bone on the z axis
  65629. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  65630. */
  65631. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  65632. /**
  65633. * Set the bone scaling in local space
  65634. * @param scale defines the scaling vector
  65635. */
  65636. setScale(scale: Vector3): void;
  65637. /**
  65638. * Gets the current scaling in local space
  65639. * @returns the current scaling vector
  65640. */
  65641. getScale(): Vector3;
  65642. /**
  65643. * Gets the current scaling in local space and stores it in a target vector
  65644. * @param result defines the target vector
  65645. */
  65646. getScaleToRef(result: Vector3): void;
  65647. /**
  65648. * Set the yaw, pitch, and roll of the bone in local or world space
  65649. * @param yaw The rotation of the bone on the y axis
  65650. * @param pitch The rotation of the bone on the x axis
  65651. * @param roll The rotation of the bone on the z axis
  65652. * @param space The space that the axes of rotation are in
  65653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65654. */
  65655. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  65656. /**
  65657. * Add a rotation to the bone on an axis in local or world space
  65658. * @param axis The axis to rotate the bone on
  65659. * @param amount The amount to rotate the bone
  65660. * @param space The space that the axis is in
  65661. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65662. */
  65663. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  65664. /**
  65665. * Set the rotation of the bone to a particular axis angle in local or world space
  65666. * @param axis The axis to rotate the bone on
  65667. * @param angle The angle that the bone should be rotated to
  65668. * @param space The space that the axis is in
  65669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65670. */
  65671. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  65672. /**
  65673. * Set the euler rotation of the bone in local of world space
  65674. * @param rotation The euler rotation that the bone should be set to
  65675. * @param space The space that the rotation is in
  65676. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65677. */
  65678. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  65679. /**
  65680. * Set the quaternion rotation of the bone in local of world space
  65681. * @param quat The quaternion rotation that the bone should be set to
  65682. * @param space The space that the rotation is in
  65683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65684. */
  65685. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  65686. /**
  65687. * Set the rotation matrix of the bone in local of world space
  65688. * @param rotMat The rotation matrix that the bone should be set to
  65689. * @param space The space that the rotation is in
  65690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65691. */
  65692. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  65693. private _rotateWithMatrix;
  65694. private _getNegativeRotationToRef;
  65695. /**
  65696. * Get the position of the bone in local or world space
  65697. * @param space The space that the returned position is in
  65698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65699. * @returns The position of the bone
  65700. */
  65701. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65702. /**
  65703. * Copy the position of the bone to a vector3 in local or world space
  65704. * @param space The space that the returned position is in
  65705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65706. * @param result The vector3 to copy the position to
  65707. */
  65708. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  65709. /**
  65710. * Get the absolute position of the bone (world space)
  65711. * @param mesh The mesh that this bone is attached to
  65712. * @returns The absolute position of the bone
  65713. */
  65714. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  65715. /**
  65716. * Copy the absolute position of the bone (world space) to the result param
  65717. * @param mesh The mesh that this bone is attached to
  65718. * @param result The vector3 to copy the absolute position to
  65719. */
  65720. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  65721. /**
  65722. * Compute the absolute transforms of this bone and its children
  65723. */
  65724. computeAbsoluteTransforms(): void;
  65725. /**
  65726. * Get the world direction from an axis that is in the local space of the bone
  65727. * @param localAxis The local direction that is used to compute the world direction
  65728. * @param mesh The mesh that this bone is attached to
  65729. * @returns The world direction
  65730. */
  65731. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65732. /**
  65733. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  65734. * @param localAxis The local direction that is used to compute the world direction
  65735. * @param mesh The mesh that this bone is attached to
  65736. * @param result The vector3 that the world direction will be copied to
  65737. */
  65738. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65739. /**
  65740. * Get the euler rotation of the bone in local or world space
  65741. * @param space The space that the rotation should be in
  65742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65743. * @returns The euler rotation
  65744. */
  65745. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  65746. /**
  65747. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  65748. * @param space The space that the rotation should be in
  65749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65750. * @param result The vector3 that the rotation should be copied to
  65751. */
  65752. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65753. /**
  65754. * Get the quaternion rotation of the bone in either local or world space
  65755. * @param space The space that the rotation should be in
  65756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65757. * @returns The quaternion rotation
  65758. */
  65759. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  65760. /**
  65761. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  65762. * @param space The space that the rotation should be in
  65763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65764. * @param result The quaternion that the rotation should be copied to
  65765. */
  65766. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  65767. /**
  65768. * Get the rotation matrix of the bone in local or world space
  65769. * @param space The space that the rotation should be in
  65770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65771. * @returns The rotation matrix
  65772. */
  65773. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  65774. /**
  65775. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  65776. * @param space The space that the rotation should be in
  65777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  65778. * @param result The quaternion that the rotation should be copied to
  65779. */
  65780. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  65781. /**
  65782. * Get the world position of a point that is in the local space of the bone
  65783. * @param position The local position
  65784. * @param mesh The mesh that this bone is attached to
  65785. * @returns The world position
  65786. */
  65787. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65788. /**
  65789. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  65790. * @param position The local position
  65791. * @param mesh The mesh that this bone is attached to
  65792. * @param result The vector3 that the world position should be copied to
  65793. */
  65794. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65795. /**
  65796. * Get the local position of a point that is in world space
  65797. * @param position The world position
  65798. * @param mesh The mesh that this bone is attached to
  65799. * @returns The local position
  65800. */
  65801. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  65802. /**
  65803. * Get the local position of a point that is in world space and copy it to the result param
  65804. * @param position The world position
  65805. * @param mesh The mesh that this bone is attached to
  65806. * @param result The vector3 that the local position should be copied to
  65807. */
  65808. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  65809. }
  65810. }
  65811. declare module BABYLON {
  65812. /**
  65813. * Class for creating a cube texture
  65814. */
  65815. export class CubeTexture extends BaseTexture {
  65816. private _delayedOnLoad;
  65817. /**
  65818. * The url of the texture
  65819. */
  65820. url: string;
  65821. /**
  65822. * Gets or sets the center of the bounding box associated with the cube texture.
  65823. * It must define where the camera used to render the texture was set
  65824. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65825. */
  65826. boundingBoxPosition: Vector3;
  65827. private _boundingBoxSize;
  65828. /**
  65829. * Gets or sets the size of the bounding box associated with the cube texture
  65830. * When defined, the cubemap will switch to local mode
  65831. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  65832. * @example https://www.babylonjs-playground.com/#RNASML
  65833. */
  65834. /**
  65835. * Returns the bounding box size
  65836. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  65837. */
  65838. boundingBoxSize: Vector3;
  65839. protected _rotationY: number;
  65840. /**
  65841. * Sets texture matrix rotation angle around Y axis in radians.
  65842. */
  65843. /**
  65844. * Gets texture matrix rotation angle around Y axis radians.
  65845. */
  65846. rotationY: number;
  65847. /**
  65848. * Are mip maps generated for this texture or not.
  65849. */
  65850. readonly noMipmap: boolean;
  65851. private _noMipmap;
  65852. private _files;
  65853. private _extensions;
  65854. private _textureMatrix;
  65855. private _format;
  65856. private _createPolynomials;
  65857. /** @hidden */
  65858. _prefiltered: boolean;
  65859. /**
  65860. * Creates a cube texture from an array of image urls
  65861. * @param files defines an array of image urls
  65862. * @param scene defines the hosting scene
  65863. * @param noMipmap specifies if mip maps are not used
  65864. * @returns a cube texture
  65865. */
  65866. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  65867. /**
  65868. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  65869. * @param url defines the url of the prefiltered texture
  65870. * @param scene defines the scene the texture is attached to
  65871. * @param forcedExtension defines the extension of the file if different from the url
  65872. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65873. * @return the prefiltered texture
  65874. */
  65875. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  65876. /**
  65877. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  65878. * as prefiltered data.
  65879. * @param rootUrl defines the url of the texture or the root name of the six images
  65880. * @param scene defines the scene the texture is attached to
  65881. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  65882. * @param noMipmap defines if mipmaps should be created or not
  65883. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  65884. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  65885. * @param onError defines a callback triggered in case of error during load
  65886. * @param format defines the internal format to use for the texture once loaded
  65887. * @param prefiltered defines whether or not the texture is created from prefiltered data
  65888. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  65889. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  65890. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65891. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65892. * @return the cube texture
  65893. */
  65894. 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);
  65895. /**
  65896. * Get the current class name of the texture useful for serialization or dynamic coding.
  65897. * @returns "CubeTexture"
  65898. */
  65899. getClassName(): string;
  65900. /**
  65901. * Update the url (and optional buffer) of this texture if url was null during construction.
  65902. * @param url the url of the texture
  65903. * @param forcedExtension defines the extension to use
  65904. * @param onLoad callback called when the texture is loaded (defaults to null)
  65905. */
  65906. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  65907. /**
  65908. * Delays loading of the cube texture
  65909. * @param forcedExtension defines the extension to use
  65910. */
  65911. delayLoad(forcedExtension?: string): void;
  65912. /**
  65913. * Returns the reflection texture matrix
  65914. * @returns the reflection texture matrix
  65915. */
  65916. getReflectionTextureMatrix(): Matrix;
  65917. /**
  65918. * Sets the reflection texture matrix
  65919. * @param value Reflection texture matrix
  65920. */
  65921. setReflectionTextureMatrix(value: Matrix): void;
  65922. /**
  65923. * Parses text to create a cube texture
  65924. * @param parsedTexture define the serialized text to read from
  65925. * @param scene defines the hosting scene
  65926. * @param rootUrl defines the root url of the cube texture
  65927. * @returns a cube texture
  65928. */
  65929. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  65930. /**
  65931. * Makes a clone, or deep copy, of the cube texture
  65932. * @returns a new cube texture
  65933. */
  65934. clone(): CubeTexture;
  65935. }
  65936. }
  65937. declare module BABYLON {
  65938. /** @hidden */
  65939. export var postprocessVertexShader: {
  65940. name: string;
  65941. shader: string;
  65942. };
  65943. }
  65944. declare module BABYLON {
  65945. /**
  65946. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  65947. * This is the base of the follow, arc rotate cameras and Free camera
  65948. * @see http://doc.babylonjs.com/features/cameras
  65949. */
  65950. export class TargetCamera extends Camera {
  65951. private static _RigCamTransformMatrix;
  65952. private static _TargetTransformMatrix;
  65953. private static _TargetFocalPoint;
  65954. /**
  65955. * Define the current direction the camera is moving to
  65956. */
  65957. cameraDirection: Vector3;
  65958. /**
  65959. * Define the current rotation the camera is rotating to
  65960. */
  65961. cameraRotation: Vector2;
  65962. /**
  65963. * When set, the up vector of the camera will be updated by the rotation of the camera
  65964. */
  65965. updateUpVectorFromRotation: boolean;
  65966. private _tmpQuaternion;
  65967. /**
  65968. * Define the current rotation of the camera
  65969. */
  65970. rotation: Vector3;
  65971. /**
  65972. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  65973. */
  65974. rotationQuaternion: Quaternion;
  65975. /**
  65976. * Define the current speed of the camera
  65977. */
  65978. speed: number;
  65979. /**
  65980. * Add cconstraint to the camera to prevent it to move freely in all directions and
  65981. * around all axis.
  65982. */
  65983. noRotationConstraint: boolean;
  65984. /**
  65985. * Define the current target of the camera as an object or a position.
  65986. */
  65987. lockedTarget: any;
  65988. /** @hidden */
  65989. _currentTarget: Vector3;
  65990. /** @hidden */
  65991. _initialFocalDistance: number;
  65992. /** @hidden */
  65993. _viewMatrix: Matrix;
  65994. /** @hidden */
  65995. _camMatrix: Matrix;
  65996. /** @hidden */
  65997. _cameraTransformMatrix: Matrix;
  65998. /** @hidden */
  65999. _cameraRotationMatrix: Matrix;
  66000. /** @hidden */
  66001. _referencePoint: Vector3;
  66002. /** @hidden */
  66003. _transformedReferencePoint: Vector3;
  66004. protected _globalCurrentTarget: Vector3;
  66005. protected _globalCurrentUpVector: Vector3;
  66006. /** @hidden */
  66007. _reset: () => void;
  66008. private _defaultUp;
  66009. /**
  66010. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66011. * This is the base of the follow, arc rotate cameras and Free camera
  66012. * @see http://doc.babylonjs.com/features/cameras
  66013. * @param name Defines the name of the camera in the scene
  66014. * @param position Defines the start position of the camera in the scene
  66015. * @param scene Defines the scene the camera belongs to
  66016. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66017. */
  66018. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66019. /**
  66020. * Gets the position in front of the camera at a given distance.
  66021. * @param distance The distance from the camera we want the position to be
  66022. * @returns the position
  66023. */
  66024. getFrontPosition(distance: number): Vector3;
  66025. /** @hidden */
  66026. _getLockedTargetPosition(): Nullable<Vector3>;
  66027. private _storedPosition;
  66028. private _storedRotation;
  66029. private _storedRotationQuaternion;
  66030. /**
  66031. * Store current camera state of the camera (fov, position, rotation, etc..)
  66032. * @returns the camera
  66033. */
  66034. storeState(): Camera;
  66035. /**
  66036. * Restored camera state. You must call storeState() first
  66037. * @returns whether it was successful or not
  66038. * @hidden
  66039. */
  66040. _restoreStateValues(): boolean;
  66041. /** @hidden */
  66042. _initCache(): void;
  66043. /** @hidden */
  66044. _updateCache(ignoreParentClass?: boolean): void;
  66045. /** @hidden */
  66046. _isSynchronizedViewMatrix(): boolean;
  66047. /** @hidden */
  66048. _computeLocalCameraSpeed(): number;
  66049. /**
  66050. * Defines the target the camera should look at.
  66051. * This will automatically adapt alpha beta and radius to fit within the new target.
  66052. * @param target Defines the new target as a Vector or a mesh
  66053. */
  66054. setTarget(target: Vector3): void;
  66055. /**
  66056. * Return the current target position of the camera. This value is expressed in local space.
  66057. * @returns the target position
  66058. */
  66059. getTarget(): Vector3;
  66060. /** @hidden */
  66061. _decideIfNeedsToMove(): boolean;
  66062. /** @hidden */
  66063. _updatePosition(): void;
  66064. /** @hidden */
  66065. _checkInputs(): void;
  66066. protected _updateCameraRotationMatrix(): void;
  66067. /**
  66068. * 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)
  66069. * @returns the current camera
  66070. */
  66071. private _rotateUpVectorWithCameraRotationMatrix;
  66072. private _cachedRotationZ;
  66073. private _cachedQuaternionRotationZ;
  66074. /** @hidden */
  66075. _getViewMatrix(): Matrix;
  66076. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66077. /**
  66078. * @hidden
  66079. */
  66080. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66081. /**
  66082. * @hidden
  66083. */
  66084. _updateRigCameras(): void;
  66085. private _getRigCamPositionAndTarget;
  66086. /**
  66087. * Gets the current object class name.
  66088. * @return the class name
  66089. */
  66090. getClassName(): string;
  66091. }
  66092. }
  66093. declare module BABYLON {
  66094. /**
  66095. * @ignore
  66096. * This is a list of all the different input types that are available in the application.
  66097. * Fo instance: ArcRotateCameraGamepadInput...
  66098. */
  66099. export var CameraInputTypes: {};
  66100. /**
  66101. * This is the contract to implement in order to create a new input class.
  66102. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66103. */
  66104. export interface ICameraInput<TCamera extends Camera> {
  66105. /**
  66106. * Defines the camera the input is attached to.
  66107. */
  66108. camera: Nullable<TCamera>;
  66109. /**
  66110. * Gets the class name of the current intput.
  66111. * @returns the class name
  66112. */
  66113. getClassName(): string;
  66114. /**
  66115. * Get the friendly name associated with the input class.
  66116. * @returns the input friendly name
  66117. */
  66118. getSimpleName(): string;
  66119. /**
  66120. * Attach the input controls to a specific dom element to get the input from.
  66121. * @param element Defines the element the controls should be listened from
  66122. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66123. */
  66124. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66125. /**
  66126. * Detach the current controls from the specified dom element.
  66127. * @param element Defines the element to stop listening the inputs from
  66128. */
  66129. detachControl(element: Nullable<HTMLElement>): void;
  66130. /**
  66131. * Update the current camera state depending on the inputs that have been used this frame.
  66132. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66133. */
  66134. checkInputs?: () => void;
  66135. }
  66136. /**
  66137. * Represents a map of input types to input instance or input index to input instance.
  66138. */
  66139. export interface CameraInputsMap<TCamera extends Camera> {
  66140. /**
  66141. * Accessor to the input by input type.
  66142. */
  66143. [name: string]: ICameraInput<TCamera>;
  66144. /**
  66145. * Accessor to the input by input index.
  66146. */
  66147. [idx: number]: ICameraInput<TCamera>;
  66148. }
  66149. /**
  66150. * This represents the input manager used within a camera.
  66151. * It helps dealing with all the different kind of input attached to a camera.
  66152. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66153. */
  66154. export class CameraInputsManager<TCamera extends Camera> {
  66155. /**
  66156. * Defines the list of inputs attahed to the camera.
  66157. */
  66158. attached: CameraInputsMap<TCamera>;
  66159. /**
  66160. * Defines the dom element the camera is collecting inputs from.
  66161. * This is null if the controls have not been attached.
  66162. */
  66163. attachedElement: Nullable<HTMLElement>;
  66164. /**
  66165. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66166. */
  66167. noPreventDefault: boolean;
  66168. /**
  66169. * Defined the camera the input manager belongs to.
  66170. */
  66171. camera: TCamera;
  66172. /**
  66173. * Update the current camera state depending on the inputs that have been used this frame.
  66174. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66175. */
  66176. checkInputs: () => void;
  66177. /**
  66178. * Instantiate a new Camera Input Manager.
  66179. * @param camera Defines the camera the input manager blongs to
  66180. */
  66181. constructor(camera: TCamera);
  66182. /**
  66183. * Add an input method to a camera
  66184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66185. * @param input camera input method
  66186. */
  66187. add(input: ICameraInput<TCamera>): void;
  66188. /**
  66189. * Remove a specific input method from a camera
  66190. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  66191. * @param inputToRemove camera input method
  66192. */
  66193. remove(inputToRemove: ICameraInput<TCamera>): void;
  66194. /**
  66195. * Remove a specific input type from a camera
  66196. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  66197. * @param inputType the type of the input to remove
  66198. */
  66199. removeByType(inputType: string): void;
  66200. private _addCheckInputs;
  66201. /**
  66202. * Attach the input controls to the currently attached dom element to listen the events from.
  66203. * @param input Defines the input to attach
  66204. */
  66205. attachInput(input: ICameraInput<TCamera>): void;
  66206. /**
  66207. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  66208. * @param element Defines the dom element to collect the events from
  66209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66210. */
  66211. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  66212. /**
  66213. * Detach the current manager inputs controls from a specific dom element.
  66214. * @param element Defines the dom element to collect the events from
  66215. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  66216. */
  66217. detachElement(element: HTMLElement, disconnect?: boolean): void;
  66218. /**
  66219. * Rebuild the dynamic inputCheck function from the current list of
  66220. * defined inputs in the manager.
  66221. */
  66222. rebuildInputCheck(): void;
  66223. /**
  66224. * Remove all attached input methods from a camera
  66225. */
  66226. clear(): void;
  66227. /**
  66228. * Serialize the current input manager attached to a camera.
  66229. * This ensures than once parsed,
  66230. * the input associated to the camera will be identical to the current ones
  66231. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  66232. */
  66233. serialize(serializedCamera: any): void;
  66234. /**
  66235. * Parses an input manager serialized JSON to restore the previous list of inputs
  66236. * and states associated to a camera.
  66237. * @param parsedCamera Defines the JSON to parse
  66238. */
  66239. parse(parsedCamera: any): void;
  66240. }
  66241. }
  66242. declare module BABYLON {
  66243. /**
  66244. * Gather the list of keyboard event types as constants.
  66245. */
  66246. export class KeyboardEventTypes {
  66247. /**
  66248. * The keydown event is fired when a key becomes active (pressed).
  66249. */
  66250. static readonly KEYDOWN: number;
  66251. /**
  66252. * The keyup event is fired when a key has been released.
  66253. */
  66254. static readonly KEYUP: number;
  66255. }
  66256. /**
  66257. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66258. */
  66259. export class KeyboardInfo {
  66260. /**
  66261. * Defines the type of event (KeyboardEventTypes)
  66262. */
  66263. type: number;
  66264. /**
  66265. * Defines the related dom event
  66266. */
  66267. event: KeyboardEvent;
  66268. /**
  66269. * Instantiates a new keyboard info.
  66270. * This class is used to store keyboard related info for the onKeyboardObservable event.
  66271. * @param type Defines the type of event (KeyboardEventTypes)
  66272. * @param event Defines the related dom event
  66273. */
  66274. constructor(
  66275. /**
  66276. * Defines the type of event (KeyboardEventTypes)
  66277. */
  66278. type: number,
  66279. /**
  66280. * Defines the related dom event
  66281. */
  66282. event: KeyboardEvent);
  66283. }
  66284. /**
  66285. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66286. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  66287. */
  66288. export class KeyboardInfoPre extends KeyboardInfo {
  66289. /**
  66290. * Defines the type of event (KeyboardEventTypes)
  66291. */
  66292. type: number;
  66293. /**
  66294. * Defines the related dom event
  66295. */
  66296. event: KeyboardEvent;
  66297. /**
  66298. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  66299. */
  66300. skipOnPointerObservable: boolean;
  66301. /**
  66302. * Instantiates a new keyboard pre info.
  66303. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  66304. * @param type Defines the type of event (KeyboardEventTypes)
  66305. * @param event Defines the related dom event
  66306. */
  66307. constructor(
  66308. /**
  66309. * Defines the type of event (KeyboardEventTypes)
  66310. */
  66311. type: number,
  66312. /**
  66313. * Defines the related dom event
  66314. */
  66315. event: KeyboardEvent);
  66316. }
  66317. }
  66318. declare module BABYLON {
  66319. /**
  66320. * Manage the keyboard inputs to control the movement of a free camera.
  66321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  66322. */
  66323. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  66324. /**
  66325. * Defines the camera the input is attached to.
  66326. */
  66327. camera: FreeCamera;
  66328. /**
  66329. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  66330. */
  66331. keysUp: number[];
  66332. /**
  66333. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  66334. */
  66335. keysDown: number[];
  66336. /**
  66337. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  66338. */
  66339. keysLeft: number[];
  66340. /**
  66341. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  66342. */
  66343. keysRight: number[];
  66344. private _keys;
  66345. private _onCanvasBlurObserver;
  66346. private _onKeyboardObserver;
  66347. private _engine;
  66348. private _scene;
  66349. /**
  66350. * Attach the input controls to a specific dom element to get the input from.
  66351. * @param element Defines the element the controls should be listened from
  66352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66353. */
  66354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66355. /**
  66356. * Detach the current controls from the specified dom element.
  66357. * @param element Defines the element to stop listening the inputs from
  66358. */
  66359. detachControl(element: Nullable<HTMLElement>): void;
  66360. /**
  66361. * Update the current camera state depending on the inputs that have been used this frame.
  66362. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  66363. */
  66364. checkInputs(): void;
  66365. /**
  66366. * Gets the class name of the current intput.
  66367. * @returns the class name
  66368. */
  66369. getClassName(): string;
  66370. /** @hidden */
  66371. _onLostFocus(): void;
  66372. /**
  66373. * Get the friendly name associated with the input class.
  66374. * @returns the input friendly name
  66375. */
  66376. getSimpleName(): string;
  66377. }
  66378. }
  66379. declare module BABYLON {
  66380. /**
  66381. * Interface describing all the common properties and methods a shadow light needs to implement.
  66382. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  66383. * as well as binding the different shadow properties to the effects.
  66384. */
  66385. export interface IShadowLight extends Light {
  66386. /**
  66387. * The light id in the scene (used in scene.findLighById for instance)
  66388. */
  66389. id: string;
  66390. /**
  66391. * The position the shdow will be casted from.
  66392. */
  66393. position: Vector3;
  66394. /**
  66395. * In 2d mode (needCube being false), the direction used to cast the shadow.
  66396. */
  66397. direction: Vector3;
  66398. /**
  66399. * The transformed position. Position of the light in world space taking parenting in account.
  66400. */
  66401. transformedPosition: Vector3;
  66402. /**
  66403. * The transformed direction. Direction of the light in world space taking parenting in account.
  66404. */
  66405. transformedDirection: Vector3;
  66406. /**
  66407. * The friendly name of the light in the scene.
  66408. */
  66409. name: string;
  66410. /**
  66411. * Defines the shadow projection clipping minimum z value.
  66412. */
  66413. shadowMinZ: number;
  66414. /**
  66415. * Defines the shadow projection clipping maximum z value.
  66416. */
  66417. shadowMaxZ: number;
  66418. /**
  66419. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66420. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66421. */
  66422. computeTransformedInformation(): boolean;
  66423. /**
  66424. * Gets the scene the light belongs to.
  66425. * @returns The scene
  66426. */
  66427. getScene(): Scene;
  66428. /**
  66429. * Callback defining a custom Projection Matrix Builder.
  66430. * This can be used to override the default projection matrix computation.
  66431. */
  66432. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66433. /**
  66434. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66435. * @param matrix The materix to updated with the projection information
  66436. * @param viewMatrix The transform matrix of the light
  66437. * @param renderList The list of mesh to render in the map
  66438. * @returns The current light
  66439. */
  66440. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66441. /**
  66442. * Gets the current depth scale used in ESM.
  66443. * @returns The scale
  66444. */
  66445. getDepthScale(): number;
  66446. /**
  66447. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66448. * @returns true if a cube texture needs to be use
  66449. */
  66450. needCube(): boolean;
  66451. /**
  66452. * Detects if the projection matrix requires to be recomputed this frame.
  66453. * @returns true if it requires to be recomputed otherwise, false.
  66454. */
  66455. needProjectionMatrixCompute(): boolean;
  66456. /**
  66457. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66458. */
  66459. forceProjectionMatrixCompute(): void;
  66460. /**
  66461. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66462. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66463. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66464. */
  66465. getShadowDirection(faceIndex?: number): Vector3;
  66466. /**
  66467. * Gets the minZ used for shadow according to both the scene and the light.
  66468. * @param activeCamera The camera we are returning the min for
  66469. * @returns the depth min z
  66470. */
  66471. getDepthMinZ(activeCamera: Camera): number;
  66472. /**
  66473. * Gets the maxZ used for shadow according to both the scene and the light.
  66474. * @param activeCamera The camera we are returning the max for
  66475. * @returns the depth max z
  66476. */
  66477. getDepthMaxZ(activeCamera: Camera): number;
  66478. }
  66479. /**
  66480. * Base implementation IShadowLight
  66481. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  66482. */
  66483. export abstract class ShadowLight extends Light implements IShadowLight {
  66484. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  66485. protected _position: Vector3;
  66486. protected _setPosition(value: Vector3): void;
  66487. /**
  66488. * Sets the position the shadow will be casted from. Also use as the light position for both
  66489. * point and spot lights.
  66490. */
  66491. /**
  66492. * Sets the position the shadow will be casted from. Also use as the light position for both
  66493. * point and spot lights.
  66494. */
  66495. position: Vector3;
  66496. protected _direction: Vector3;
  66497. protected _setDirection(value: Vector3): void;
  66498. /**
  66499. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  66500. * Also use as the light direction on spot and directional lights.
  66501. */
  66502. /**
  66503. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  66504. * Also use as the light direction on spot and directional lights.
  66505. */
  66506. direction: Vector3;
  66507. private _shadowMinZ;
  66508. /**
  66509. * Gets the shadow projection clipping minimum z value.
  66510. */
  66511. /**
  66512. * Sets the shadow projection clipping minimum z value.
  66513. */
  66514. shadowMinZ: number;
  66515. private _shadowMaxZ;
  66516. /**
  66517. * Sets the shadow projection clipping maximum z value.
  66518. */
  66519. /**
  66520. * Gets the shadow projection clipping maximum z value.
  66521. */
  66522. shadowMaxZ: number;
  66523. /**
  66524. * Callback defining a custom Projection Matrix Builder.
  66525. * This can be used to override the default projection matrix computation.
  66526. */
  66527. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  66528. /**
  66529. * The transformed position. Position of the light in world space taking parenting in account.
  66530. */
  66531. transformedPosition: Vector3;
  66532. /**
  66533. * The transformed direction. Direction of the light in world space taking parenting in account.
  66534. */
  66535. transformedDirection: Vector3;
  66536. private _needProjectionMatrixCompute;
  66537. /**
  66538. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  66539. * @returns true if the information has been computed, false if it does not need to (no parenting)
  66540. */
  66541. computeTransformedInformation(): boolean;
  66542. /**
  66543. * Return the depth scale used for the shadow map.
  66544. * @returns the depth scale.
  66545. */
  66546. getDepthScale(): number;
  66547. /**
  66548. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  66549. * @param faceIndex The index of the face we are computed the direction to generate shadow
  66550. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  66551. */
  66552. getShadowDirection(faceIndex?: number): Vector3;
  66553. /**
  66554. * Returns the ShadowLight absolute position in the World.
  66555. * @returns the position vector in world space
  66556. */
  66557. getAbsolutePosition(): Vector3;
  66558. /**
  66559. * Sets the ShadowLight direction toward the passed target.
  66560. * @param target The point to target in local space
  66561. * @returns the updated ShadowLight direction
  66562. */
  66563. setDirectionToTarget(target: Vector3): Vector3;
  66564. /**
  66565. * Returns the light rotation in euler definition.
  66566. * @returns the x y z rotation in local space.
  66567. */
  66568. getRotation(): Vector3;
  66569. /**
  66570. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  66571. * @returns true if a cube texture needs to be use
  66572. */
  66573. needCube(): boolean;
  66574. /**
  66575. * Detects if the projection matrix requires to be recomputed this frame.
  66576. * @returns true if it requires to be recomputed otherwise, false.
  66577. */
  66578. needProjectionMatrixCompute(): boolean;
  66579. /**
  66580. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  66581. */
  66582. forceProjectionMatrixCompute(): void;
  66583. /** @hidden */
  66584. _initCache(): void;
  66585. /** @hidden */
  66586. _isSynchronized(): boolean;
  66587. /**
  66588. * Computes the world matrix of the node
  66589. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66590. * @returns the world matrix
  66591. */
  66592. computeWorldMatrix(force?: boolean): Matrix;
  66593. /**
  66594. * Gets the minZ used for shadow according to both the scene and the light.
  66595. * @param activeCamera The camera we are returning the min for
  66596. * @returns the depth min z
  66597. */
  66598. getDepthMinZ(activeCamera: Camera): number;
  66599. /**
  66600. * Gets the maxZ used for shadow according to both the scene and the light.
  66601. * @param activeCamera The camera we are returning the max for
  66602. * @returns the depth max z
  66603. */
  66604. getDepthMaxZ(activeCamera: Camera): number;
  66605. /**
  66606. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66607. * @param matrix The materix to updated with the projection information
  66608. * @param viewMatrix The transform matrix of the light
  66609. * @param renderList The list of mesh to render in the map
  66610. * @returns The current light
  66611. */
  66612. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66613. }
  66614. }
  66615. declare module BABYLON {
  66616. /**
  66617. * "Static Class" containing the most commonly used helper while dealing with material for
  66618. * rendering purpose.
  66619. *
  66620. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66621. *
  66622. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66623. */
  66624. export class MaterialHelper {
  66625. /**
  66626. * Bind the current view position to an effect.
  66627. * @param effect The effect to be bound
  66628. * @param scene The scene the eyes position is used from
  66629. */
  66630. static BindEyePosition(effect: Effect, scene: Scene): void;
  66631. /**
  66632. * Helps preparing the defines values about the UVs in used in the effect.
  66633. * UVs are shared as much as we can accross channels in the shaders.
  66634. * @param texture The texture we are preparing the UVs for
  66635. * @param defines The defines to update
  66636. * @param key The channel key "diffuse", "specular"... used in the shader
  66637. */
  66638. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66639. /**
  66640. * Binds a texture matrix value to its corrsponding uniform
  66641. * @param texture The texture to bind the matrix for
  66642. * @param uniformBuffer The uniform buffer receivin the data
  66643. * @param key The channel key "diffuse", "specular"... used in the shader
  66644. */
  66645. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66646. /**
  66647. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66648. * @param mesh defines the current mesh
  66649. * @param scene defines the current scene
  66650. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66651. * @param pointsCloud defines if point cloud rendering has to be turned on
  66652. * @param fogEnabled defines if fog has to be turned on
  66653. * @param alphaTest defines if alpha testing has to be turned on
  66654. * @param defines defines the current list of defines
  66655. */
  66656. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66657. /**
  66658. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66659. * @param scene defines the current scene
  66660. * @param engine defines the current engine
  66661. * @param defines specifies the list of active defines
  66662. * @param useInstances defines if instances have to be turned on
  66663. * @param useClipPlane defines if clip plane have to be turned on
  66664. */
  66665. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66666. /**
  66667. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66668. * @param mesh The mesh containing the geometry data we will draw
  66669. * @param defines The defines to update
  66670. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66671. * @param useBones Precise whether bones should be used or not (override mesh info)
  66672. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66673. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66674. * @returns false if defines are considered not dirty and have not been checked
  66675. */
  66676. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66677. /**
  66678. * Prepares the defines related to the light information passed in parameter
  66679. * @param scene The scene we are intending to draw
  66680. * @param mesh The mesh the effect is compiling for
  66681. * @param defines The defines to update
  66682. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66683. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66684. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66685. * @returns true if normals will be required for the rest of the effect
  66686. */
  66687. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66688. /**
  66689. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66690. * that won t be acctive due to defines being turned off.
  66691. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66692. * @param samplersList The samplers list
  66693. * @param defines The defines helping in the list generation
  66694. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66695. */
  66696. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66697. /**
  66698. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66699. * @param defines The defines to update while falling back
  66700. * @param fallbacks The authorized effect fallbacks
  66701. * @param maxSimultaneousLights The maximum number of lights allowed
  66702. * @param rank the current rank of the Effect
  66703. * @returns The newly affected rank
  66704. */
  66705. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66706. /**
  66707. * Prepares the list of attributes required for morph targets according to the effect defines.
  66708. * @param attribs The current list of supported attribs
  66709. * @param mesh The mesh to prepare the morph targets attributes for
  66710. * @param defines The current Defines of the effect
  66711. */
  66712. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66713. /**
  66714. * Prepares the list of attributes required for bones according to the effect defines.
  66715. * @param attribs The current list of supported attribs
  66716. * @param mesh The mesh to prepare the bones attributes for
  66717. * @param defines The current Defines of the effect
  66718. * @param fallbacks The current efffect fallback strategy
  66719. */
  66720. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66721. /**
  66722. * Prepares the list of attributes required for instances according to the effect defines.
  66723. * @param attribs The current list of supported attribs
  66724. * @param defines The current Defines of the effect
  66725. */
  66726. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66727. /**
  66728. * Binds the light shadow information to the effect for the given mesh.
  66729. * @param light The light containing the generator
  66730. * @param scene The scene the lights belongs to
  66731. * @param mesh The mesh we are binding the information to render
  66732. * @param lightIndex The light index in the effect used to render the mesh
  66733. * @param effect The effect we are binding the data to
  66734. */
  66735. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66736. /**
  66737. * Binds the light information to the effect.
  66738. * @param light The light containing the generator
  66739. * @param effect The effect we are binding the data to
  66740. * @param lightIndex The light index in the effect used to render
  66741. */
  66742. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66743. /**
  66744. * Binds the lights information from the scene to the effect for the given mesh.
  66745. * @param scene The scene the lights belongs to
  66746. * @param mesh The mesh we are binding the information to render
  66747. * @param effect The effect we are binding the data to
  66748. * @param defines The generated defines for the effect
  66749. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66750. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66751. */
  66752. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66753. private static _tempFogColor;
  66754. /**
  66755. * Binds the fog information from the scene to the effect for the given mesh.
  66756. * @param scene The scene the lights belongs to
  66757. * @param mesh The mesh we are binding the information to render
  66758. * @param effect The effect we are binding the data to
  66759. * @param linearSpace Defines if the fog effect is applied in linear space
  66760. */
  66761. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66762. /**
  66763. * Binds the bones information from the mesh to the effect.
  66764. * @param mesh The mesh we are binding the information to render
  66765. * @param effect The effect we are binding the data to
  66766. */
  66767. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66768. /**
  66769. * Binds the morph targets information from the mesh to the effect.
  66770. * @param abstractMesh The mesh we are binding the information to render
  66771. * @param effect The effect we are binding the data to
  66772. */
  66773. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66774. /**
  66775. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66776. * @param defines The generated defines used in the effect
  66777. * @param effect The effect we are binding the data to
  66778. * @param scene The scene we are willing to render with logarithmic scale for
  66779. */
  66780. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66781. /**
  66782. * Binds the clip plane information from the scene to the effect.
  66783. * @param scene The scene the clip plane information are extracted from
  66784. * @param effect The effect we are binding the data to
  66785. */
  66786. static BindClipPlane(effect: Effect, scene: Scene): void;
  66787. }
  66788. }
  66789. declare module BABYLON {
  66790. /** @hidden */
  66791. export var kernelBlurVaryingDeclaration: {
  66792. name: string;
  66793. shader: string;
  66794. };
  66795. }
  66796. declare module BABYLON {
  66797. /** @hidden */
  66798. export var kernelBlurFragment: {
  66799. name: string;
  66800. shader: string;
  66801. };
  66802. }
  66803. declare module BABYLON {
  66804. /** @hidden */
  66805. export var kernelBlurFragment2: {
  66806. name: string;
  66807. shader: string;
  66808. };
  66809. }
  66810. declare module BABYLON {
  66811. /** @hidden */
  66812. export var kernelBlurPixelShader: {
  66813. name: string;
  66814. shader: string;
  66815. };
  66816. }
  66817. declare module BABYLON {
  66818. /** @hidden */
  66819. export var kernelBlurVertex: {
  66820. name: string;
  66821. shader: string;
  66822. };
  66823. }
  66824. declare module BABYLON {
  66825. /** @hidden */
  66826. export var kernelBlurVertexShader: {
  66827. name: string;
  66828. shader: string;
  66829. };
  66830. }
  66831. declare module BABYLON {
  66832. /**
  66833. * The Blur Post Process which blurs an image based on a kernel and direction.
  66834. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  66835. */
  66836. export class BlurPostProcess extends PostProcess {
  66837. /** The direction in which to blur the image. */
  66838. direction: Vector2;
  66839. private blockCompilation;
  66840. protected _kernel: number;
  66841. protected _idealKernel: number;
  66842. protected _packedFloat: boolean;
  66843. private _staticDefines;
  66844. /**
  66845. * Sets the length in pixels of the blur sample region
  66846. */
  66847. /**
  66848. * Gets the length in pixels of the blur sample region
  66849. */
  66850. kernel: number;
  66851. /**
  66852. * Sets wether or not the blur needs to unpack/repack floats
  66853. */
  66854. /**
  66855. * Gets wether or not the blur is unpacking/repacking floats
  66856. */
  66857. packedFloat: boolean;
  66858. /**
  66859. * Creates a new instance BlurPostProcess
  66860. * @param name The name of the effect.
  66861. * @param direction The direction in which to blur the image.
  66862. * @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.
  66863. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  66864. * @param camera The camera to apply the render pass to.
  66865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66866. * @param engine The engine which the post process will be applied. (default: current engine)
  66867. * @param reusable If the post process can be reused on the same frame. (default: false)
  66868. * @param textureType Type of textures used when performing the post process. (default: 0)
  66869. * @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)
  66870. */
  66871. constructor(name: string,
  66872. /** The direction in which to blur the image. */
  66873. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  66874. /**
  66875. * Updates the effect with the current post process compile time values and recompiles the shader.
  66876. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66877. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66878. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66879. * @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
  66880. * @param onCompiled Called when the shader has been compiled.
  66881. * @param onError Called if there is an error when compiling a shader.
  66882. */
  66883. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66884. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66885. /**
  66886. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  66887. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  66888. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  66889. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  66890. * The gaps between physical kernels are compensated for in the weighting of the samples
  66891. * @param idealKernel Ideal blur kernel.
  66892. * @return Nearest best kernel.
  66893. */
  66894. protected _nearestBestKernel(idealKernel: number): number;
  66895. /**
  66896. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  66897. * @param x The point on the Gaussian distribution to sample.
  66898. * @return the value of the Gaussian function at x.
  66899. */
  66900. protected _gaussianWeight(x: number): number;
  66901. /**
  66902. * Generates a string that can be used as a floating point number in GLSL.
  66903. * @param x Value to print.
  66904. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  66905. * @return GLSL float string.
  66906. */
  66907. protected _glslFloat(x: number, decimalFigures?: number): string;
  66908. }
  66909. }
  66910. declare module BABYLON {
  66911. /** @hidden */
  66912. export var shadowMapPixelShader: {
  66913. name: string;
  66914. shader: string;
  66915. };
  66916. }
  66917. declare module BABYLON {
  66918. /** @hidden */
  66919. export var bonesDeclaration: {
  66920. name: string;
  66921. shader: string;
  66922. };
  66923. }
  66924. declare module BABYLON {
  66925. /** @hidden */
  66926. export var morphTargetsVertexGlobalDeclaration: {
  66927. name: string;
  66928. shader: string;
  66929. };
  66930. }
  66931. declare module BABYLON {
  66932. /** @hidden */
  66933. export var morphTargetsVertexDeclaration: {
  66934. name: string;
  66935. shader: string;
  66936. };
  66937. }
  66938. declare module BABYLON {
  66939. /** @hidden */
  66940. export var instancesDeclaration: {
  66941. name: string;
  66942. shader: string;
  66943. };
  66944. }
  66945. declare module BABYLON {
  66946. /** @hidden */
  66947. export var helperFunctions: {
  66948. name: string;
  66949. shader: string;
  66950. };
  66951. }
  66952. declare module BABYLON {
  66953. /** @hidden */
  66954. export var morphTargetsVertex: {
  66955. name: string;
  66956. shader: string;
  66957. };
  66958. }
  66959. declare module BABYLON {
  66960. /** @hidden */
  66961. export var instancesVertex: {
  66962. name: string;
  66963. shader: string;
  66964. };
  66965. }
  66966. declare module BABYLON {
  66967. /** @hidden */
  66968. export var bonesVertex: {
  66969. name: string;
  66970. shader: string;
  66971. };
  66972. }
  66973. declare module BABYLON {
  66974. /** @hidden */
  66975. export var shadowMapVertexShader: {
  66976. name: string;
  66977. shader: string;
  66978. };
  66979. }
  66980. declare module BABYLON {
  66981. /** @hidden */
  66982. export var depthBoxBlurPixelShader: {
  66983. name: string;
  66984. shader: string;
  66985. };
  66986. }
  66987. declare module BABYLON {
  66988. /**
  66989. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66990. */
  66991. export interface ICustomShaderOptions {
  66992. /**
  66993. * Gets or sets the custom shader name to use
  66994. */
  66995. shaderName: string;
  66996. /**
  66997. * The list of attribute names used in the shader
  66998. */
  66999. attributes?: string[];
  67000. /**
  67001. * The list of unifrom names used in the shader
  67002. */
  67003. uniforms?: string[];
  67004. /**
  67005. * The list of sampler names used in the shader
  67006. */
  67007. samplers?: string[];
  67008. /**
  67009. * The list of defines used in the shader
  67010. */
  67011. defines?: string[];
  67012. }
  67013. /**
  67014. * Interface to implement to create a shadow generator compatible with BJS.
  67015. */
  67016. export interface IShadowGenerator {
  67017. /**
  67018. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67019. * @returns The render target texture if present otherwise, null
  67020. */
  67021. getShadowMap(): Nullable<RenderTargetTexture>;
  67022. /**
  67023. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67024. * @returns The render target texture if the shadow map is present otherwise, null
  67025. */
  67026. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67027. /**
  67028. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67029. * @param subMesh The submesh we want to render in the shadow map
  67030. * @param useInstances Defines wether will draw in the map using instances
  67031. * @returns true if ready otherwise, false
  67032. */
  67033. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67034. /**
  67035. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67036. * @param defines Defines of the material we want to update
  67037. * @param lightIndex Index of the light in the enabled light list of the material
  67038. */
  67039. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67040. /**
  67041. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67042. * defined in the generator but impacting the effect).
  67043. * It implies the unifroms available on the materials are the standard BJS ones.
  67044. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67045. * @param effect The effect we are binfing the information for
  67046. */
  67047. bindShadowLight(lightIndex: string, effect: Effect): void;
  67048. /**
  67049. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67050. * (eq to shadow prjection matrix * light transform matrix)
  67051. * @returns The transform matrix used to create the shadow map
  67052. */
  67053. getTransformMatrix(): Matrix;
  67054. /**
  67055. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67056. * Cube and 2D textures for instance.
  67057. */
  67058. recreateShadowMap(): void;
  67059. /**
  67060. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67061. * @param onCompiled Callback triggered at the and of the effects compilation
  67062. * @param options Sets of optional options forcing the compilation with different modes
  67063. */
  67064. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67065. useInstances: boolean;
  67066. }>): void;
  67067. /**
  67068. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67069. * @param options Sets of optional options forcing the compilation with different modes
  67070. * @returns A promise that resolves when the compilation completes
  67071. */
  67072. forceCompilationAsync(options?: Partial<{
  67073. useInstances: boolean;
  67074. }>): Promise<void>;
  67075. /**
  67076. * Serializes the shadow generator setup to a json object.
  67077. * @returns The serialized JSON object
  67078. */
  67079. serialize(): any;
  67080. /**
  67081. * Disposes the Shadow map and related Textures and effects.
  67082. */
  67083. dispose(): void;
  67084. }
  67085. /**
  67086. * Default implementation IShadowGenerator.
  67087. * This is the main object responsible of generating shadows in the framework.
  67088. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67089. */
  67090. export class ShadowGenerator implements IShadowGenerator {
  67091. /**
  67092. * Shadow generator mode None: no filtering applied.
  67093. */
  67094. static readonly FILTER_NONE: number;
  67095. /**
  67096. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67097. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67098. */
  67099. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67100. /**
  67101. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67102. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67103. */
  67104. static readonly FILTER_POISSONSAMPLING: number;
  67105. /**
  67106. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67107. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67108. */
  67109. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67110. /**
  67111. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67112. * edge artifacts on steep falloff.
  67113. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67114. */
  67115. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67116. /**
  67117. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67118. * edge artifacts on steep falloff.
  67119. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67120. */
  67121. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67122. /**
  67123. * Shadow generator mode PCF: Percentage Closer Filtering
  67124. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67125. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67126. */
  67127. static readonly FILTER_PCF: number;
  67128. /**
  67129. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67130. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67131. * Contact Hardening
  67132. */
  67133. static readonly FILTER_PCSS: number;
  67134. /**
  67135. * Reserved for PCF and PCSS
  67136. * Highest Quality.
  67137. *
  67138. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  67139. *
  67140. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  67141. */
  67142. static readonly QUALITY_HIGH: number;
  67143. /**
  67144. * Reserved for PCF and PCSS
  67145. * Good tradeoff for quality/perf cross devices
  67146. *
  67147. * Execute PCF on a 3*3 kernel.
  67148. *
  67149. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  67150. */
  67151. static readonly QUALITY_MEDIUM: number;
  67152. /**
  67153. * Reserved for PCF and PCSS
  67154. * The lowest quality but the fastest.
  67155. *
  67156. * Execute PCF on a 1*1 kernel.
  67157. *
  67158. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  67159. */
  67160. static readonly QUALITY_LOW: number;
  67161. /** Gets or sets the custom shader name to use */
  67162. customShaderOptions: ICustomShaderOptions;
  67163. /**
  67164. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  67165. */
  67166. onBeforeShadowMapRenderObservable: Observable<Effect>;
  67167. /**
  67168. * Observable triggered before a mesh is rendered in the shadow map.
  67169. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  67170. */
  67171. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  67172. private _bias;
  67173. /**
  67174. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  67175. */
  67176. /**
  67177. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  67178. */
  67179. bias: number;
  67180. private _normalBias;
  67181. /**
  67182. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67183. */
  67184. /**
  67185. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  67186. */
  67187. normalBias: number;
  67188. private _blurBoxOffset;
  67189. /**
  67190. * Gets the blur box offset: offset applied during the blur pass.
  67191. * Only useful if useKernelBlur = false
  67192. */
  67193. /**
  67194. * Sets the blur box offset: offset applied during the blur pass.
  67195. * Only useful if useKernelBlur = false
  67196. */
  67197. blurBoxOffset: number;
  67198. private _blurScale;
  67199. /**
  67200. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  67201. * 2 means half of the size.
  67202. */
  67203. /**
  67204. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  67205. * 2 means half of the size.
  67206. */
  67207. blurScale: number;
  67208. private _blurKernel;
  67209. /**
  67210. * Gets the blur kernel: kernel size of the blur pass.
  67211. * Only useful if useKernelBlur = true
  67212. */
  67213. /**
  67214. * Sets the blur kernel: kernel size of the blur pass.
  67215. * Only useful if useKernelBlur = true
  67216. */
  67217. blurKernel: number;
  67218. private _useKernelBlur;
  67219. /**
  67220. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  67221. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67222. */
  67223. /**
  67224. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  67225. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  67226. */
  67227. useKernelBlur: boolean;
  67228. private _depthScale;
  67229. /**
  67230. * Gets the depth scale used in ESM mode.
  67231. */
  67232. /**
  67233. * Sets the depth scale used in ESM mode.
  67234. * This can override the scale stored on the light.
  67235. */
  67236. depthScale: number;
  67237. private _filter;
  67238. /**
  67239. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  67240. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67241. */
  67242. /**
  67243. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  67244. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  67245. */
  67246. filter: number;
  67247. /**
  67248. * Gets if the current filter is set to Poisson Sampling.
  67249. */
  67250. /**
  67251. * Sets the current filter to Poisson Sampling.
  67252. */
  67253. usePoissonSampling: boolean;
  67254. /**
  67255. * Gets if the current filter is set to ESM.
  67256. */
  67257. /**
  67258. * Sets the current filter is to ESM.
  67259. */
  67260. useExponentialShadowMap: boolean;
  67261. /**
  67262. * Gets if the current filter is set to filtered ESM.
  67263. */
  67264. /**
  67265. * Gets if the current filter is set to filtered ESM.
  67266. */
  67267. useBlurExponentialShadowMap: boolean;
  67268. /**
  67269. * Gets if the current filter is set to "close ESM" (using the inverse of the
  67270. * exponential to prevent steep falloff artifacts).
  67271. */
  67272. /**
  67273. * Sets the current filter to "close ESM" (using the inverse of the
  67274. * exponential to prevent steep falloff artifacts).
  67275. */
  67276. useCloseExponentialShadowMap: boolean;
  67277. /**
  67278. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  67279. * exponential to prevent steep falloff artifacts).
  67280. */
  67281. /**
  67282. * Sets the current filter to filtered "close ESM" (using the inverse of the
  67283. * exponential to prevent steep falloff artifacts).
  67284. */
  67285. useBlurCloseExponentialShadowMap: boolean;
  67286. /**
  67287. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  67288. */
  67289. /**
  67290. * Sets the current filter to "PCF" (percentage closer filtering).
  67291. */
  67292. usePercentageCloserFiltering: boolean;
  67293. private _filteringQuality;
  67294. /**
  67295. * Gets the PCF or PCSS Quality.
  67296. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67297. */
  67298. /**
  67299. * Sets the PCF or PCSS Quality.
  67300. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  67301. */
  67302. filteringQuality: number;
  67303. /**
  67304. * Gets if the current filter is set to "PCSS" (contact hardening).
  67305. */
  67306. /**
  67307. * Sets the current filter to "PCSS" (contact hardening).
  67308. */
  67309. useContactHardeningShadow: boolean;
  67310. private _contactHardeningLightSizeUVRatio;
  67311. /**
  67312. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67313. * Using a ratio helps keeping shape stability independently of the map size.
  67314. *
  67315. * It does not account for the light projection as it was having too much
  67316. * instability during the light setup or during light position changes.
  67317. *
  67318. * Only valid if useContactHardeningShadow is true.
  67319. */
  67320. /**
  67321. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  67322. * Using a ratio helps keeping shape stability independently of the map size.
  67323. *
  67324. * It does not account for the light projection as it was having too much
  67325. * instability during the light setup or during light position changes.
  67326. *
  67327. * Only valid if useContactHardeningShadow is true.
  67328. */
  67329. contactHardeningLightSizeUVRatio: number;
  67330. private _darkness;
  67331. /**
  67332. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  67333. * 0 means strongest and 1 would means no shadow.
  67334. * @returns the darkness.
  67335. */
  67336. getDarkness(): number;
  67337. /**
  67338. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  67339. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  67340. * @returns the shadow generator allowing fluent coding.
  67341. */
  67342. setDarkness(darkness: number): ShadowGenerator;
  67343. private _transparencyShadow;
  67344. /**
  67345. * Sets the ability to have transparent shadow (boolean).
  67346. * @param transparent True if transparent else False
  67347. * @returns the shadow generator allowing fluent coding
  67348. */
  67349. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  67350. private _shadowMap;
  67351. private _shadowMap2;
  67352. /**
  67353. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67354. * @returns The render target texture if present otherwise, null
  67355. */
  67356. getShadowMap(): Nullable<RenderTargetTexture>;
  67357. /**
  67358. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67359. * @returns The render target texture if the shadow map is present otherwise, null
  67360. */
  67361. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67362. /**
  67363. * Helper function to add a mesh and its descendants to the list of shadow casters.
  67364. * @param mesh Mesh to add
  67365. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  67366. * @returns the Shadow Generator itself
  67367. */
  67368. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67369. /**
  67370. * Helper function to remove a mesh and its descendants from the list of shadow casters
  67371. * @param mesh Mesh to remove
  67372. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  67373. * @returns the Shadow Generator itself
  67374. */
  67375. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  67376. /**
  67377. * Controls the extent to which the shadows fade out at the edge of the frustum
  67378. * Used only by directionals and spots
  67379. */
  67380. frustumEdgeFalloff: number;
  67381. private _light;
  67382. /**
  67383. * Returns the associated light object.
  67384. * @returns the light generating the shadow
  67385. */
  67386. getLight(): IShadowLight;
  67387. /**
  67388. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  67389. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  67390. * It might on the other hand introduce peter panning.
  67391. */
  67392. forceBackFacesOnly: boolean;
  67393. private _scene;
  67394. private _lightDirection;
  67395. private _effect;
  67396. private _viewMatrix;
  67397. private _projectionMatrix;
  67398. private _transformMatrix;
  67399. private _cachedPosition;
  67400. private _cachedDirection;
  67401. private _cachedDefines;
  67402. private _currentRenderID;
  67403. private _boxBlurPostprocess;
  67404. private _kernelBlurXPostprocess;
  67405. private _kernelBlurYPostprocess;
  67406. private _blurPostProcesses;
  67407. private _mapSize;
  67408. private _currentFaceIndex;
  67409. private _currentFaceIndexCache;
  67410. private _textureType;
  67411. private _defaultTextureMatrix;
  67412. /** @hidden */
  67413. static _SceneComponentInitialization: (scene: Scene) => void;
  67414. /**
  67415. * Creates a ShadowGenerator object.
  67416. * A ShadowGenerator is the required tool to use the shadows.
  67417. * Each light casting shadows needs to use its own ShadowGenerator.
  67418. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  67419. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  67420. * @param light The light object generating the shadows.
  67421. * @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.
  67422. */
  67423. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  67424. private _initializeGenerator;
  67425. private _initializeShadowMap;
  67426. private _initializeBlurRTTAndPostProcesses;
  67427. private _renderForShadowMap;
  67428. private _renderSubMeshForShadowMap;
  67429. private _applyFilterValues;
  67430. /**
  67431. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67432. * @param onCompiled Callback triggered at the and of the effects compilation
  67433. * @param options Sets of optional options forcing the compilation with different modes
  67434. */
  67435. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67436. useInstances: boolean;
  67437. }>): void;
  67438. /**
  67439. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67440. * @param options Sets of optional options forcing the compilation with different modes
  67441. * @returns A promise that resolves when the compilation completes
  67442. */
  67443. forceCompilationAsync(options?: Partial<{
  67444. useInstances: boolean;
  67445. }>): Promise<void>;
  67446. /**
  67447. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67448. * @param subMesh The submesh we want to render in the shadow map
  67449. * @param useInstances Defines wether will draw in the map using instances
  67450. * @returns true if ready otherwise, false
  67451. */
  67452. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67453. /**
  67454. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67455. * @param defines Defines of the material we want to update
  67456. * @param lightIndex Index of the light in the enabled light list of the material
  67457. */
  67458. prepareDefines(defines: any, lightIndex: number): void;
  67459. /**
  67460. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67461. * defined in the generator but impacting the effect).
  67462. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67463. * @param effect The effect we are binfing the information for
  67464. */
  67465. bindShadowLight(lightIndex: string, effect: Effect): void;
  67466. /**
  67467. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67468. * (eq to shadow prjection matrix * light transform matrix)
  67469. * @returns The transform matrix used to create the shadow map
  67470. */
  67471. getTransformMatrix(): Matrix;
  67472. /**
  67473. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67474. * Cube and 2D textures for instance.
  67475. */
  67476. recreateShadowMap(): void;
  67477. private _disposeBlurPostProcesses;
  67478. private _disposeRTTandPostProcesses;
  67479. /**
  67480. * Disposes the ShadowGenerator.
  67481. * Returns nothing.
  67482. */
  67483. dispose(): void;
  67484. /**
  67485. * Serializes the shadow generator setup to a json object.
  67486. * @returns The serialized JSON object
  67487. */
  67488. serialize(): any;
  67489. /**
  67490. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  67491. * @param parsedShadowGenerator The JSON object to parse
  67492. * @param scene The scene to create the shadow map for
  67493. * @returns The parsed shadow generator
  67494. */
  67495. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  67496. }
  67497. }
  67498. declare module BABYLON {
  67499. /**
  67500. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  67501. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  67502. * 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.
  67503. */
  67504. export abstract class Light extends Node {
  67505. /**
  67506. * Falloff Default: light is falling off following the material specification:
  67507. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  67508. */
  67509. static readonly FALLOFF_DEFAULT: number;
  67510. /**
  67511. * Falloff Physical: light is falling off following the inverse squared distance law.
  67512. */
  67513. static readonly FALLOFF_PHYSICAL: number;
  67514. /**
  67515. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  67516. * to enhance interoperability with other engines.
  67517. */
  67518. static readonly FALLOFF_GLTF: number;
  67519. /**
  67520. * Falloff Standard: light is falling off like in the standard material
  67521. * to enhance interoperability with other materials.
  67522. */
  67523. static readonly FALLOFF_STANDARD: number;
  67524. /**
  67525. * If every light affecting the material is in this lightmapMode,
  67526. * material.lightmapTexture adds or multiplies
  67527. * (depends on material.useLightmapAsShadowmap)
  67528. * after every other light calculations.
  67529. */
  67530. static readonly LIGHTMAP_DEFAULT: number;
  67531. /**
  67532. * material.lightmapTexture as only diffuse lighting from this light
  67533. * adds only specular lighting from this light
  67534. * adds dynamic shadows
  67535. */
  67536. static readonly LIGHTMAP_SPECULAR: number;
  67537. /**
  67538. * material.lightmapTexture as only lighting
  67539. * no light calculation from this light
  67540. * only adds dynamic shadows from this light
  67541. */
  67542. static readonly LIGHTMAP_SHADOWSONLY: number;
  67543. /**
  67544. * Each light type uses the default quantity according to its type:
  67545. * point/spot lights use luminous intensity
  67546. * directional lights use illuminance
  67547. */
  67548. static readonly INTENSITYMODE_AUTOMATIC: number;
  67549. /**
  67550. * lumen (lm)
  67551. */
  67552. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  67553. /**
  67554. * candela (lm/sr)
  67555. */
  67556. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  67557. /**
  67558. * lux (lm/m^2)
  67559. */
  67560. static readonly INTENSITYMODE_ILLUMINANCE: number;
  67561. /**
  67562. * nit (cd/m^2)
  67563. */
  67564. static readonly INTENSITYMODE_LUMINANCE: number;
  67565. /**
  67566. * Light type const id of the point light.
  67567. */
  67568. static readonly LIGHTTYPEID_POINTLIGHT: number;
  67569. /**
  67570. * Light type const id of the directional light.
  67571. */
  67572. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  67573. /**
  67574. * Light type const id of the spot light.
  67575. */
  67576. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  67577. /**
  67578. * Light type const id of the hemispheric light.
  67579. */
  67580. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  67581. /**
  67582. * Diffuse gives the basic color to an object.
  67583. */
  67584. diffuse: Color3;
  67585. /**
  67586. * Specular produces a highlight color on an object.
  67587. * Note: This is note affecting PBR materials.
  67588. */
  67589. specular: Color3;
  67590. /**
  67591. * Defines the falloff type for this light. This lets overrriding how punctual light are
  67592. * falling off base on range or angle.
  67593. * This can be set to any values in Light.FALLOFF_x.
  67594. *
  67595. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  67596. * other types of materials.
  67597. */
  67598. falloffType: number;
  67599. /**
  67600. * Strength of the light.
  67601. * Note: By default it is define in the framework own unit.
  67602. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  67603. */
  67604. intensity: number;
  67605. private _range;
  67606. protected _inverseSquaredRange: number;
  67607. /**
  67608. * Defines how far from the source the light is impacting in scene units.
  67609. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67610. */
  67611. /**
  67612. * Defines how far from the source the light is impacting in scene units.
  67613. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  67614. */
  67615. range: number;
  67616. /**
  67617. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  67618. * of light.
  67619. */
  67620. private _photometricScale;
  67621. private _intensityMode;
  67622. /**
  67623. * Gets the photometric scale used to interpret the intensity.
  67624. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67625. */
  67626. /**
  67627. * Sets the photometric scale used to interpret the intensity.
  67628. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  67629. */
  67630. intensityMode: number;
  67631. private _radius;
  67632. /**
  67633. * Gets the light radius used by PBR Materials to simulate soft area lights.
  67634. */
  67635. /**
  67636. * sets the light radius used by PBR Materials to simulate soft area lights.
  67637. */
  67638. radius: number;
  67639. private _renderPriority;
  67640. /**
  67641. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  67642. * exceeding the number allowed of the materials.
  67643. */
  67644. renderPriority: number;
  67645. private _shadowEnabled;
  67646. /**
  67647. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67648. * the current shadow generator.
  67649. */
  67650. /**
  67651. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  67652. * the current shadow generator.
  67653. */
  67654. shadowEnabled: boolean;
  67655. private _includedOnlyMeshes;
  67656. /**
  67657. * Gets the only meshes impacted by this light.
  67658. */
  67659. /**
  67660. * Sets the only meshes impacted by this light.
  67661. */
  67662. includedOnlyMeshes: AbstractMesh[];
  67663. private _excludedMeshes;
  67664. /**
  67665. * Gets the meshes not impacted by this light.
  67666. */
  67667. /**
  67668. * Sets the meshes not impacted by this light.
  67669. */
  67670. excludedMeshes: AbstractMesh[];
  67671. private _excludeWithLayerMask;
  67672. /**
  67673. * Gets the layer id use to find what meshes are not impacted by the light.
  67674. * Inactive if 0
  67675. */
  67676. /**
  67677. * Sets the layer id use to find what meshes are not impacted by the light.
  67678. * Inactive if 0
  67679. */
  67680. excludeWithLayerMask: number;
  67681. private _includeOnlyWithLayerMask;
  67682. /**
  67683. * Gets the layer id use to find what meshes are impacted by the light.
  67684. * Inactive if 0
  67685. */
  67686. /**
  67687. * Sets the layer id use to find what meshes are impacted by the light.
  67688. * Inactive if 0
  67689. */
  67690. includeOnlyWithLayerMask: number;
  67691. private _lightmapMode;
  67692. /**
  67693. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67694. */
  67695. /**
  67696. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  67697. */
  67698. lightmapMode: number;
  67699. /**
  67700. * Shadow generator associted to the light.
  67701. * @hidden Internal use only.
  67702. */
  67703. _shadowGenerator: Nullable<IShadowGenerator>;
  67704. /**
  67705. * @hidden Internal use only.
  67706. */
  67707. _excludedMeshesIds: string[];
  67708. /**
  67709. * @hidden Internal use only.
  67710. */
  67711. _includedOnlyMeshesIds: string[];
  67712. /**
  67713. * The current light unifom buffer.
  67714. * @hidden Internal use only.
  67715. */
  67716. _uniformBuffer: UniformBuffer;
  67717. /**
  67718. * Creates a Light object in the scene.
  67719. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67720. * @param name The firendly name of the light
  67721. * @param scene The scene the light belongs too
  67722. */
  67723. constructor(name: string, scene: Scene);
  67724. protected abstract _buildUniformLayout(): void;
  67725. /**
  67726. * Sets the passed Effect "effect" with the Light information.
  67727. * @param effect The effect to update
  67728. * @param lightIndex The index of the light in the effect to update
  67729. * @returns The light
  67730. */
  67731. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67732. /**
  67733. * Returns the string "Light".
  67734. * @returns the class name
  67735. */
  67736. getClassName(): string;
  67737. /** @hidden */
  67738. readonly _isLight: boolean;
  67739. /**
  67740. * Converts the light information to a readable string for debug purpose.
  67741. * @param fullDetails Supports for multiple levels of logging within scene loading
  67742. * @returns the human readable light info
  67743. */
  67744. toString(fullDetails?: boolean): string;
  67745. /** @hidden */
  67746. protected _syncParentEnabledState(): void;
  67747. /**
  67748. * Set the enabled state of this node.
  67749. * @param value - the new enabled state
  67750. */
  67751. setEnabled(value: boolean): void;
  67752. /**
  67753. * Returns the Light associated shadow generator if any.
  67754. * @return the associated shadow generator.
  67755. */
  67756. getShadowGenerator(): Nullable<IShadowGenerator>;
  67757. /**
  67758. * Returns a Vector3, the absolute light position in the World.
  67759. * @returns the world space position of the light
  67760. */
  67761. getAbsolutePosition(): Vector3;
  67762. /**
  67763. * Specifies if the light will affect the passed mesh.
  67764. * @param mesh The mesh to test against the light
  67765. * @return true the mesh is affected otherwise, false.
  67766. */
  67767. canAffectMesh(mesh: AbstractMesh): boolean;
  67768. /**
  67769. * Sort function to order lights for rendering.
  67770. * @param a First Light object to compare to second.
  67771. * @param b Second Light object to compare first.
  67772. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67773. */
  67774. static CompareLightsPriority(a: Light, b: Light): number;
  67775. /**
  67776. * Releases resources associated with this node.
  67777. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67778. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67779. */
  67780. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67781. /**
  67782. * Returns the light type ID (integer).
  67783. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67784. */
  67785. getTypeID(): number;
  67786. /**
  67787. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67788. * @returns the scaled intensity in intensity mode unit
  67789. */
  67790. getScaledIntensity(): number;
  67791. /**
  67792. * Returns a new Light object, named "name", from the current one.
  67793. * @param name The name of the cloned light
  67794. * @returns the new created light
  67795. */
  67796. clone(name: string): Nullable<Light>;
  67797. /**
  67798. * Serializes the current light into a Serialization object.
  67799. * @returns the serialized object.
  67800. */
  67801. serialize(): any;
  67802. /**
  67803. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67804. * This new light is named "name" and added to the passed scene.
  67805. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67806. * @param name The friendly name of the light
  67807. * @param scene The scene the new light will belong to
  67808. * @returns the constructor function
  67809. */
  67810. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67811. /**
  67812. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67813. * @param parsedLight The JSON representation of the light
  67814. * @param scene The scene to create the parsed light in
  67815. * @returns the created light after parsing
  67816. */
  67817. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67818. private _hookArrayForExcluded;
  67819. private _hookArrayForIncludedOnly;
  67820. private _resyncMeshes;
  67821. /**
  67822. * Forces the meshes to update their light related information in their rendering used effects
  67823. * @hidden Internal Use Only
  67824. */
  67825. _markMeshesAsLightDirty(): void;
  67826. /**
  67827. * Recomputes the cached photometric scale if needed.
  67828. */
  67829. private _computePhotometricScale;
  67830. /**
  67831. * Returns the Photometric Scale according to the light type and intensity mode.
  67832. */
  67833. private _getPhotometricScale;
  67834. /**
  67835. * Reorder the light in the scene according to their defined priority.
  67836. * @hidden Internal Use Only
  67837. */
  67838. _reorderLightsInScene(): void;
  67839. /**
  67840. * Prepares the list of defines specific to the light type.
  67841. * @param defines the list of defines
  67842. * @param lightIndex defines the index of the light for the effect
  67843. */
  67844. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67845. }
  67846. }
  67847. declare module BABYLON {
  67848. /**
  67849. * Interface used to define Action
  67850. */
  67851. export interface IAction {
  67852. /**
  67853. * Trigger for the action
  67854. */
  67855. trigger: number;
  67856. /** Options of the trigger */
  67857. triggerOptions: any;
  67858. /**
  67859. * Gets the trigger parameters
  67860. * @returns the trigger parameters
  67861. */
  67862. getTriggerParameter(): any;
  67863. /**
  67864. * Internal only - executes current action event
  67865. * @hidden
  67866. */
  67867. _executeCurrent(evt?: ActionEvent): void;
  67868. /**
  67869. * Serialize placeholder for child classes
  67870. * @param parent of child
  67871. * @returns the serialized object
  67872. */
  67873. serialize(parent: any): any;
  67874. /**
  67875. * Internal only
  67876. * @hidden
  67877. */
  67878. _prepare(): void;
  67879. /**
  67880. * Internal only - manager for action
  67881. * @hidden
  67882. */
  67883. _actionManager: AbstractActionManager;
  67884. }
  67885. /**
  67886. * The action to be carried out following a trigger
  67887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  67888. */
  67889. export class Action implements IAction {
  67890. /** the trigger, with or without parameters, for the action */
  67891. triggerOptions: any;
  67892. /**
  67893. * Trigger for the action
  67894. */
  67895. trigger: number;
  67896. /**
  67897. * Internal only - manager for action
  67898. * @hidden
  67899. */
  67900. _actionManager: ActionManager;
  67901. private _nextActiveAction;
  67902. private _child;
  67903. private _condition?;
  67904. private _triggerParameter;
  67905. /**
  67906. * An event triggered prior to action being executed.
  67907. */
  67908. onBeforeExecuteObservable: Observable<Action>;
  67909. /**
  67910. * Creates a new Action
  67911. * @param triggerOptions the trigger, with or without parameters, for the action
  67912. * @param condition an optional determinant of action
  67913. */
  67914. constructor(
  67915. /** the trigger, with or without parameters, for the action */
  67916. triggerOptions: any, condition?: Condition);
  67917. /**
  67918. * Internal only
  67919. * @hidden
  67920. */
  67921. _prepare(): void;
  67922. /**
  67923. * Gets the trigger parameters
  67924. * @returns the trigger parameters
  67925. */
  67926. getTriggerParameter(): any;
  67927. /**
  67928. * Internal only - executes current action event
  67929. * @hidden
  67930. */
  67931. _executeCurrent(evt?: ActionEvent): void;
  67932. /**
  67933. * Execute placeholder for child classes
  67934. * @param evt optional action event
  67935. */
  67936. execute(evt?: ActionEvent): void;
  67937. /**
  67938. * Skips to next active action
  67939. */
  67940. skipToNextActiveAction(): void;
  67941. /**
  67942. * Adds action to chain of actions, may be a DoNothingAction
  67943. * @param action defines the next action to execute
  67944. * @returns The action passed in
  67945. * @see https://www.babylonjs-playground.com/#1T30HR#0
  67946. */
  67947. then(action: Action): Action;
  67948. /**
  67949. * Internal only
  67950. * @hidden
  67951. */
  67952. _getProperty(propertyPath: string): string;
  67953. /**
  67954. * Internal only
  67955. * @hidden
  67956. */
  67957. _getEffectiveTarget(target: any, propertyPath: string): any;
  67958. /**
  67959. * Serialize placeholder for child classes
  67960. * @param parent of child
  67961. * @returns the serialized object
  67962. */
  67963. serialize(parent: any): any;
  67964. /**
  67965. * Internal only called by serialize
  67966. * @hidden
  67967. */
  67968. protected _serialize(serializedAction: any, parent?: any): any;
  67969. /**
  67970. * Internal only
  67971. * @hidden
  67972. */
  67973. static _SerializeValueAsString: (value: any) => string;
  67974. /**
  67975. * Internal only
  67976. * @hidden
  67977. */
  67978. static _GetTargetProperty: (target: Scene | Node) => {
  67979. name: string;
  67980. targetType: string;
  67981. value: string;
  67982. };
  67983. }
  67984. }
  67985. declare module BABYLON {
  67986. /**
  67987. * A Condition applied to an Action
  67988. */
  67989. export class Condition {
  67990. /**
  67991. * Internal only - manager for action
  67992. * @hidden
  67993. */
  67994. _actionManager: ActionManager;
  67995. /**
  67996. * Internal only
  67997. * @hidden
  67998. */
  67999. _evaluationId: number;
  68000. /**
  68001. * Internal only
  68002. * @hidden
  68003. */
  68004. _currentResult: boolean;
  68005. /**
  68006. * Creates a new Condition
  68007. * @param actionManager the manager of the action the condition is applied to
  68008. */
  68009. constructor(actionManager: ActionManager);
  68010. /**
  68011. * Check if the current condition is valid
  68012. * @returns a boolean
  68013. */
  68014. isValid(): boolean;
  68015. /**
  68016. * Internal only
  68017. * @hidden
  68018. */
  68019. _getProperty(propertyPath: string): string;
  68020. /**
  68021. * Internal only
  68022. * @hidden
  68023. */
  68024. _getEffectiveTarget(target: any, propertyPath: string): any;
  68025. /**
  68026. * Serialize placeholder for child classes
  68027. * @returns the serialized object
  68028. */
  68029. serialize(): any;
  68030. /**
  68031. * Internal only
  68032. * @hidden
  68033. */
  68034. protected _serialize(serializedCondition: any): any;
  68035. }
  68036. /**
  68037. * Defines specific conditional operators as extensions of Condition
  68038. */
  68039. export class ValueCondition extends Condition {
  68040. /** path to specify the property of the target the conditional operator uses */
  68041. propertyPath: string;
  68042. /** the value compared by the conditional operator against the current value of the property */
  68043. value: any;
  68044. /** the conditional operator, default ValueCondition.IsEqual */
  68045. operator: number;
  68046. /**
  68047. * Internal only
  68048. * @hidden
  68049. */
  68050. private static _IsEqual;
  68051. /**
  68052. * Internal only
  68053. * @hidden
  68054. */
  68055. private static _IsDifferent;
  68056. /**
  68057. * Internal only
  68058. * @hidden
  68059. */
  68060. private static _IsGreater;
  68061. /**
  68062. * Internal only
  68063. * @hidden
  68064. */
  68065. private static _IsLesser;
  68066. /**
  68067. * returns the number for IsEqual
  68068. */
  68069. static readonly IsEqual: number;
  68070. /**
  68071. * Returns the number for IsDifferent
  68072. */
  68073. static readonly IsDifferent: number;
  68074. /**
  68075. * Returns the number for IsGreater
  68076. */
  68077. static readonly IsGreater: number;
  68078. /**
  68079. * Returns the number for IsLesser
  68080. */
  68081. static readonly IsLesser: number;
  68082. /**
  68083. * Internal only The action manager for the condition
  68084. * @hidden
  68085. */
  68086. _actionManager: ActionManager;
  68087. /**
  68088. * Internal only
  68089. * @hidden
  68090. */
  68091. private _target;
  68092. /**
  68093. * Internal only
  68094. * @hidden
  68095. */
  68096. private _effectiveTarget;
  68097. /**
  68098. * Internal only
  68099. * @hidden
  68100. */
  68101. private _property;
  68102. /**
  68103. * Creates a new ValueCondition
  68104. * @param actionManager manager for the action the condition applies to
  68105. * @param target for the action
  68106. * @param propertyPath path to specify the property of the target the conditional operator uses
  68107. * @param value the value compared by the conditional operator against the current value of the property
  68108. * @param operator the conditional operator, default ValueCondition.IsEqual
  68109. */
  68110. constructor(actionManager: ActionManager, target: any,
  68111. /** path to specify the property of the target the conditional operator uses */
  68112. propertyPath: string,
  68113. /** the value compared by the conditional operator against the current value of the property */
  68114. value: any,
  68115. /** the conditional operator, default ValueCondition.IsEqual */
  68116. operator?: number);
  68117. /**
  68118. * Compares the given value with the property value for the specified conditional operator
  68119. * @returns the result of the comparison
  68120. */
  68121. isValid(): boolean;
  68122. /**
  68123. * Serialize the ValueCondition into a JSON compatible object
  68124. * @returns serialization object
  68125. */
  68126. serialize(): any;
  68127. /**
  68128. * Gets the name of the conditional operator for the ValueCondition
  68129. * @param operator the conditional operator
  68130. * @returns the name
  68131. */
  68132. static GetOperatorName(operator: number): string;
  68133. }
  68134. /**
  68135. * Defines a predicate condition as an extension of Condition
  68136. */
  68137. export class PredicateCondition extends Condition {
  68138. /** defines the predicate function used to validate the condition */
  68139. predicate: () => boolean;
  68140. /**
  68141. * Internal only - manager for action
  68142. * @hidden
  68143. */
  68144. _actionManager: ActionManager;
  68145. /**
  68146. * Creates a new PredicateCondition
  68147. * @param actionManager manager for the action the condition applies to
  68148. * @param predicate defines the predicate function used to validate the condition
  68149. */
  68150. constructor(actionManager: ActionManager,
  68151. /** defines the predicate function used to validate the condition */
  68152. predicate: () => boolean);
  68153. /**
  68154. * @returns the validity of the predicate condition
  68155. */
  68156. isValid(): boolean;
  68157. }
  68158. /**
  68159. * Defines a state condition as an extension of Condition
  68160. */
  68161. export class StateCondition extends Condition {
  68162. /** Value to compare with target state */
  68163. value: string;
  68164. /**
  68165. * Internal only - manager for action
  68166. * @hidden
  68167. */
  68168. _actionManager: ActionManager;
  68169. /**
  68170. * Internal only
  68171. * @hidden
  68172. */
  68173. private _target;
  68174. /**
  68175. * Creates a new StateCondition
  68176. * @param actionManager manager for the action the condition applies to
  68177. * @param target of the condition
  68178. * @param value to compare with target state
  68179. */
  68180. constructor(actionManager: ActionManager, target: any,
  68181. /** Value to compare with target state */
  68182. value: string);
  68183. /**
  68184. * Gets a boolean indicating if the current condition is met
  68185. * @returns the validity of the state
  68186. */
  68187. isValid(): boolean;
  68188. /**
  68189. * Serialize the StateCondition into a JSON compatible object
  68190. * @returns serialization object
  68191. */
  68192. serialize(): any;
  68193. }
  68194. }
  68195. declare module BABYLON {
  68196. /**
  68197. * This defines an action responsible to toggle a boolean once triggered.
  68198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68199. */
  68200. export class SwitchBooleanAction extends Action {
  68201. /**
  68202. * The path to the boolean property in the target object
  68203. */
  68204. propertyPath: string;
  68205. private _target;
  68206. private _effectiveTarget;
  68207. private _property;
  68208. /**
  68209. * Instantiate the action
  68210. * @param triggerOptions defines the trigger options
  68211. * @param target defines the object containing the boolean
  68212. * @param propertyPath defines the path to the boolean property in the target object
  68213. * @param condition defines the trigger related conditions
  68214. */
  68215. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  68216. /** @hidden */
  68217. _prepare(): void;
  68218. /**
  68219. * Execute the action toggle the boolean value.
  68220. */
  68221. execute(): void;
  68222. /**
  68223. * Serializes the actions and its related information.
  68224. * @param parent defines the object to serialize in
  68225. * @returns the serialized object
  68226. */
  68227. serialize(parent: any): any;
  68228. }
  68229. /**
  68230. * This defines an action responsible to set a the state field of the target
  68231. * to a desired value once triggered.
  68232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68233. */
  68234. export class SetStateAction extends Action {
  68235. /**
  68236. * The value to store in the state field.
  68237. */
  68238. value: string;
  68239. private _target;
  68240. /**
  68241. * Instantiate the action
  68242. * @param triggerOptions defines the trigger options
  68243. * @param target defines the object containing the state property
  68244. * @param value defines the value to store in the state field
  68245. * @param condition defines the trigger related conditions
  68246. */
  68247. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  68248. /**
  68249. * Execute the action and store the value on the target state property.
  68250. */
  68251. execute(): void;
  68252. /**
  68253. * Serializes the actions and its related information.
  68254. * @param parent defines the object to serialize in
  68255. * @returns the serialized object
  68256. */
  68257. serialize(parent: any): any;
  68258. }
  68259. /**
  68260. * This defines an action responsible to set a property of the target
  68261. * to a desired value once triggered.
  68262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68263. */
  68264. export class SetValueAction extends Action {
  68265. /**
  68266. * The path of the property to set in the target.
  68267. */
  68268. propertyPath: string;
  68269. /**
  68270. * The value to set in the property
  68271. */
  68272. value: any;
  68273. private _target;
  68274. private _effectiveTarget;
  68275. private _property;
  68276. /**
  68277. * Instantiate the action
  68278. * @param triggerOptions defines the trigger options
  68279. * @param target defines the object containing the property
  68280. * @param propertyPath defines the path of the property to set in the target
  68281. * @param value defines the value to set in the property
  68282. * @param condition defines the trigger related conditions
  68283. */
  68284. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68285. /** @hidden */
  68286. _prepare(): void;
  68287. /**
  68288. * Execute the action and set the targetted property to the desired value.
  68289. */
  68290. execute(): void;
  68291. /**
  68292. * Serializes the actions and its related information.
  68293. * @param parent defines the object to serialize in
  68294. * @returns the serialized object
  68295. */
  68296. serialize(parent: any): any;
  68297. }
  68298. /**
  68299. * This defines an action responsible to increment the target value
  68300. * to a desired value once triggered.
  68301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68302. */
  68303. export class IncrementValueAction extends Action {
  68304. /**
  68305. * The path of the property to increment in the target.
  68306. */
  68307. propertyPath: string;
  68308. /**
  68309. * The value we should increment the property by.
  68310. */
  68311. value: any;
  68312. private _target;
  68313. private _effectiveTarget;
  68314. private _property;
  68315. /**
  68316. * Instantiate the action
  68317. * @param triggerOptions defines the trigger options
  68318. * @param target defines the object containing the property
  68319. * @param propertyPath defines the path of the property to increment in the target
  68320. * @param value defines the value value we should increment the property by
  68321. * @param condition defines the trigger related conditions
  68322. */
  68323. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  68324. /** @hidden */
  68325. _prepare(): void;
  68326. /**
  68327. * Execute the action and increment the target of the value amount.
  68328. */
  68329. execute(): void;
  68330. /**
  68331. * Serializes the actions and its related information.
  68332. * @param parent defines the object to serialize in
  68333. * @returns the serialized object
  68334. */
  68335. serialize(parent: any): any;
  68336. }
  68337. /**
  68338. * This defines an action responsible to start an animation once triggered.
  68339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68340. */
  68341. export class PlayAnimationAction extends Action {
  68342. /**
  68343. * Where the animation should start (animation frame)
  68344. */
  68345. from: number;
  68346. /**
  68347. * Where the animation should stop (animation frame)
  68348. */
  68349. to: number;
  68350. /**
  68351. * Define if the animation should loop or stop after the first play.
  68352. */
  68353. loop?: boolean;
  68354. private _target;
  68355. /**
  68356. * Instantiate the action
  68357. * @param triggerOptions defines the trigger options
  68358. * @param target defines the target animation or animation name
  68359. * @param from defines from where the animation should start (animation frame)
  68360. * @param end defines where the animation should stop (animation frame)
  68361. * @param loop defines if the animation should loop or stop after the first play
  68362. * @param condition defines the trigger related conditions
  68363. */
  68364. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  68365. /** @hidden */
  68366. _prepare(): void;
  68367. /**
  68368. * Execute the action and play the animation.
  68369. */
  68370. execute(): void;
  68371. /**
  68372. * Serializes the actions and its related information.
  68373. * @param parent defines the object to serialize in
  68374. * @returns the serialized object
  68375. */
  68376. serialize(parent: any): any;
  68377. }
  68378. /**
  68379. * This defines an action responsible to stop an animation once triggered.
  68380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68381. */
  68382. export class StopAnimationAction extends Action {
  68383. private _target;
  68384. /**
  68385. * Instantiate the action
  68386. * @param triggerOptions defines the trigger options
  68387. * @param target defines the target animation or animation name
  68388. * @param condition defines the trigger related conditions
  68389. */
  68390. constructor(triggerOptions: any, target: any, condition?: Condition);
  68391. /** @hidden */
  68392. _prepare(): void;
  68393. /**
  68394. * Execute the action and stop the animation.
  68395. */
  68396. execute(): void;
  68397. /**
  68398. * Serializes the actions and its related information.
  68399. * @param parent defines the object to serialize in
  68400. * @returns the serialized object
  68401. */
  68402. serialize(parent: any): any;
  68403. }
  68404. /**
  68405. * This defines an action responsible that does nothing once triggered.
  68406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68407. */
  68408. export class DoNothingAction extends Action {
  68409. /**
  68410. * Instantiate the action
  68411. * @param triggerOptions defines the trigger options
  68412. * @param condition defines the trigger related conditions
  68413. */
  68414. constructor(triggerOptions?: any, condition?: Condition);
  68415. /**
  68416. * Execute the action and do nothing.
  68417. */
  68418. execute(): void;
  68419. /**
  68420. * Serializes the actions and its related information.
  68421. * @param parent defines the object to serialize in
  68422. * @returns the serialized object
  68423. */
  68424. serialize(parent: any): any;
  68425. }
  68426. /**
  68427. * This defines an action responsible to trigger several actions once triggered.
  68428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68429. */
  68430. export class CombineAction extends Action {
  68431. /**
  68432. * The list of aggregated animations to run.
  68433. */
  68434. children: Action[];
  68435. /**
  68436. * Instantiate the action
  68437. * @param triggerOptions defines the trigger options
  68438. * @param children defines the list of aggregated animations to run
  68439. * @param condition defines the trigger related conditions
  68440. */
  68441. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  68442. /** @hidden */
  68443. _prepare(): void;
  68444. /**
  68445. * Execute the action and executes all the aggregated actions.
  68446. */
  68447. execute(evt: ActionEvent): void;
  68448. /**
  68449. * Serializes the actions and its related information.
  68450. * @param parent defines the object to serialize in
  68451. * @returns the serialized object
  68452. */
  68453. serialize(parent: any): any;
  68454. }
  68455. /**
  68456. * This defines an action responsible to run code (external event) once triggered.
  68457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68458. */
  68459. export class ExecuteCodeAction extends Action {
  68460. /**
  68461. * The callback function to run.
  68462. */
  68463. func: (evt: ActionEvent) => void;
  68464. /**
  68465. * Instantiate the action
  68466. * @param triggerOptions defines the trigger options
  68467. * @param func defines the callback function to run
  68468. * @param condition defines the trigger related conditions
  68469. */
  68470. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  68471. /**
  68472. * Execute the action and run the attached code.
  68473. */
  68474. execute(evt: ActionEvent): void;
  68475. }
  68476. /**
  68477. * This defines an action responsible to set the parent property of the target once triggered.
  68478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68479. */
  68480. export class SetParentAction extends Action {
  68481. private _parent;
  68482. private _target;
  68483. /**
  68484. * Instantiate the action
  68485. * @param triggerOptions defines the trigger options
  68486. * @param target defines the target containing the parent property
  68487. * @param parent defines from where the animation should start (animation frame)
  68488. * @param condition defines the trigger related conditions
  68489. */
  68490. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  68491. /** @hidden */
  68492. _prepare(): void;
  68493. /**
  68494. * Execute the action and set the parent property.
  68495. */
  68496. execute(): void;
  68497. /**
  68498. * Serializes the actions and its related information.
  68499. * @param parent defines the object to serialize in
  68500. * @returns the serialized object
  68501. */
  68502. serialize(parent: any): any;
  68503. }
  68504. }
  68505. declare module BABYLON {
  68506. /**
  68507. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  68508. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  68509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  68510. */
  68511. export class ActionManager extends AbstractActionManager {
  68512. /**
  68513. * Nothing
  68514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68515. */
  68516. static readonly NothingTrigger: number;
  68517. /**
  68518. * On pick
  68519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68520. */
  68521. static readonly OnPickTrigger: number;
  68522. /**
  68523. * On left pick
  68524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68525. */
  68526. static readonly OnLeftPickTrigger: number;
  68527. /**
  68528. * On right pick
  68529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68530. */
  68531. static readonly OnRightPickTrigger: number;
  68532. /**
  68533. * On center pick
  68534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68535. */
  68536. static readonly OnCenterPickTrigger: number;
  68537. /**
  68538. * On pick down
  68539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68540. */
  68541. static readonly OnPickDownTrigger: number;
  68542. /**
  68543. * On double pick
  68544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68545. */
  68546. static readonly OnDoublePickTrigger: number;
  68547. /**
  68548. * On pick up
  68549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68550. */
  68551. static readonly OnPickUpTrigger: number;
  68552. /**
  68553. * On pick out.
  68554. * This trigger will only be raised if you also declared a OnPickDown
  68555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68556. */
  68557. static readonly OnPickOutTrigger: number;
  68558. /**
  68559. * On long press
  68560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68561. */
  68562. static readonly OnLongPressTrigger: number;
  68563. /**
  68564. * On pointer over
  68565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68566. */
  68567. static readonly OnPointerOverTrigger: number;
  68568. /**
  68569. * On pointer out
  68570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68571. */
  68572. static readonly OnPointerOutTrigger: number;
  68573. /**
  68574. * On every frame
  68575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68576. */
  68577. static readonly OnEveryFrameTrigger: number;
  68578. /**
  68579. * On intersection enter
  68580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68581. */
  68582. static readonly OnIntersectionEnterTrigger: number;
  68583. /**
  68584. * On intersection exit
  68585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68586. */
  68587. static readonly OnIntersectionExitTrigger: number;
  68588. /**
  68589. * On key down
  68590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68591. */
  68592. static readonly OnKeyDownTrigger: number;
  68593. /**
  68594. * On key up
  68595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68596. */
  68597. static readonly OnKeyUpTrigger: number;
  68598. private _scene;
  68599. /**
  68600. * Creates a new action manager
  68601. * @param scene defines the hosting scene
  68602. */
  68603. constructor(scene: Scene);
  68604. /**
  68605. * Releases all associated resources
  68606. */
  68607. dispose(): void;
  68608. /**
  68609. * Gets hosting scene
  68610. * @returns the hosting scene
  68611. */
  68612. getScene(): Scene;
  68613. /**
  68614. * Does this action manager handles actions of any of the given triggers
  68615. * @param triggers defines the triggers to be tested
  68616. * @return a boolean indicating whether one (or more) of the triggers is handled
  68617. */
  68618. hasSpecificTriggers(triggers: number[]): boolean;
  68619. /**
  68620. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  68621. * speed.
  68622. * @param triggerA defines the trigger to be tested
  68623. * @param triggerB defines the trigger to be tested
  68624. * @return a boolean indicating whether one (or more) of the triggers is handled
  68625. */
  68626. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  68627. /**
  68628. * Does this action manager handles actions of a given trigger
  68629. * @param trigger defines the trigger to be tested
  68630. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  68631. * @return whether the trigger is handled
  68632. */
  68633. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  68634. /**
  68635. * Does this action manager has pointer triggers
  68636. */
  68637. readonly hasPointerTriggers: boolean;
  68638. /**
  68639. * Does this action manager has pick triggers
  68640. */
  68641. readonly hasPickTriggers: boolean;
  68642. /**
  68643. * Registers an action to this action manager
  68644. * @param action defines the action to be registered
  68645. * @return the action amended (prepared) after registration
  68646. */
  68647. registerAction(action: IAction): Nullable<IAction>;
  68648. /**
  68649. * Unregisters an action to this action manager
  68650. * @param action defines the action to be unregistered
  68651. * @return a boolean indicating whether the action has been unregistered
  68652. */
  68653. unregisterAction(action: IAction): Boolean;
  68654. /**
  68655. * Process a specific trigger
  68656. * @param trigger defines the trigger to process
  68657. * @param evt defines the event details to be processed
  68658. */
  68659. processTrigger(trigger: number, evt?: IActionEvent): void;
  68660. /** @hidden */
  68661. _getEffectiveTarget(target: any, propertyPath: string): any;
  68662. /** @hidden */
  68663. _getProperty(propertyPath: string): string;
  68664. /**
  68665. * Serialize this manager to a JSON object
  68666. * @param name defines the property name to store this manager
  68667. * @returns a JSON representation of this manager
  68668. */
  68669. serialize(name: string): any;
  68670. /**
  68671. * Creates a new ActionManager from a JSON data
  68672. * @param parsedActions defines the JSON data to read from
  68673. * @param object defines the hosting mesh
  68674. * @param scene defines the hosting scene
  68675. */
  68676. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  68677. /**
  68678. * Get a trigger name by index
  68679. * @param trigger defines the trigger index
  68680. * @returns a trigger name
  68681. */
  68682. static GetTriggerName(trigger: number): string;
  68683. }
  68684. }
  68685. declare module BABYLON {
  68686. /**
  68687. * Class representing a ray with position and direction
  68688. */
  68689. export class Ray {
  68690. /** origin point */
  68691. origin: Vector3;
  68692. /** direction */
  68693. direction: Vector3;
  68694. /** length of the ray */
  68695. length: number;
  68696. private static readonly TmpVector3;
  68697. private _tmpRay;
  68698. /**
  68699. * Creates a new ray
  68700. * @param origin origin point
  68701. * @param direction direction
  68702. * @param length length of the ray
  68703. */
  68704. constructor(
  68705. /** origin point */
  68706. origin: Vector3,
  68707. /** direction */
  68708. direction: Vector3,
  68709. /** length of the ray */
  68710. length?: number);
  68711. /**
  68712. * Checks if the ray intersects a box
  68713. * @param minimum bound of the box
  68714. * @param maximum bound of the box
  68715. * @param intersectionTreshold extra extend to be added to the box in all direction
  68716. * @returns if the box was hit
  68717. */
  68718. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  68719. /**
  68720. * Checks if the ray intersects a box
  68721. * @param box the bounding box to check
  68722. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  68723. * @returns if the box was hit
  68724. */
  68725. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  68726. /**
  68727. * If the ray hits a sphere
  68728. * @param sphere the bounding sphere to check
  68729. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  68730. * @returns true if it hits the sphere
  68731. */
  68732. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  68733. /**
  68734. * If the ray hits a triange
  68735. * @param vertex0 triangle vertex
  68736. * @param vertex1 triangle vertex
  68737. * @param vertex2 triangle vertex
  68738. * @returns intersection information if hit
  68739. */
  68740. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  68741. /**
  68742. * Checks if ray intersects a plane
  68743. * @param plane the plane to check
  68744. * @returns the distance away it was hit
  68745. */
  68746. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  68747. /**
  68748. * Checks if ray intersects a mesh
  68749. * @param mesh the mesh to check
  68750. * @param fastCheck if only the bounding box should checked
  68751. * @returns picking info of the intersecton
  68752. */
  68753. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  68754. /**
  68755. * Checks if ray intersects a mesh
  68756. * @param meshes the meshes to check
  68757. * @param fastCheck if only the bounding box should checked
  68758. * @param results array to store result in
  68759. * @returns Array of picking infos
  68760. */
  68761. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  68762. private _comparePickingInfo;
  68763. private static smallnum;
  68764. private static rayl;
  68765. /**
  68766. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  68767. * @param sega the first point of the segment to test the intersection against
  68768. * @param segb the second point of the segment to test the intersection against
  68769. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  68770. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  68771. */
  68772. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  68773. /**
  68774. * Update the ray from viewport position
  68775. * @param x position
  68776. * @param y y position
  68777. * @param viewportWidth viewport width
  68778. * @param viewportHeight viewport height
  68779. * @param world world matrix
  68780. * @param view view matrix
  68781. * @param projection projection matrix
  68782. * @returns this ray updated
  68783. */
  68784. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68785. /**
  68786. * Creates a ray with origin and direction of 0,0,0
  68787. * @returns the new ray
  68788. */
  68789. static Zero(): Ray;
  68790. /**
  68791. * Creates a new ray from screen space and viewport
  68792. * @param x position
  68793. * @param y y position
  68794. * @param viewportWidth viewport width
  68795. * @param viewportHeight viewport height
  68796. * @param world world matrix
  68797. * @param view view matrix
  68798. * @param projection projection matrix
  68799. * @returns new ray
  68800. */
  68801. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  68802. /**
  68803. * 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
  68804. * transformed to the given world matrix.
  68805. * @param origin The origin point
  68806. * @param end The end point
  68807. * @param world a matrix to transform the ray to. Default is the identity matrix.
  68808. * @returns the new ray
  68809. */
  68810. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  68811. /**
  68812. * Transforms a ray by a matrix
  68813. * @param ray ray to transform
  68814. * @param matrix matrix to apply
  68815. * @returns the resulting new ray
  68816. */
  68817. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  68818. /**
  68819. * Transforms a ray by a matrix
  68820. * @param ray ray to transform
  68821. * @param matrix matrix to apply
  68822. * @param result ray to store result in
  68823. */
  68824. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  68825. /**
  68826. * Unproject a ray from screen space to object space
  68827. * @param sourceX defines the screen space x coordinate to use
  68828. * @param sourceY defines the screen space y coordinate to use
  68829. * @param viewportWidth defines the current width of the viewport
  68830. * @param viewportHeight defines the current height of the viewport
  68831. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68832. * @param view defines the view matrix to use
  68833. * @param projection defines the projection matrix to use
  68834. */
  68835. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  68836. }
  68837. /**
  68838. * Type used to define predicate used to select faces when a mesh intersection is detected
  68839. */
  68840. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  68841. interface Scene {
  68842. /** @hidden */
  68843. _tempPickingRay: Nullable<Ray>;
  68844. /** @hidden */
  68845. _cachedRayForTransform: Ray;
  68846. /** @hidden */
  68847. _pickWithRayInverseMatrix: Matrix;
  68848. /** @hidden */
  68849. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  68850. /** @hidden */
  68851. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  68852. }
  68853. }
  68854. declare module BABYLON {
  68855. /**
  68856. * Groups all the scene component constants in one place to ease maintenance.
  68857. * @hidden
  68858. */
  68859. export class SceneComponentConstants {
  68860. static readonly NAME_EFFECTLAYER: string;
  68861. static readonly NAME_LAYER: string;
  68862. static readonly NAME_LENSFLARESYSTEM: string;
  68863. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68864. static readonly NAME_PARTICLESYSTEM: string;
  68865. static readonly NAME_GAMEPAD: string;
  68866. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68867. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68868. static readonly NAME_DEPTHRENDERER: string;
  68869. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68870. static readonly NAME_SPRITE: string;
  68871. static readonly NAME_OUTLINERENDERER: string;
  68872. static readonly NAME_PROCEDURALTEXTURE: string;
  68873. static readonly NAME_SHADOWGENERATOR: string;
  68874. static readonly NAME_OCTREE: string;
  68875. static readonly NAME_PHYSICSENGINE: string;
  68876. static readonly NAME_AUDIO: string;
  68877. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68878. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68879. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68880. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68881. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68882. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68883. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68884. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68885. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68886. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68887. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68888. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68889. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68890. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68891. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68892. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68893. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68894. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68895. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68896. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68897. static readonly STEP_AFTERRENDER_AUDIO: number;
  68898. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68899. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68900. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68901. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68902. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68903. static readonly STEP_POINTERMOVE_SPRITE: number;
  68904. static readonly STEP_POINTERDOWN_SPRITE: number;
  68905. static readonly STEP_POINTERUP_SPRITE: number;
  68906. }
  68907. /**
  68908. * This represents a scene component.
  68909. *
  68910. * This is used to decouple the dependency the scene is having on the different workloads like
  68911. * layers, post processes...
  68912. */
  68913. export interface ISceneComponent {
  68914. /**
  68915. * The name of the component. Each component must have a unique name.
  68916. */
  68917. name: string;
  68918. /**
  68919. * The scene the component belongs to.
  68920. */
  68921. scene: Scene;
  68922. /**
  68923. * Register the component to one instance of a scene.
  68924. */
  68925. register(): void;
  68926. /**
  68927. * Rebuilds the elements related to this component in case of
  68928. * context lost for instance.
  68929. */
  68930. rebuild(): void;
  68931. /**
  68932. * Disposes the component and the associated ressources.
  68933. */
  68934. dispose(): void;
  68935. }
  68936. /**
  68937. * This represents a SERIALIZABLE scene component.
  68938. *
  68939. * This extends Scene Component to add Serialization methods on top.
  68940. */
  68941. export interface ISceneSerializableComponent extends ISceneComponent {
  68942. /**
  68943. * Adds all the element from the container to the scene
  68944. * @param container the container holding the elements
  68945. */
  68946. addFromContainer(container: AbstractScene): void;
  68947. /**
  68948. * Removes all the elements in the container from the scene
  68949. * @param container contains the elements to remove
  68950. */
  68951. removeFromContainer(container: AbstractScene): void;
  68952. /**
  68953. * Serializes the component data to the specified json object
  68954. * @param serializationObject The object to serialize to
  68955. */
  68956. serialize(serializationObject: any): void;
  68957. }
  68958. /**
  68959. * Strong typing of a Mesh related stage step action
  68960. */
  68961. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68962. /**
  68963. * Strong typing of a Evaluate Sub Mesh related stage step action
  68964. */
  68965. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68966. /**
  68967. * Strong typing of a Active Mesh related stage step action
  68968. */
  68969. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68970. /**
  68971. * Strong typing of a Camera related stage step action
  68972. */
  68973. export type CameraStageAction = (camera: Camera) => void;
  68974. /**
  68975. * Strong typing of a Render Target related stage step action
  68976. */
  68977. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68978. /**
  68979. * Strong typing of a RenderingGroup related stage step action
  68980. */
  68981. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68982. /**
  68983. * Strong typing of a Mesh Render related stage step action
  68984. */
  68985. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68986. /**
  68987. * Strong typing of a simple stage step action
  68988. */
  68989. export type SimpleStageAction = () => void;
  68990. /**
  68991. * Strong typing of a render target action.
  68992. */
  68993. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68994. /**
  68995. * Strong typing of a pointer move action.
  68996. */
  68997. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68998. /**
  68999. * Strong typing of a pointer up/down action.
  69000. */
  69001. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69002. /**
  69003. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69004. * @hidden
  69005. */
  69006. export class Stage<T extends Function> extends Array<{
  69007. index: number;
  69008. component: ISceneComponent;
  69009. action: T;
  69010. }> {
  69011. /**
  69012. * Hide ctor from the rest of the world.
  69013. * @param items The items to add.
  69014. */
  69015. private constructor();
  69016. /**
  69017. * Creates a new Stage.
  69018. * @returns A new instance of a Stage
  69019. */
  69020. static Create<T extends Function>(): Stage<T>;
  69021. /**
  69022. * Registers a step in an ordered way in the targeted stage.
  69023. * @param index Defines the position to register the step in
  69024. * @param component Defines the component attached to the step
  69025. * @param action Defines the action to launch during the step
  69026. */
  69027. registerStep(index: number, component: ISceneComponent, action: T): void;
  69028. /**
  69029. * Clears all the steps from the stage.
  69030. */
  69031. clear(): void;
  69032. }
  69033. }
  69034. declare module BABYLON {
  69035. interface Scene {
  69036. /** @hidden */
  69037. _pointerOverSprite: Nullable<Sprite>;
  69038. /** @hidden */
  69039. _pickedDownSprite: Nullable<Sprite>;
  69040. /** @hidden */
  69041. _tempSpritePickingRay: Nullable<Ray>;
  69042. /**
  69043. * All of the sprite managers added to this scene
  69044. * @see http://doc.babylonjs.com/babylon101/sprites
  69045. */
  69046. spriteManagers: Array<ISpriteManager>;
  69047. /**
  69048. * An event triggered when sprites rendering is about to start
  69049. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69050. */
  69051. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69052. /**
  69053. * An event triggered when sprites rendering is done
  69054. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69055. */
  69056. onAfterSpritesRenderingObservable: Observable<Scene>;
  69057. /** @hidden */
  69058. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69059. /** Launch a ray to try to pick a sprite in the scene
  69060. * @param x position on screen
  69061. * @param y position on screen
  69062. * @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
  69063. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69064. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69065. * @returns a PickingInfo
  69066. */
  69067. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69068. /** Use the given ray to pick a sprite in the scene
  69069. * @param ray The ray (in world space) to use to pick meshes
  69070. * @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
  69071. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69072. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69073. * @returns a PickingInfo
  69074. */
  69075. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69076. /**
  69077. * Force the sprite under the pointer
  69078. * @param sprite defines the sprite to use
  69079. */
  69080. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69081. /**
  69082. * Gets the sprite under the pointer
  69083. * @returns a Sprite or null if no sprite is under the pointer
  69084. */
  69085. getPointerOverSprite(): Nullable<Sprite>;
  69086. }
  69087. /**
  69088. * Defines the sprite scene component responsible to manage sprites
  69089. * in a given scene.
  69090. */
  69091. export class SpriteSceneComponent implements ISceneComponent {
  69092. /**
  69093. * The component name helpfull to identify the component in the list of scene components.
  69094. */
  69095. readonly name: string;
  69096. /**
  69097. * The scene the component belongs to.
  69098. */
  69099. scene: Scene;
  69100. /** @hidden */
  69101. private _spritePredicate;
  69102. /**
  69103. * Creates a new instance of the component for the given scene
  69104. * @param scene Defines the scene to register the component in
  69105. */
  69106. constructor(scene: Scene);
  69107. /**
  69108. * Registers the component in a given scene
  69109. */
  69110. register(): void;
  69111. /**
  69112. * Rebuilds the elements related to this component in case of
  69113. * context lost for instance.
  69114. */
  69115. rebuild(): void;
  69116. /**
  69117. * Disposes the component and the associated ressources.
  69118. */
  69119. dispose(): void;
  69120. private _pickSpriteButKeepRay;
  69121. private _pointerMove;
  69122. private _pointerDown;
  69123. private _pointerUp;
  69124. }
  69125. }
  69126. declare module BABYLON {
  69127. /** @hidden */
  69128. export var fogFragmentDeclaration: {
  69129. name: string;
  69130. shader: string;
  69131. };
  69132. }
  69133. declare module BABYLON {
  69134. /** @hidden */
  69135. export var fogFragment: {
  69136. name: string;
  69137. shader: string;
  69138. };
  69139. }
  69140. declare module BABYLON {
  69141. /** @hidden */
  69142. export var spritesPixelShader: {
  69143. name: string;
  69144. shader: string;
  69145. };
  69146. }
  69147. declare module BABYLON {
  69148. /** @hidden */
  69149. export var fogVertexDeclaration: {
  69150. name: string;
  69151. shader: string;
  69152. };
  69153. }
  69154. declare module BABYLON {
  69155. /** @hidden */
  69156. export var spritesVertexShader: {
  69157. name: string;
  69158. shader: string;
  69159. };
  69160. }
  69161. declare module BABYLON {
  69162. /**
  69163. * Defines the minimum interface to fullfil in order to be a sprite manager.
  69164. */
  69165. export interface ISpriteManager extends IDisposable {
  69166. /**
  69167. * Restricts the camera to viewing objects with the same layerMask.
  69168. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  69169. */
  69170. layerMask: number;
  69171. /**
  69172. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  69173. */
  69174. isPickable: boolean;
  69175. /**
  69176. * Specifies the rendering group id for this mesh (0 by default)
  69177. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  69178. */
  69179. renderingGroupId: number;
  69180. /**
  69181. * Defines the list of sprites managed by the manager.
  69182. */
  69183. sprites: Array<Sprite>;
  69184. /**
  69185. * Tests the intersection of a sprite with a specific ray.
  69186. * @param ray The ray we are sending to test the collision
  69187. * @param camera The camera space we are sending rays in
  69188. * @param predicate A predicate allowing excluding sprites from the list of object to test
  69189. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  69190. * @returns picking info or null.
  69191. */
  69192. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69193. /**
  69194. * Renders the list of sprites on screen.
  69195. */
  69196. render(): void;
  69197. }
  69198. /**
  69199. * Class used to manage multiple sprites on the same spritesheet
  69200. * @see http://doc.babylonjs.com/babylon101/sprites
  69201. */
  69202. export class SpriteManager implements ISpriteManager {
  69203. /** defines the manager's name */
  69204. name: string;
  69205. /** Gets the list of sprites */
  69206. sprites: Sprite[];
  69207. /** Gets or sets the rendering group id (0 by default) */
  69208. renderingGroupId: number;
  69209. /** Gets or sets camera layer mask */
  69210. layerMask: number;
  69211. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  69212. fogEnabled: boolean;
  69213. /** Gets or sets a boolean indicating if the sprites are pickable */
  69214. isPickable: boolean;
  69215. /** Defines the default width of a cell in the spritesheet */
  69216. cellWidth: number;
  69217. /** Defines the default height of a cell in the spritesheet */
  69218. cellHeight: number;
  69219. /**
  69220. * An event triggered when the manager is disposed.
  69221. */
  69222. onDisposeObservable: Observable<SpriteManager>;
  69223. private _onDisposeObserver;
  69224. /**
  69225. * Callback called when the manager is disposed
  69226. */
  69227. onDispose: () => void;
  69228. private _capacity;
  69229. private _spriteTexture;
  69230. private _epsilon;
  69231. private _scene;
  69232. private _vertexData;
  69233. private _buffer;
  69234. private _vertexBuffers;
  69235. private _indexBuffer;
  69236. private _effectBase;
  69237. private _effectFog;
  69238. /**
  69239. * Gets or sets the spritesheet texture
  69240. */
  69241. texture: Texture;
  69242. /**
  69243. * Creates a new sprite manager
  69244. * @param name defines the manager's name
  69245. * @param imgUrl defines the sprite sheet url
  69246. * @param capacity defines the maximum allowed number of sprites
  69247. * @param cellSize defines the size of a sprite cell
  69248. * @param scene defines the hosting scene
  69249. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69250. * @param samplingMode defines the smapling mode to use with spritesheet
  69251. */
  69252. constructor(
  69253. /** defines the manager's name */
  69254. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  69255. private _appendSpriteVertex;
  69256. /**
  69257. * Intersects the sprites with a ray
  69258. * @param ray defines the ray to intersect with
  69259. * @param camera defines the current active camera
  69260. * @param predicate defines a predicate used to select candidate sprites
  69261. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  69262. * @returns null if no hit or a PickingInfo
  69263. */
  69264. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  69265. /**
  69266. * Render all child sprites
  69267. */
  69268. render(): void;
  69269. /**
  69270. * Release associated resources
  69271. */
  69272. dispose(): void;
  69273. }
  69274. }
  69275. declare module BABYLON {
  69276. /**
  69277. * Class used to represent a sprite
  69278. * @see http://doc.babylonjs.com/babylon101/sprites
  69279. */
  69280. export class Sprite {
  69281. /** defines the name */
  69282. name: string;
  69283. /** Gets or sets the current world position */
  69284. position: Vector3;
  69285. /** Gets or sets the main color */
  69286. color: Color4;
  69287. /** Gets or sets the width */
  69288. width: number;
  69289. /** Gets or sets the height */
  69290. height: number;
  69291. /** Gets or sets rotation angle */
  69292. angle: number;
  69293. /** Gets or sets the cell index in the sprite sheet */
  69294. cellIndex: number;
  69295. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  69296. invertU: number;
  69297. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  69298. invertV: number;
  69299. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  69300. disposeWhenFinishedAnimating: boolean;
  69301. /** Gets the list of attached animations */
  69302. animations: Animation[];
  69303. /** Gets or sets a boolean indicating if the sprite can be picked */
  69304. isPickable: boolean;
  69305. /**
  69306. * Gets or sets the associated action manager
  69307. */
  69308. actionManager: Nullable<ActionManager>;
  69309. private _animationStarted;
  69310. private _loopAnimation;
  69311. private _fromIndex;
  69312. private _toIndex;
  69313. private _delay;
  69314. private _direction;
  69315. private _manager;
  69316. private _time;
  69317. private _onAnimationEnd;
  69318. /**
  69319. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  69320. */
  69321. isVisible: boolean;
  69322. /**
  69323. * Gets or sets the sprite size
  69324. */
  69325. size: number;
  69326. /**
  69327. * Creates a new Sprite
  69328. * @param name defines the name
  69329. * @param manager defines the manager
  69330. */
  69331. constructor(
  69332. /** defines the name */
  69333. name: string, manager: ISpriteManager);
  69334. /**
  69335. * Starts an animation
  69336. * @param from defines the initial key
  69337. * @param to defines the end key
  69338. * @param loop defines if the animation must loop
  69339. * @param delay defines the start delay (in ms)
  69340. * @param onAnimationEnd defines a callback to call when animation ends
  69341. */
  69342. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  69343. /** Stops current animation (if any) */
  69344. stopAnimation(): void;
  69345. /** @hidden */
  69346. _animate(deltaTime: number): void;
  69347. /** Release associated resources */
  69348. dispose(): void;
  69349. }
  69350. }
  69351. declare module BABYLON {
  69352. /**
  69353. * Information about the result of picking within a scene
  69354. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  69355. */
  69356. export class PickingInfo {
  69357. /** @hidden */
  69358. _pickingUnavailable: boolean;
  69359. /**
  69360. * If the pick collided with an object
  69361. */
  69362. hit: boolean;
  69363. /**
  69364. * Distance away where the pick collided
  69365. */
  69366. distance: number;
  69367. /**
  69368. * The location of pick collision
  69369. */
  69370. pickedPoint: Nullable<Vector3>;
  69371. /**
  69372. * The mesh corresponding the the pick collision
  69373. */
  69374. pickedMesh: Nullable<AbstractMesh>;
  69375. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  69376. bu: number;
  69377. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  69378. bv: number;
  69379. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  69380. faceId: number;
  69381. /** Id of the the submesh that was picked */
  69382. subMeshId: number;
  69383. /** If a sprite was picked, this will be the sprite the pick collided with */
  69384. pickedSprite: Nullable<Sprite>;
  69385. /**
  69386. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  69387. */
  69388. originMesh: Nullable<AbstractMesh>;
  69389. /**
  69390. * The ray that was used to perform the picking.
  69391. */
  69392. ray: Nullable<Ray>;
  69393. /**
  69394. * Gets the normal correspodning to the face the pick collided with
  69395. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  69396. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  69397. * @returns The normal correspodning to the face the pick collided with
  69398. */
  69399. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  69400. /**
  69401. * Gets the texture coordinates of where the pick occured
  69402. * @returns the vector containing the coordnates of the texture
  69403. */
  69404. getTextureCoordinates(): Nullable<Vector2>;
  69405. }
  69406. }
  69407. declare module BABYLON {
  69408. /**
  69409. * Gather the list of pointer event types as constants.
  69410. */
  69411. export class PointerEventTypes {
  69412. /**
  69413. * 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.
  69414. */
  69415. static readonly POINTERDOWN: number;
  69416. /**
  69417. * The pointerup event is fired when a pointer is no longer active.
  69418. */
  69419. static readonly POINTERUP: number;
  69420. /**
  69421. * The pointermove event is fired when a pointer changes coordinates.
  69422. */
  69423. static readonly POINTERMOVE: number;
  69424. /**
  69425. * The pointerwheel event is fired when a mouse wheel has been rotated.
  69426. */
  69427. static readonly POINTERWHEEL: number;
  69428. /**
  69429. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  69430. */
  69431. static readonly POINTERPICK: number;
  69432. /**
  69433. * The pointertap event is fired when a the object has been touched and released without drag.
  69434. */
  69435. static readonly POINTERTAP: number;
  69436. /**
  69437. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  69438. */
  69439. static readonly POINTERDOUBLETAP: number;
  69440. }
  69441. /**
  69442. * Base class of pointer info types.
  69443. */
  69444. export class PointerInfoBase {
  69445. /**
  69446. * Defines the type of event (PointerEventTypes)
  69447. */
  69448. type: number;
  69449. /**
  69450. * Defines the related dom event
  69451. */
  69452. event: PointerEvent | MouseWheelEvent;
  69453. /**
  69454. * Instantiates the base class of pointers info.
  69455. * @param type Defines the type of event (PointerEventTypes)
  69456. * @param event Defines the related dom event
  69457. */
  69458. constructor(
  69459. /**
  69460. * Defines the type of event (PointerEventTypes)
  69461. */
  69462. type: number,
  69463. /**
  69464. * Defines the related dom event
  69465. */
  69466. event: PointerEvent | MouseWheelEvent);
  69467. }
  69468. /**
  69469. * This class is used to store pointer related info for the onPrePointerObservable event.
  69470. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  69471. */
  69472. export class PointerInfoPre extends PointerInfoBase {
  69473. /**
  69474. * Ray from a pointer if availible (eg. 6dof controller)
  69475. */
  69476. ray: Nullable<Ray>;
  69477. /**
  69478. * Defines the local position of the pointer on the canvas.
  69479. */
  69480. localPosition: Vector2;
  69481. /**
  69482. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  69483. */
  69484. skipOnPointerObservable: boolean;
  69485. /**
  69486. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  69487. * @param type Defines the type of event (PointerEventTypes)
  69488. * @param event Defines the related dom event
  69489. * @param localX Defines the local x coordinates of the pointer when the event occured
  69490. * @param localY Defines the local y coordinates of the pointer when the event occured
  69491. */
  69492. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  69493. }
  69494. /**
  69495. * This type contains all the data related to a pointer event in Babylon.js.
  69496. * 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.
  69497. */
  69498. export class PointerInfo extends PointerInfoBase {
  69499. /**
  69500. * Defines the picking info associated to the info (if any)\
  69501. */
  69502. pickInfo: Nullable<PickingInfo>;
  69503. /**
  69504. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  69505. * @param type Defines the type of event (PointerEventTypes)
  69506. * @param event Defines the related dom event
  69507. * @param pickInfo Defines the picking info associated to the info (if any)\
  69508. */
  69509. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  69510. /**
  69511. * Defines the picking info associated to the info (if any)\
  69512. */
  69513. pickInfo: Nullable<PickingInfo>);
  69514. }
  69515. /**
  69516. * Data relating to a touch event on the screen.
  69517. */
  69518. export interface PointerTouch {
  69519. /**
  69520. * X coordinate of touch.
  69521. */
  69522. x: number;
  69523. /**
  69524. * Y coordinate of touch.
  69525. */
  69526. y: number;
  69527. /**
  69528. * Id of touch. Unique for each finger.
  69529. */
  69530. pointerId: number;
  69531. /**
  69532. * Event type passed from DOM.
  69533. */
  69534. type: any;
  69535. }
  69536. }
  69537. declare module BABYLON {
  69538. /**
  69539. * Manage the mouse inputs to control the movement of a free camera.
  69540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69541. */
  69542. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  69543. /**
  69544. * Define if touch is enabled in the mouse input
  69545. */
  69546. touchEnabled: boolean;
  69547. /**
  69548. * Defines the camera the input is attached to.
  69549. */
  69550. camera: FreeCamera;
  69551. /**
  69552. * Defines the buttons associated with the input to handle camera move.
  69553. */
  69554. buttons: number[];
  69555. /**
  69556. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  69557. */
  69558. angularSensibility: number;
  69559. private _pointerInput;
  69560. private _onMouseMove;
  69561. private _observer;
  69562. private previousPosition;
  69563. /**
  69564. * Manage the mouse inputs to control the movement of a free camera.
  69565. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69566. * @param touchEnabled Defines if touch is enabled or not
  69567. */
  69568. constructor(
  69569. /**
  69570. * Define if touch is enabled in the mouse input
  69571. */
  69572. touchEnabled?: boolean);
  69573. /**
  69574. * Attach the input controls to a specific dom element to get the input from.
  69575. * @param element Defines the element the controls should be listened from
  69576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69577. */
  69578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69579. /**
  69580. * Called on JS contextmenu event.
  69581. * Override this method to provide functionality.
  69582. */
  69583. protected onContextMenu(evt: PointerEvent): void;
  69584. /**
  69585. * Detach the current controls from the specified dom element.
  69586. * @param element Defines the element to stop listening the inputs from
  69587. */
  69588. detachControl(element: Nullable<HTMLElement>): void;
  69589. /**
  69590. * Gets the class name of the current intput.
  69591. * @returns the class name
  69592. */
  69593. getClassName(): string;
  69594. /**
  69595. * Get the friendly name associated with the input class.
  69596. * @returns the input friendly name
  69597. */
  69598. getSimpleName(): string;
  69599. }
  69600. }
  69601. declare module BABYLON {
  69602. /**
  69603. * Manage the touch inputs to control the movement of a free camera.
  69604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69605. */
  69606. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  69607. /**
  69608. * Defines the camera the input is attached to.
  69609. */
  69610. camera: FreeCamera;
  69611. /**
  69612. * Defines the touch sensibility for rotation.
  69613. * The higher the faster.
  69614. */
  69615. touchAngularSensibility: number;
  69616. /**
  69617. * Defines the touch sensibility for move.
  69618. * The higher the faster.
  69619. */
  69620. touchMoveSensibility: number;
  69621. private _offsetX;
  69622. private _offsetY;
  69623. private _pointerPressed;
  69624. private _pointerInput;
  69625. private _observer;
  69626. private _onLostFocus;
  69627. /**
  69628. * Attach the input controls to a specific dom element to get the input from.
  69629. * @param element Defines the element the controls should be listened from
  69630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69631. */
  69632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69633. /**
  69634. * Detach the current controls from the specified dom element.
  69635. * @param element Defines the element to stop listening the inputs from
  69636. */
  69637. detachControl(element: Nullable<HTMLElement>): void;
  69638. /**
  69639. * Update the current camera state depending on the inputs that have been used this frame.
  69640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  69641. */
  69642. checkInputs(): void;
  69643. /**
  69644. * Gets the class name of the current intput.
  69645. * @returns the class name
  69646. */
  69647. getClassName(): string;
  69648. /**
  69649. * Get the friendly name associated with the input class.
  69650. * @returns the input friendly name
  69651. */
  69652. getSimpleName(): string;
  69653. }
  69654. }
  69655. declare module BABYLON {
  69656. /**
  69657. * Default Inputs manager for the FreeCamera.
  69658. * It groups all the default supported inputs for ease of use.
  69659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  69660. */
  69661. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  69662. /**
  69663. * Instantiates a new FreeCameraInputsManager.
  69664. * @param camera Defines the camera the inputs belong to
  69665. */
  69666. constructor(camera: FreeCamera);
  69667. /**
  69668. * Add keyboard input support to the input manager.
  69669. * @returns the current input manager
  69670. */
  69671. addKeyboard(): FreeCameraInputsManager;
  69672. /**
  69673. * Add mouse input support to the input manager.
  69674. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  69675. * @returns the current input manager
  69676. */
  69677. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  69678. /**
  69679. * Add touch input support to the input manager.
  69680. * @returns the current input manager
  69681. */
  69682. addTouch(): FreeCameraInputsManager;
  69683. }
  69684. }
  69685. declare module BABYLON {
  69686. /**
  69687. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69688. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  69689. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69690. */
  69691. export class FreeCamera extends TargetCamera {
  69692. /**
  69693. * Define the collision ellipsoid of the camera.
  69694. * This is helpful to simulate a camera body like the player body around the camera
  69695. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  69696. */
  69697. ellipsoid: Vector3;
  69698. /**
  69699. * Define an offset for the position of the ellipsoid around the camera.
  69700. * This can be helpful to determine the center of the body near the gravity center of the body
  69701. * instead of its head.
  69702. */
  69703. ellipsoidOffset: Vector3;
  69704. /**
  69705. * Enable or disable collisions of the camera with the rest of the scene objects.
  69706. */
  69707. checkCollisions: boolean;
  69708. /**
  69709. * Enable or disable gravity on the camera.
  69710. */
  69711. applyGravity: boolean;
  69712. /**
  69713. * Define the input manager associated to the camera.
  69714. */
  69715. inputs: FreeCameraInputsManager;
  69716. /**
  69717. * Gets the input sensibility for a mouse input. (default is 2000.0)
  69718. * Higher values reduce sensitivity.
  69719. */
  69720. /**
  69721. * Sets the input sensibility for a mouse input. (default is 2000.0)
  69722. * Higher values reduce sensitivity.
  69723. */
  69724. angularSensibility: number;
  69725. /**
  69726. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  69727. */
  69728. keysUp: number[];
  69729. /**
  69730. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  69731. */
  69732. keysDown: number[];
  69733. /**
  69734. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  69735. */
  69736. keysLeft: number[];
  69737. /**
  69738. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  69739. */
  69740. keysRight: number[];
  69741. /**
  69742. * Event raised when the camera collide with a mesh in the scene.
  69743. */
  69744. onCollide: (collidedMesh: AbstractMesh) => void;
  69745. private _collider;
  69746. private _needMoveForGravity;
  69747. private _oldPosition;
  69748. private _diffPosition;
  69749. private _newPosition;
  69750. /** @hidden */
  69751. _localDirection: Vector3;
  69752. /** @hidden */
  69753. _transformedDirection: Vector3;
  69754. /**
  69755. * Instantiates a Free Camera.
  69756. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  69757. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  69758. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  69759. * @param name Define the name of the camera in the scene
  69760. * @param position Define the start position of the camera in the scene
  69761. * @param scene Define the scene the camera belongs to
  69762. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  69763. */
  69764. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  69765. /**
  69766. * Attached controls to the current camera.
  69767. * @param element Defines the element the controls should be listened from
  69768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  69769. */
  69770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  69771. /**
  69772. * Detach the current controls from the camera.
  69773. * The camera will stop reacting to inputs.
  69774. * @param element Defines the element to stop listening the inputs from
  69775. */
  69776. detachControl(element: HTMLElement): void;
  69777. private _collisionMask;
  69778. /**
  69779. * Define a collision mask to limit the list of object the camera can collide with
  69780. */
  69781. collisionMask: number;
  69782. /** @hidden */
  69783. _collideWithWorld(displacement: Vector3): void;
  69784. private _onCollisionPositionChange;
  69785. /** @hidden */
  69786. _checkInputs(): void;
  69787. /** @hidden */
  69788. _decideIfNeedsToMove(): boolean;
  69789. /** @hidden */
  69790. _updatePosition(): void;
  69791. /**
  69792. * Destroy the camera and release the current resources hold by it.
  69793. */
  69794. dispose(): void;
  69795. /**
  69796. * Gets the current object class name.
  69797. * @return the class name
  69798. */
  69799. getClassName(): string;
  69800. }
  69801. }
  69802. declare module BABYLON {
  69803. /**
  69804. * Represents a gamepad control stick position
  69805. */
  69806. export class StickValues {
  69807. /**
  69808. * The x component of the control stick
  69809. */
  69810. x: number;
  69811. /**
  69812. * The y component of the control stick
  69813. */
  69814. y: number;
  69815. /**
  69816. * Initializes the gamepad x and y control stick values
  69817. * @param x The x component of the gamepad control stick value
  69818. * @param y The y component of the gamepad control stick value
  69819. */
  69820. constructor(
  69821. /**
  69822. * The x component of the control stick
  69823. */
  69824. x: number,
  69825. /**
  69826. * The y component of the control stick
  69827. */
  69828. y: number);
  69829. }
  69830. /**
  69831. * An interface which manages callbacks for gamepad button changes
  69832. */
  69833. export interface GamepadButtonChanges {
  69834. /**
  69835. * Called when a gamepad has been changed
  69836. */
  69837. changed: boolean;
  69838. /**
  69839. * Called when a gamepad press event has been triggered
  69840. */
  69841. pressChanged: boolean;
  69842. /**
  69843. * Called when a touch event has been triggered
  69844. */
  69845. touchChanged: boolean;
  69846. /**
  69847. * Called when a value has changed
  69848. */
  69849. valueChanged: boolean;
  69850. }
  69851. /**
  69852. * Represents a gamepad
  69853. */
  69854. export class Gamepad {
  69855. /**
  69856. * The id of the gamepad
  69857. */
  69858. id: string;
  69859. /**
  69860. * The index of the gamepad
  69861. */
  69862. index: number;
  69863. /**
  69864. * The browser gamepad
  69865. */
  69866. browserGamepad: any;
  69867. /**
  69868. * Specifies what type of gamepad this represents
  69869. */
  69870. type: number;
  69871. private _leftStick;
  69872. private _rightStick;
  69873. /** @hidden */
  69874. _isConnected: boolean;
  69875. private _leftStickAxisX;
  69876. private _leftStickAxisY;
  69877. private _rightStickAxisX;
  69878. private _rightStickAxisY;
  69879. /**
  69880. * Triggered when the left control stick has been changed
  69881. */
  69882. private _onleftstickchanged;
  69883. /**
  69884. * Triggered when the right control stick has been changed
  69885. */
  69886. private _onrightstickchanged;
  69887. /**
  69888. * Represents a gamepad controller
  69889. */
  69890. static GAMEPAD: number;
  69891. /**
  69892. * Represents a generic controller
  69893. */
  69894. static GENERIC: number;
  69895. /**
  69896. * Represents an XBox controller
  69897. */
  69898. static XBOX: number;
  69899. /**
  69900. * Represents a pose-enabled controller
  69901. */
  69902. static POSE_ENABLED: number;
  69903. /**
  69904. * Specifies whether the left control stick should be Y-inverted
  69905. */
  69906. protected _invertLeftStickY: boolean;
  69907. /**
  69908. * Specifies if the gamepad has been connected
  69909. */
  69910. readonly isConnected: boolean;
  69911. /**
  69912. * Initializes the gamepad
  69913. * @param id The id of the gamepad
  69914. * @param index The index of the gamepad
  69915. * @param browserGamepad The browser gamepad
  69916. * @param leftStickX The x component of the left joystick
  69917. * @param leftStickY The y component of the left joystick
  69918. * @param rightStickX The x component of the right joystick
  69919. * @param rightStickY The y component of the right joystick
  69920. */
  69921. constructor(
  69922. /**
  69923. * The id of the gamepad
  69924. */
  69925. id: string,
  69926. /**
  69927. * The index of the gamepad
  69928. */
  69929. index: number,
  69930. /**
  69931. * The browser gamepad
  69932. */
  69933. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  69934. /**
  69935. * Callback triggered when the left joystick has changed
  69936. * @param callback
  69937. */
  69938. onleftstickchanged(callback: (values: StickValues) => void): void;
  69939. /**
  69940. * Callback triggered when the right joystick has changed
  69941. * @param callback
  69942. */
  69943. onrightstickchanged(callback: (values: StickValues) => void): void;
  69944. /**
  69945. * Gets the left joystick
  69946. */
  69947. /**
  69948. * Sets the left joystick values
  69949. */
  69950. leftStick: StickValues;
  69951. /**
  69952. * Gets the right joystick
  69953. */
  69954. /**
  69955. * Sets the right joystick value
  69956. */
  69957. rightStick: StickValues;
  69958. /**
  69959. * Updates the gamepad joystick positions
  69960. */
  69961. update(): void;
  69962. /**
  69963. * Disposes the gamepad
  69964. */
  69965. dispose(): void;
  69966. }
  69967. /**
  69968. * Represents a generic gamepad
  69969. */
  69970. export class GenericPad extends Gamepad {
  69971. private _buttons;
  69972. private _onbuttondown;
  69973. private _onbuttonup;
  69974. /**
  69975. * Observable triggered when a button has been pressed
  69976. */
  69977. onButtonDownObservable: Observable<number>;
  69978. /**
  69979. * Observable triggered when a button has been released
  69980. */
  69981. onButtonUpObservable: Observable<number>;
  69982. /**
  69983. * Callback triggered when a button has been pressed
  69984. * @param callback Called when a button has been pressed
  69985. */
  69986. onbuttondown(callback: (buttonPressed: number) => void): void;
  69987. /**
  69988. * Callback triggered when a button has been released
  69989. * @param callback Called when a button has been released
  69990. */
  69991. onbuttonup(callback: (buttonReleased: number) => void): void;
  69992. /**
  69993. * Initializes the generic gamepad
  69994. * @param id The id of the generic gamepad
  69995. * @param index The index of the generic gamepad
  69996. * @param browserGamepad The browser gamepad
  69997. */
  69998. constructor(id: string, index: number, browserGamepad: any);
  69999. private _setButtonValue;
  70000. /**
  70001. * Updates the generic gamepad
  70002. */
  70003. update(): void;
  70004. /**
  70005. * Disposes the generic gamepad
  70006. */
  70007. dispose(): void;
  70008. }
  70009. }
  70010. declare module BABYLON {
  70011. /**
  70012. * Defines the types of pose enabled controllers that are supported
  70013. */
  70014. export enum PoseEnabledControllerType {
  70015. /**
  70016. * HTC Vive
  70017. */
  70018. VIVE = 0,
  70019. /**
  70020. * Oculus Rift
  70021. */
  70022. OCULUS = 1,
  70023. /**
  70024. * Windows mixed reality
  70025. */
  70026. WINDOWS = 2,
  70027. /**
  70028. * Samsung gear VR
  70029. */
  70030. GEAR_VR = 3,
  70031. /**
  70032. * Google Daydream
  70033. */
  70034. DAYDREAM = 4,
  70035. /**
  70036. * Generic
  70037. */
  70038. GENERIC = 5
  70039. }
  70040. /**
  70041. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70042. */
  70043. export interface MutableGamepadButton {
  70044. /**
  70045. * Value of the button/trigger
  70046. */
  70047. value: number;
  70048. /**
  70049. * If the button/trigger is currently touched
  70050. */
  70051. touched: boolean;
  70052. /**
  70053. * If the button/trigger is currently pressed
  70054. */
  70055. pressed: boolean;
  70056. }
  70057. /**
  70058. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70059. * @hidden
  70060. */
  70061. export interface ExtendedGamepadButton extends GamepadButton {
  70062. /**
  70063. * If the button/trigger is currently pressed
  70064. */
  70065. readonly pressed: boolean;
  70066. /**
  70067. * If the button/trigger is currently touched
  70068. */
  70069. readonly touched: boolean;
  70070. /**
  70071. * Value of the button/trigger
  70072. */
  70073. readonly value: number;
  70074. }
  70075. /** @hidden */
  70076. export interface _GamePadFactory {
  70077. /**
  70078. * Returns wether or not the current gamepad can be created for this type of controller.
  70079. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70080. * @returns true if it can be created, otherwise false
  70081. */
  70082. canCreate(gamepadInfo: any): boolean;
  70083. /**
  70084. * Creates a new instance of the Gamepad.
  70085. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70086. * @returns the new gamepad instance
  70087. */
  70088. create(gamepadInfo: any): Gamepad;
  70089. }
  70090. /**
  70091. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70092. */
  70093. export class PoseEnabledControllerHelper {
  70094. /** @hidden */
  70095. static _ControllerFactories: _GamePadFactory[];
  70096. /** @hidden */
  70097. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70098. /**
  70099. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70100. * @param vrGamepad the gamepad to initialized
  70101. * @returns a vr controller of the type the gamepad identified as
  70102. */
  70103. static InitiateController(vrGamepad: any): Gamepad;
  70104. }
  70105. /**
  70106. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70107. */
  70108. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70109. private _deviceRoomPosition;
  70110. private _deviceRoomRotationQuaternion;
  70111. /**
  70112. * The device position in babylon space
  70113. */
  70114. devicePosition: Vector3;
  70115. /**
  70116. * The device rotation in babylon space
  70117. */
  70118. deviceRotationQuaternion: Quaternion;
  70119. /**
  70120. * The scale factor of the device in babylon space
  70121. */
  70122. deviceScaleFactor: number;
  70123. /**
  70124. * (Likely devicePosition should be used instead) The device position in its room space
  70125. */
  70126. position: Vector3;
  70127. /**
  70128. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70129. */
  70130. rotationQuaternion: Quaternion;
  70131. /**
  70132. * The type of controller (Eg. Windows mixed reality)
  70133. */
  70134. controllerType: PoseEnabledControllerType;
  70135. protected _calculatedPosition: Vector3;
  70136. private _calculatedRotation;
  70137. /**
  70138. * The raw pose from the device
  70139. */
  70140. rawPose: DevicePose;
  70141. private _trackPosition;
  70142. private _maxRotationDistFromHeadset;
  70143. private _draggedRoomRotation;
  70144. /**
  70145. * @hidden
  70146. */
  70147. _disableTrackPosition(fixedPosition: Vector3): void;
  70148. /**
  70149. * Internal, the mesh attached to the controller
  70150. * @hidden
  70151. */
  70152. _mesh: Nullable<AbstractMesh>;
  70153. private _poseControlledCamera;
  70154. private _leftHandSystemQuaternion;
  70155. /**
  70156. * Internal, matrix used to convert room space to babylon space
  70157. * @hidden
  70158. */
  70159. _deviceToWorld: Matrix;
  70160. /**
  70161. * Node to be used when casting a ray from the controller
  70162. * @hidden
  70163. */
  70164. _pointingPoseNode: Nullable<TransformNode>;
  70165. /**
  70166. * Name of the child mesh that can be used to cast a ray from the controller
  70167. */
  70168. static readonly POINTING_POSE: string;
  70169. /**
  70170. * Creates a new PoseEnabledController from a gamepad
  70171. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  70172. */
  70173. constructor(browserGamepad: any);
  70174. private _workingMatrix;
  70175. /**
  70176. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  70177. */
  70178. update(): void;
  70179. /**
  70180. * Updates only the pose device and mesh without doing any button event checking
  70181. */
  70182. protected _updatePoseAndMesh(): void;
  70183. /**
  70184. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  70185. * @param poseData raw pose fromthe device
  70186. */
  70187. updateFromDevice(poseData: DevicePose): void;
  70188. /**
  70189. * @hidden
  70190. */
  70191. _meshAttachedObservable: Observable<AbstractMesh>;
  70192. /**
  70193. * Attaches a mesh to the controller
  70194. * @param mesh the mesh to be attached
  70195. */
  70196. attachToMesh(mesh: AbstractMesh): void;
  70197. /**
  70198. * Attaches the controllers mesh to a camera
  70199. * @param camera the camera the mesh should be attached to
  70200. */
  70201. attachToPoseControlledCamera(camera: TargetCamera): void;
  70202. /**
  70203. * Disposes of the controller
  70204. */
  70205. dispose(): void;
  70206. /**
  70207. * The mesh that is attached to the controller
  70208. */
  70209. readonly mesh: Nullable<AbstractMesh>;
  70210. /**
  70211. * Gets the ray of the controller in the direction the controller is pointing
  70212. * @param length the length the resulting ray should be
  70213. * @returns a ray in the direction the controller is pointing
  70214. */
  70215. getForwardRay(length?: number): Ray;
  70216. }
  70217. }
  70218. declare module BABYLON {
  70219. /**
  70220. * Defines the WebVRController object that represents controllers tracked in 3D space
  70221. */
  70222. export abstract class WebVRController extends PoseEnabledController {
  70223. /**
  70224. * Internal, the default controller model for the controller
  70225. */
  70226. protected _defaultModel: AbstractMesh;
  70227. /**
  70228. * Fired when the trigger state has changed
  70229. */
  70230. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  70231. /**
  70232. * Fired when the main button state has changed
  70233. */
  70234. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70235. /**
  70236. * Fired when the secondary button state has changed
  70237. */
  70238. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  70239. /**
  70240. * Fired when the pad state has changed
  70241. */
  70242. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  70243. /**
  70244. * Fired when controllers stick values have changed
  70245. */
  70246. onPadValuesChangedObservable: Observable<StickValues>;
  70247. /**
  70248. * Array of button availible on the controller
  70249. */
  70250. protected _buttons: Array<MutableGamepadButton>;
  70251. private _onButtonStateChange;
  70252. /**
  70253. * Fired when a controller button's state has changed
  70254. * @param callback the callback containing the button that was modified
  70255. */
  70256. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  70257. /**
  70258. * X and Y axis corrisponding to the controllers joystick
  70259. */
  70260. pad: StickValues;
  70261. /**
  70262. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  70263. */
  70264. hand: string;
  70265. /**
  70266. * The default controller model for the controller
  70267. */
  70268. readonly defaultModel: AbstractMesh;
  70269. /**
  70270. * Creates a new WebVRController from a gamepad
  70271. * @param vrGamepad the gamepad that the WebVRController should be created from
  70272. */
  70273. constructor(vrGamepad: any);
  70274. /**
  70275. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  70276. */
  70277. update(): void;
  70278. /**
  70279. * Function to be called when a button is modified
  70280. */
  70281. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  70282. /**
  70283. * Loads a mesh and attaches it to the controller
  70284. * @param scene the scene the mesh should be added to
  70285. * @param meshLoaded callback for when the mesh has been loaded
  70286. */
  70287. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  70288. private _setButtonValue;
  70289. private _changes;
  70290. private _checkChanges;
  70291. /**
  70292. * Disposes of th webVRCOntroller
  70293. */
  70294. dispose(): void;
  70295. }
  70296. }
  70297. declare module BABYLON {
  70298. /**
  70299. * The HemisphericLight simulates the ambient environment light,
  70300. * so the passed direction is the light reflection direction, not the incoming direction.
  70301. */
  70302. export class HemisphericLight extends Light {
  70303. /**
  70304. * The groundColor is the light in the opposite direction to the one specified during creation.
  70305. * 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.
  70306. */
  70307. groundColor: Color3;
  70308. /**
  70309. * The light reflection direction, not the incoming direction.
  70310. */
  70311. direction: Vector3;
  70312. /**
  70313. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  70314. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  70315. * The HemisphericLight can't cast shadows.
  70316. * Documentation : https://doc.babylonjs.com/babylon101/lights
  70317. * @param name The friendly name of the light
  70318. * @param direction The direction of the light reflection
  70319. * @param scene The scene the light belongs to
  70320. */
  70321. constructor(name: string, direction: Vector3, scene: Scene);
  70322. protected _buildUniformLayout(): void;
  70323. /**
  70324. * Returns the string "HemisphericLight".
  70325. * @return The class name
  70326. */
  70327. getClassName(): string;
  70328. /**
  70329. * Sets the HemisphericLight direction towards the passed target (Vector3).
  70330. * Returns the updated direction.
  70331. * @param target The target the direction should point to
  70332. * @return The computed direction
  70333. */
  70334. setDirectionToTarget(target: Vector3): Vector3;
  70335. /**
  70336. * Returns the shadow generator associated to the light.
  70337. * @returns Always null for hemispheric lights because it does not support shadows.
  70338. */
  70339. getShadowGenerator(): Nullable<IShadowGenerator>;
  70340. /**
  70341. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  70342. * @param effect The effect to update
  70343. * @param lightIndex The index of the light in the effect to update
  70344. * @returns The hemispheric light
  70345. */
  70346. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  70347. /**
  70348. * Computes the world matrix of the node
  70349. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70350. * @param useWasUpdatedFlag defines a reserved property
  70351. * @returns the world matrix
  70352. */
  70353. computeWorldMatrix(): Matrix;
  70354. /**
  70355. * Returns the integer 3.
  70356. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  70357. */
  70358. getTypeID(): number;
  70359. /**
  70360. * Prepares the list of defines specific to the light type.
  70361. * @param defines the list of defines
  70362. * @param lightIndex defines the index of the light for the effect
  70363. */
  70364. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  70365. }
  70366. }
  70367. declare module BABYLON {
  70368. /**
  70369. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  70370. * IMPORTANT!! The data is right-hand data.
  70371. * @export
  70372. * @interface DevicePose
  70373. */
  70374. export interface DevicePose {
  70375. /**
  70376. * The position of the device, values in array are [x,y,z].
  70377. */
  70378. readonly position: Nullable<Float32Array>;
  70379. /**
  70380. * The linearVelocity of the device, values in array are [x,y,z].
  70381. */
  70382. readonly linearVelocity: Nullable<Float32Array>;
  70383. /**
  70384. * The linearAcceleration of the device, values in array are [x,y,z].
  70385. */
  70386. readonly linearAcceleration: Nullable<Float32Array>;
  70387. /**
  70388. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  70389. */
  70390. readonly orientation: Nullable<Float32Array>;
  70391. /**
  70392. * The angularVelocity of the device, values in array are [x,y,z].
  70393. */
  70394. readonly angularVelocity: Nullable<Float32Array>;
  70395. /**
  70396. * The angularAcceleration of the device, values in array are [x,y,z].
  70397. */
  70398. readonly angularAcceleration: Nullable<Float32Array>;
  70399. }
  70400. /**
  70401. * Interface representing a pose controlled object in Babylon.
  70402. * A pose controlled object has both regular pose values as well as pose values
  70403. * from an external device such as a VR head mounted display
  70404. */
  70405. export interface PoseControlled {
  70406. /**
  70407. * The position of the object in babylon space.
  70408. */
  70409. position: Vector3;
  70410. /**
  70411. * The rotation quaternion of the object in babylon space.
  70412. */
  70413. rotationQuaternion: Quaternion;
  70414. /**
  70415. * The position of the device in babylon space.
  70416. */
  70417. devicePosition?: Vector3;
  70418. /**
  70419. * The rotation quaternion of the device in babylon space.
  70420. */
  70421. deviceRotationQuaternion: Quaternion;
  70422. /**
  70423. * The raw pose coming from the device.
  70424. */
  70425. rawPose: Nullable<DevicePose>;
  70426. /**
  70427. * The scale of the device to be used when translating from device space to babylon space.
  70428. */
  70429. deviceScaleFactor: number;
  70430. /**
  70431. * Updates the poseControlled values based on the input device pose.
  70432. * @param poseData the pose data to update the object with
  70433. */
  70434. updateFromDevice(poseData: DevicePose): void;
  70435. }
  70436. /**
  70437. * Set of options to customize the webVRCamera
  70438. */
  70439. export interface WebVROptions {
  70440. /**
  70441. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  70442. */
  70443. trackPosition?: boolean;
  70444. /**
  70445. * Sets the scale of the vrDevice in babylon space. (default: 1)
  70446. */
  70447. positionScale?: number;
  70448. /**
  70449. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  70450. */
  70451. displayName?: string;
  70452. /**
  70453. * Should the native controller meshes be initialized. (default: true)
  70454. */
  70455. controllerMeshes?: boolean;
  70456. /**
  70457. * Creating a default HemiLight only on controllers. (default: true)
  70458. */
  70459. defaultLightingOnControllers?: boolean;
  70460. /**
  70461. * If you don't want to use the default VR button of the helper. (default: false)
  70462. */
  70463. useCustomVRButton?: boolean;
  70464. /**
  70465. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  70466. */
  70467. customVRButton?: HTMLButtonElement;
  70468. /**
  70469. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  70470. */
  70471. rayLength?: number;
  70472. /**
  70473. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  70474. */
  70475. defaultHeight?: number;
  70476. }
  70477. /**
  70478. * This represents a WebVR camera.
  70479. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  70480. * @example http://doc.babylonjs.com/how_to/webvr_camera
  70481. */
  70482. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  70483. private webVROptions;
  70484. /**
  70485. * @hidden
  70486. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  70487. */
  70488. _vrDevice: any;
  70489. /**
  70490. * The rawPose of the vrDevice.
  70491. */
  70492. rawPose: Nullable<DevicePose>;
  70493. private _onVREnabled;
  70494. private _specsVersion;
  70495. private _attached;
  70496. private _frameData;
  70497. protected _descendants: Array<Node>;
  70498. private _deviceRoomPosition;
  70499. /** @hidden */
  70500. _deviceRoomRotationQuaternion: Quaternion;
  70501. private _standingMatrix;
  70502. /**
  70503. * Represents device position in babylon space.
  70504. */
  70505. devicePosition: Vector3;
  70506. /**
  70507. * Represents device rotation in babylon space.
  70508. */
  70509. deviceRotationQuaternion: Quaternion;
  70510. /**
  70511. * The scale of the device to be used when translating from device space to babylon space.
  70512. */
  70513. deviceScaleFactor: number;
  70514. private _deviceToWorld;
  70515. private _worldToDevice;
  70516. /**
  70517. * References to the webVR controllers for the vrDevice.
  70518. */
  70519. controllers: Array<WebVRController>;
  70520. /**
  70521. * Emits an event when a controller is attached.
  70522. */
  70523. onControllersAttachedObservable: Observable<WebVRController[]>;
  70524. /**
  70525. * Emits an event when a controller's mesh has been loaded;
  70526. */
  70527. onControllerMeshLoadedObservable: Observable<WebVRController>;
  70528. /**
  70529. * Emits an event when the HMD's pose has been updated.
  70530. */
  70531. onPoseUpdatedFromDeviceObservable: Observable<any>;
  70532. private _poseSet;
  70533. /**
  70534. * If the rig cameras be used as parent instead of this camera.
  70535. */
  70536. rigParenting: boolean;
  70537. private _lightOnControllers;
  70538. private _defaultHeight?;
  70539. /**
  70540. * Instantiates a WebVRFreeCamera.
  70541. * @param name The name of the WebVRFreeCamera
  70542. * @param position The starting anchor position for the camera
  70543. * @param scene The scene the camera belongs to
  70544. * @param webVROptions a set of customizable options for the webVRCamera
  70545. */
  70546. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  70547. /**
  70548. * Gets the device distance from the ground in meters.
  70549. * @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.
  70550. */
  70551. deviceDistanceToRoomGround(): number;
  70552. /**
  70553. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70554. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  70555. */
  70556. useStandingMatrix(callback?: (bool: boolean) => void): void;
  70557. /**
  70558. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  70559. * @returns A promise with a boolean set to if the standing matrix is supported.
  70560. */
  70561. useStandingMatrixAsync(): Promise<boolean>;
  70562. /**
  70563. * Disposes the camera
  70564. */
  70565. dispose(): void;
  70566. /**
  70567. * Gets a vrController by name.
  70568. * @param name The name of the controller to retreive
  70569. * @returns the controller matching the name specified or null if not found
  70570. */
  70571. getControllerByName(name: string): Nullable<WebVRController>;
  70572. private _leftController;
  70573. /**
  70574. * The controller corrisponding to the users left hand.
  70575. */
  70576. readonly leftController: Nullable<WebVRController>;
  70577. private _rightController;
  70578. /**
  70579. * The controller corrisponding to the users right hand.
  70580. */
  70581. readonly rightController: Nullable<WebVRController>;
  70582. /**
  70583. * Casts a ray forward from the vrCamera's gaze.
  70584. * @param length Length of the ray (default: 100)
  70585. * @returns the ray corrisponding to the gaze
  70586. */
  70587. getForwardRay(length?: number): Ray;
  70588. /**
  70589. * @hidden
  70590. * Updates the camera based on device's frame data
  70591. */
  70592. _checkInputs(): void;
  70593. /**
  70594. * Updates the poseControlled values based on the input device pose.
  70595. * @param poseData Pose coming from the device
  70596. */
  70597. updateFromDevice(poseData: DevicePose): void;
  70598. private _htmlElementAttached;
  70599. private _detachIfAttached;
  70600. /**
  70601. * WebVR's attach control will start broadcasting frames to the device.
  70602. * Note that in certain browsers (chrome for example) this function must be called
  70603. * within a user-interaction callback. Example:
  70604. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  70605. *
  70606. * @param element html element to attach the vrDevice to
  70607. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  70608. */
  70609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70610. /**
  70611. * Detaches the camera from the html element and disables VR
  70612. *
  70613. * @param element html element to detach from
  70614. */
  70615. detachControl(element: HTMLElement): void;
  70616. /**
  70617. * @returns the name of this class
  70618. */
  70619. getClassName(): string;
  70620. /**
  70621. * Calls resetPose on the vrDisplay
  70622. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  70623. */
  70624. resetToCurrentRotation(): void;
  70625. /**
  70626. * @hidden
  70627. * Updates the rig cameras (left and right eye)
  70628. */
  70629. _updateRigCameras(): void;
  70630. private _workingVector;
  70631. private _oneVector;
  70632. private _workingMatrix;
  70633. private updateCacheCalled;
  70634. private _correctPositionIfNotTrackPosition;
  70635. /**
  70636. * @hidden
  70637. * Updates the cached values of the camera
  70638. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  70639. */
  70640. _updateCache(ignoreParentClass?: boolean): void;
  70641. /**
  70642. * @hidden
  70643. * Get current device position in babylon world
  70644. */
  70645. _computeDevicePosition(): void;
  70646. /**
  70647. * Updates the current device position and rotation in the babylon world
  70648. */
  70649. update(): void;
  70650. /**
  70651. * @hidden
  70652. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  70653. * @returns an identity matrix
  70654. */
  70655. _getViewMatrix(): Matrix;
  70656. private _tmpMatrix;
  70657. /**
  70658. * This function is called by the two RIG cameras.
  70659. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  70660. * @hidden
  70661. */
  70662. _getWebVRViewMatrix(): Matrix;
  70663. /** @hidden */
  70664. _getWebVRProjectionMatrix(): Matrix;
  70665. private _onGamepadConnectedObserver;
  70666. private _onGamepadDisconnectedObserver;
  70667. private _updateCacheWhenTrackingDisabledObserver;
  70668. /**
  70669. * Initializes the controllers and their meshes
  70670. */
  70671. initControllers(): void;
  70672. }
  70673. }
  70674. declare module BABYLON {
  70675. /**
  70676. * Size options for a post process
  70677. */
  70678. export type PostProcessOptions = {
  70679. width: number;
  70680. height: number;
  70681. };
  70682. /**
  70683. * PostProcess can be used to apply a shader to a texture after it has been rendered
  70684. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70685. */
  70686. export class PostProcess {
  70687. /** Name of the PostProcess. */
  70688. name: string;
  70689. /**
  70690. * Gets or sets the unique id of the post process
  70691. */
  70692. uniqueId: number;
  70693. /**
  70694. * Width of the texture to apply the post process on
  70695. */
  70696. width: number;
  70697. /**
  70698. * Height of the texture to apply the post process on
  70699. */
  70700. height: number;
  70701. /**
  70702. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  70703. * @hidden
  70704. */
  70705. _outputTexture: Nullable<InternalTexture>;
  70706. /**
  70707. * Sampling mode used by the shader
  70708. * See https://doc.babylonjs.com/classes/3.1/texture
  70709. */
  70710. renderTargetSamplingMode: number;
  70711. /**
  70712. * Clear color to use when screen clearing
  70713. */
  70714. clearColor: Color4;
  70715. /**
  70716. * If the buffer needs to be cleared before applying the post process. (default: true)
  70717. * Should be set to false if shader will overwrite all previous pixels.
  70718. */
  70719. autoClear: boolean;
  70720. /**
  70721. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  70722. */
  70723. alphaMode: number;
  70724. /**
  70725. * Sets the setAlphaBlendConstants of the babylon engine
  70726. */
  70727. alphaConstants: Color4;
  70728. /**
  70729. * Animations to be used for the post processing
  70730. */
  70731. animations: Animation[];
  70732. /**
  70733. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  70734. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  70735. */
  70736. enablePixelPerfectMode: boolean;
  70737. /**
  70738. * Force the postprocess to be applied without taking in account viewport
  70739. */
  70740. forceFullscreenViewport: boolean;
  70741. /**
  70742. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  70743. *
  70744. * | Value | Type | Description |
  70745. * | ----- | ----------------------------------- | ----------- |
  70746. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  70747. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  70748. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  70749. *
  70750. */
  70751. scaleMode: number;
  70752. /**
  70753. * Force textures to be a power of two (default: false)
  70754. */
  70755. alwaysForcePOT: boolean;
  70756. private _samples;
  70757. /**
  70758. * Number of sample textures (default: 1)
  70759. */
  70760. samples: number;
  70761. /**
  70762. * Modify the scale of the post process to be the same as the viewport (default: false)
  70763. */
  70764. adaptScaleToCurrentViewport: boolean;
  70765. private _camera;
  70766. private _scene;
  70767. private _engine;
  70768. private _options;
  70769. private _reusable;
  70770. private _textureType;
  70771. /**
  70772. * Smart array of input and output textures for the post process.
  70773. * @hidden
  70774. */
  70775. _textures: SmartArray<InternalTexture>;
  70776. /**
  70777. * The index in _textures that corresponds to the output texture.
  70778. * @hidden
  70779. */
  70780. _currentRenderTextureInd: number;
  70781. private _effect;
  70782. private _samplers;
  70783. private _fragmentUrl;
  70784. private _vertexUrl;
  70785. private _parameters;
  70786. private _scaleRatio;
  70787. protected _indexParameters: any;
  70788. private _shareOutputWithPostProcess;
  70789. private _texelSize;
  70790. private _forcedOutputTexture;
  70791. /**
  70792. * Returns the fragment url or shader name used in the post process.
  70793. * @returns the fragment url or name in the shader store.
  70794. */
  70795. getEffectName(): string;
  70796. /**
  70797. * An event triggered when the postprocess is activated.
  70798. */
  70799. onActivateObservable: Observable<Camera>;
  70800. private _onActivateObserver;
  70801. /**
  70802. * A function that is added to the onActivateObservable
  70803. */
  70804. onActivate: Nullable<(camera: Camera) => void>;
  70805. /**
  70806. * An event triggered when the postprocess changes its size.
  70807. */
  70808. onSizeChangedObservable: Observable<PostProcess>;
  70809. private _onSizeChangedObserver;
  70810. /**
  70811. * A function that is added to the onSizeChangedObservable
  70812. */
  70813. onSizeChanged: (postProcess: PostProcess) => void;
  70814. /**
  70815. * An event triggered when the postprocess applies its effect.
  70816. */
  70817. onApplyObservable: Observable<Effect>;
  70818. private _onApplyObserver;
  70819. /**
  70820. * A function that is added to the onApplyObservable
  70821. */
  70822. onApply: (effect: Effect) => void;
  70823. /**
  70824. * An event triggered before rendering the postprocess
  70825. */
  70826. onBeforeRenderObservable: Observable<Effect>;
  70827. private _onBeforeRenderObserver;
  70828. /**
  70829. * A function that is added to the onBeforeRenderObservable
  70830. */
  70831. onBeforeRender: (effect: Effect) => void;
  70832. /**
  70833. * An event triggered after rendering the postprocess
  70834. */
  70835. onAfterRenderObservable: Observable<Effect>;
  70836. private _onAfterRenderObserver;
  70837. /**
  70838. * A function that is added to the onAfterRenderObservable
  70839. */
  70840. onAfterRender: (efect: Effect) => void;
  70841. /**
  70842. * 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
  70843. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  70844. */
  70845. inputTexture: InternalTexture;
  70846. /**
  70847. * Gets the camera which post process is applied to.
  70848. * @returns The camera the post process is applied to.
  70849. */
  70850. getCamera(): Camera;
  70851. /**
  70852. * Gets the texel size of the postprocess.
  70853. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  70854. */
  70855. readonly texelSize: Vector2;
  70856. /**
  70857. * Creates a new instance PostProcess
  70858. * @param name The name of the PostProcess.
  70859. * @param fragmentUrl The url of the fragment shader to be used.
  70860. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  70861. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  70862. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  70863. * @param camera The camera to apply the render pass to.
  70864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70865. * @param engine The engine which the post process will be applied. (default: current engine)
  70866. * @param reusable If the post process can be reused on the same frame. (default: false)
  70867. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  70868. * @param textureType Type of textures used when performing the post process. (default: 0)
  70869. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  70870. * @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
  70871. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  70872. */
  70873. constructor(
  70874. /** Name of the PostProcess. */
  70875. 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);
  70876. /**
  70877. * Gets a string idenfifying the name of the class
  70878. * @returns "PostProcess" string
  70879. */
  70880. getClassName(): string;
  70881. /**
  70882. * Gets the engine which this post process belongs to.
  70883. * @returns The engine the post process was enabled with.
  70884. */
  70885. getEngine(): Engine;
  70886. /**
  70887. * The effect that is created when initializing the post process.
  70888. * @returns The created effect corrisponding the the postprocess.
  70889. */
  70890. getEffect(): Effect;
  70891. /**
  70892. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  70893. * @param postProcess The post process to share the output with.
  70894. * @returns This post process.
  70895. */
  70896. shareOutputWith(postProcess: PostProcess): PostProcess;
  70897. /**
  70898. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  70899. * This should be called if the post process that shares output with this post process is disabled/disposed.
  70900. */
  70901. useOwnOutput(): void;
  70902. /**
  70903. * Updates the effect with the current post process compile time values and recompiles the shader.
  70904. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70905. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70906. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70907. * @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
  70908. * @param onCompiled Called when the shader has been compiled.
  70909. * @param onError Called if there is an error when compiling a shader.
  70910. */
  70911. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70912. /**
  70913. * The post process is reusable if it can be used multiple times within one frame.
  70914. * @returns If the post process is reusable
  70915. */
  70916. isReusable(): boolean;
  70917. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  70918. markTextureDirty(): void;
  70919. /**
  70920. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  70921. * 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.
  70922. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  70923. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  70924. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  70925. * @returns The target texture that was bound to be written to.
  70926. */
  70927. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  70928. /**
  70929. * If the post process is supported.
  70930. */
  70931. readonly isSupported: boolean;
  70932. /**
  70933. * The aspect ratio of the output texture.
  70934. */
  70935. readonly aspectRatio: number;
  70936. /**
  70937. * Get a value indicating if the post-process is ready to be used
  70938. * @returns true if the post-process is ready (shader is compiled)
  70939. */
  70940. isReady(): boolean;
  70941. /**
  70942. * Binds all textures and uniforms to the shader, this will be run on every pass.
  70943. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  70944. */
  70945. apply(): Nullable<Effect>;
  70946. private _disposeTextures;
  70947. /**
  70948. * Disposes the post process.
  70949. * @param camera The camera to dispose the post process on.
  70950. */
  70951. dispose(camera?: Camera): void;
  70952. }
  70953. }
  70954. declare module BABYLON {
  70955. /**
  70956. * PostProcessManager is used to manage one or more post processes or post process pipelines
  70957. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70958. */
  70959. export class PostProcessManager {
  70960. private _scene;
  70961. private _indexBuffer;
  70962. private _vertexBuffers;
  70963. /**
  70964. * Creates a new instance PostProcess
  70965. * @param scene The scene that the post process is associated with.
  70966. */
  70967. constructor(scene: Scene);
  70968. private _prepareBuffers;
  70969. private _buildIndexBuffer;
  70970. /**
  70971. * Rebuilds the vertex buffers of the manager.
  70972. * @hidden
  70973. */
  70974. _rebuild(): void;
  70975. /**
  70976. * Prepares a frame to be run through a post process.
  70977. * @param sourceTexture The input texture to the post procesess. (default: null)
  70978. * @param postProcesses An array of post processes to be run. (default: null)
  70979. * @returns True if the post processes were able to be run.
  70980. * @hidden
  70981. */
  70982. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  70983. /**
  70984. * Manually render a set of post processes to a texture.
  70985. * @param postProcesses An array of post processes to be run.
  70986. * @param targetTexture The target texture to render to.
  70987. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  70988. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  70989. * @param lodLevel defines which lod of the texture to render to
  70990. */
  70991. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  70992. /**
  70993. * Finalize the result of the output of the postprocesses.
  70994. * @param doNotPresent If true the result will not be displayed to the screen.
  70995. * @param targetTexture The target texture to render to.
  70996. * @param faceIndex The index of the face to bind the target texture to.
  70997. * @param postProcesses The array of post processes to render.
  70998. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  70999. * @hidden
  71000. */
  71001. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71002. /**
  71003. * Disposes of the post process manager.
  71004. */
  71005. dispose(): void;
  71006. }
  71007. }
  71008. declare module BABYLON {
  71009. interface AbstractScene {
  71010. /**
  71011. * The list of layers (background and foreground) of the scene
  71012. */
  71013. layers: Array<Layer>;
  71014. }
  71015. /**
  71016. * Defines the layer scene component responsible to manage any layers
  71017. * in a given scene.
  71018. */
  71019. export class LayerSceneComponent implements ISceneComponent {
  71020. /**
  71021. * The component name helpfull to identify the component in the list of scene components.
  71022. */
  71023. readonly name: string;
  71024. /**
  71025. * The scene the component belongs to.
  71026. */
  71027. scene: Scene;
  71028. private _engine;
  71029. /**
  71030. * Creates a new instance of the component for the given scene
  71031. * @param scene Defines the scene to register the component in
  71032. */
  71033. constructor(scene: Scene);
  71034. /**
  71035. * Registers the component in a given scene
  71036. */
  71037. register(): void;
  71038. /**
  71039. * Rebuilds the elements related to this component in case of
  71040. * context lost for instance.
  71041. */
  71042. rebuild(): void;
  71043. /**
  71044. * Disposes the component and the associated ressources.
  71045. */
  71046. dispose(): void;
  71047. private _draw;
  71048. private _drawCameraPredicate;
  71049. private _drawCameraBackground;
  71050. private _drawCameraForeground;
  71051. private _drawRenderTargetPredicate;
  71052. private _drawRenderTargetBackground;
  71053. private _drawRenderTargetForeground;
  71054. }
  71055. }
  71056. declare module BABYLON {
  71057. /** @hidden */
  71058. export var layerPixelShader: {
  71059. name: string;
  71060. shader: string;
  71061. };
  71062. }
  71063. declare module BABYLON {
  71064. /** @hidden */
  71065. export var layerVertexShader: {
  71066. name: string;
  71067. shader: string;
  71068. };
  71069. }
  71070. declare module BABYLON {
  71071. /**
  71072. * This represents a full screen 2d layer.
  71073. * This can be useful to display a picture in the background of your scene for instance.
  71074. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71075. */
  71076. export class Layer {
  71077. /**
  71078. * Define the name of the layer.
  71079. */
  71080. name: string;
  71081. /**
  71082. * Define the texture the layer should display.
  71083. */
  71084. texture: Nullable<Texture>;
  71085. /**
  71086. * Is the layer in background or foreground.
  71087. */
  71088. isBackground: boolean;
  71089. /**
  71090. * Define the color of the layer (instead of texture).
  71091. */
  71092. color: Color4;
  71093. /**
  71094. * Define the scale of the layer in order to zoom in out of the texture.
  71095. */
  71096. scale: Vector2;
  71097. /**
  71098. * Define an offset for the layer in order to shift the texture.
  71099. */
  71100. offset: Vector2;
  71101. /**
  71102. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71103. */
  71104. alphaBlendingMode: number;
  71105. /**
  71106. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71107. * Alpha test will not mix with the background color in case of transparency.
  71108. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71109. */
  71110. alphaTest: boolean;
  71111. /**
  71112. * Define a mask to restrict the layer to only some of the scene cameras.
  71113. */
  71114. layerMask: number;
  71115. /**
  71116. * Define the list of render target the layer is visible into.
  71117. */
  71118. renderTargetTextures: RenderTargetTexture[];
  71119. /**
  71120. * Define if the layer is only used in renderTarget or if it also
  71121. * renders in the main frame buffer of the canvas.
  71122. */
  71123. renderOnlyInRenderTargetTextures: boolean;
  71124. private _scene;
  71125. private _vertexBuffers;
  71126. private _indexBuffer;
  71127. private _effect;
  71128. private _alphaTestEffect;
  71129. /**
  71130. * An event triggered when the layer is disposed.
  71131. */
  71132. onDisposeObservable: Observable<Layer>;
  71133. private _onDisposeObserver;
  71134. /**
  71135. * Back compatibility with callback before the onDisposeObservable existed.
  71136. * The set callback will be triggered when the layer has been disposed.
  71137. */
  71138. onDispose: () => void;
  71139. /**
  71140. * An event triggered before rendering the scene
  71141. */
  71142. onBeforeRenderObservable: Observable<Layer>;
  71143. private _onBeforeRenderObserver;
  71144. /**
  71145. * Back compatibility with callback before the onBeforeRenderObservable existed.
  71146. * The set callback will be triggered just before rendering the layer.
  71147. */
  71148. onBeforeRender: () => void;
  71149. /**
  71150. * An event triggered after rendering the scene
  71151. */
  71152. onAfterRenderObservable: Observable<Layer>;
  71153. private _onAfterRenderObserver;
  71154. /**
  71155. * Back compatibility with callback before the onAfterRenderObservable existed.
  71156. * The set callback will be triggered just after rendering the layer.
  71157. */
  71158. onAfterRender: () => void;
  71159. /**
  71160. * Instantiates a new layer.
  71161. * This represents a full screen 2d layer.
  71162. * This can be useful to display a picture in the background of your scene for instance.
  71163. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71164. * @param name Define the name of the layer in the scene
  71165. * @param imgUrl Define the url of the texture to display in the layer
  71166. * @param scene Define the scene the layer belongs to
  71167. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  71168. * @param color Defines a color for the layer
  71169. */
  71170. constructor(
  71171. /**
  71172. * Define the name of the layer.
  71173. */
  71174. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  71175. private _createIndexBuffer;
  71176. /** @hidden */
  71177. _rebuild(): void;
  71178. /**
  71179. * Renders the layer in the scene.
  71180. */
  71181. render(): void;
  71182. /**
  71183. * Disposes and releases the associated ressources.
  71184. */
  71185. dispose(): void;
  71186. }
  71187. }
  71188. declare module BABYLON {
  71189. interface AbstractScene {
  71190. /**
  71191. * The list of procedural textures added to the scene
  71192. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71193. */
  71194. proceduralTextures: Array<ProceduralTexture>;
  71195. }
  71196. /**
  71197. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  71198. * in a given scene.
  71199. */
  71200. export class ProceduralTextureSceneComponent implements ISceneComponent {
  71201. /**
  71202. * The component name helpfull to identify the component in the list of scene components.
  71203. */
  71204. readonly name: string;
  71205. /**
  71206. * The scene the component belongs to.
  71207. */
  71208. scene: Scene;
  71209. /**
  71210. * Creates a new instance of the component for the given scene
  71211. * @param scene Defines the scene to register the component in
  71212. */
  71213. constructor(scene: Scene);
  71214. /**
  71215. * Registers the component in a given scene
  71216. */
  71217. register(): void;
  71218. /**
  71219. * Rebuilds the elements related to this component in case of
  71220. * context lost for instance.
  71221. */
  71222. rebuild(): void;
  71223. /**
  71224. * Disposes the component and the associated ressources.
  71225. */
  71226. dispose(): void;
  71227. private _beforeClear;
  71228. }
  71229. }
  71230. declare module BABYLON {
  71231. /** @hidden */
  71232. export var proceduralVertexShader: {
  71233. name: string;
  71234. shader: string;
  71235. };
  71236. }
  71237. declare module BABYLON {
  71238. /**
  71239. * 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.
  71240. * This is the base class of any Procedural texture and contains most of the shareable code.
  71241. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71242. */
  71243. export class ProceduralTexture extends Texture {
  71244. isCube: boolean;
  71245. /**
  71246. * Define if the texture is enabled or not (disabled texture will not render)
  71247. */
  71248. isEnabled: boolean;
  71249. /**
  71250. * Define if the texture must be cleared before rendering (default is true)
  71251. */
  71252. autoClear: boolean;
  71253. /**
  71254. * Callback called when the texture is generated
  71255. */
  71256. onGenerated: () => void;
  71257. /**
  71258. * Event raised when the texture is generated
  71259. */
  71260. onGeneratedObservable: Observable<ProceduralTexture>;
  71261. /** @hidden */
  71262. _generateMipMaps: boolean;
  71263. /** @hidden **/
  71264. _effect: Effect;
  71265. /** @hidden */
  71266. _textures: {
  71267. [key: string]: Texture;
  71268. };
  71269. private _size;
  71270. private _currentRefreshId;
  71271. private _refreshRate;
  71272. private _vertexBuffers;
  71273. private _indexBuffer;
  71274. private _uniforms;
  71275. private _samplers;
  71276. private _fragment;
  71277. private _floats;
  71278. private _ints;
  71279. private _floatsArrays;
  71280. private _colors3;
  71281. private _colors4;
  71282. private _vectors2;
  71283. private _vectors3;
  71284. private _matrices;
  71285. private _fallbackTexture;
  71286. private _fallbackTextureUsed;
  71287. private _engine;
  71288. private _cachedDefines;
  71289. private _contentUpdateId;
  71290. private _contentData;
  71291. /**
  71292. * Instantiates a new procedural texture.
  71293. * 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.
  71294. * This is the base class of any Procedural texture and contains most of the shareable code.
  71295. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  71296. * @param name Define the name of the texture
  71297. * @param size Define the size of the texture to create
  71298. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  71299. * @param scene Define the scene the texture belongs to
  71300. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  71301. * @param generateMipMaps Define if the texture should creates mip maps or not
  71302. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  71303. */
  71304. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  71305. /**
  71306. * The effect that is created when initializing the post process.
  71307. * @returns The created effect corrisponding the the postprocess.
  71308. */
  71309. getEffect(): Effect;
  71310. /**
  71311. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  71312. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  71313. */
  71314. getContent(): Nullable<ArrayBufferView>;
  71315. private _createIndexBuffer;
  71316. /** @hidden */
  71317. _rebuild(): void;
  71318. /**
  71319. * Resets the texture in order to recreate its associated resources.
  71320. * This can be called in case of context loss
  71321. */
  71322. reset(): void;
  71323. protected _getDefines(): string;
  71324. /**
  71325. * Is the texture ready to be used ? (rendered at least once)
  71326. * @returns true if ready, otherwise, false.
  71327. */
  71328. isReady(): boolean;
  71329. /**
  71330. * Resets the refresh counter of the texture and start bak from scratch.
  71331. * Could be useful to regenerate the texture if it is setup to render only once.
  71332. */
  71333. resetRefreshCounter(): void;
  71334. /**
  71335. * Set the fragment shader to use in order to render the texture.
  71336. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  71337. */
  71338. setFragment(fragment: any): void;
  71339. /**
  71340. * Define the refresh rate of the texture or the rendering frequency.
  71341. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  71342. */
  71343. refreshRate: number;
  71344. /** @hidden */
  71345. _shouldRender(): boolean;
  71346. /**
  71347. * Get the size the texture is rendering at.
  71348. * @returns the size (texture is always squared)
  71349. */
  71350. getRenderSize(): number;
  71351. /**
  71352. * Resize the texture to new value.
  71353. * @param size Define the new size the texture should have
  71354. * @param generateMipMaps Define whether the new texture should create mip maps
  71355. */
  71356. resize(size: number, generateMipMaps: boolean): void;
  71357. private _checkUniform;
  71358. /**
  71359. * Set a texture in the shader program used to render.
  71360. * @param name Define the name of the uniform samplers as defined in the shader
  71361. * @param texture Define the texture to bind to this sampler
  71362. * @return the texture itself allowing "fluent" like uniform updates
  71363. */
  71364. setTexture(name: string, texture: Texture): ProceduralTexture;
  71365. /**
  71366. * Set a float in the shader.
  71367. * @param name Define the name of the uniform as defined in the shader
  71368. * @param value Define the value to give to the uniform
  71369. * @return the texture itself allowing "fluent" like uniform updates
  71370. */
  71371. setFloat(name: string, value: number): ProceduralTexture;
  71372. /**
  71373. * Set a int in the shader.
  71374. * @param name Define the name of the uniform as defined in the shader
  71375. * @param value Define the value to give to the uniform
  71376. * @return the texture itself allowing "fluent" like uniform updates
  71377. */
  71378. setInt(name: string, value: number): ProceduralTexture;
  71379. /**
  71380. * Set an array of floats in the shader.
  71381. * @param name Define the name of the uniform as defined in the shader
  71382. * @param value Define the value to give to the uniform
  71383. * @return the texture itself allowing "fluent" like uniform updates
  71384. */
  71385. setFloats(name: string, value: number[]): ProceduralTexture;
  71386. /**
  71387. * Set a vec3 in the shader from a Color3.
  71388. * @param name Define the name of the uniform as defined in the shader
  71389. * @param value Define the value to give to the uniform
  71390. * @return the texture itself allowing "fluent" like uniform updates
  71391. */
  71392. setColor3(name: string, value: Color3): ProceduralTexture;
  71393. /**
  71394. * Set a vec4 in the shader from a Color4.
  71395. * @param name Define the name of the uniform as defined in the shader
  71396. * @param value Define the value to give to the uniform
  71397. * @return the texture itself allowing "fluent" like uniform updates
  71398. */
  71399. setColor4(name: string, value: Color4): ProceduralTexture;
  71400. /**
  71401. * Set a vec2 in the shader from a Vector2.
  71402. * @param name Define the name of the uniform as defined in the shader
  71403. * @param value Define the value to give to the uniform
  71404. * @return the texture itself allowing "fluent" like uniform updates
  71405. */
  71406. setVector2(name: string, value: Vector2): ProceduralTexture;
  71407. /**
  71408. * Set a vec3 in the shader from a Vector3.
  71409. * @param name Define the name of the uniform as defined in the shader
  71410. * @param value Define the value to give to the uniform
  71411. * @return the texture itself allowing "fluent" like uniform updates
  71412. */
  71413. setVector3(name: string, value: Vector3): ProceduralTexture;
  71414. /**
  71415. * Set a mat4 in the shader from a MAtrix.
  71416. * @param name Define the name of the uniform as defined in the shader
  71417. * @param value Define the value to give to the uniform
  71418. * @return the texture itself allowing "fluent" like uniform updates
  71419. */
  71420. setMatrix(name: string, value: Matrix): ProceduralTexture;
  71421. /**
  71422. * Render the texture to its associated render target.
  71423. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  71424. */
  71425. render(useCameraPostProcess?: boolean): void;
  71426. /**
  71427. * Clone the texture.
  71428. * @returns the cloned texture
  71429. */
  71430. clone(): ProceduralTexture;
  71431. /**
  71432. * Dispose the texture and release its asoociated resources.
  71433. */
  71434. dispose(): void;
  71435. }
  71436. }
  71437. declare module BABYLON {
  71438. /**
  71439. * This represents the base class for particle system in Babylon.
  71440. * 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.
  71441. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  71442. * @example https://doc.babylonjs.com/babylon101/particles
  71443. */
  71444. export class BaseParticleSystem {
  71445. /**
  71446. * Source color is added to the destination color without alpha affecting the result
  71447. */
  71448. static BLENDMODE_ONEONE: number;
  71449. /**
  71450. * Blend current color and particle color using particle’s alpha
  71451. */
  71452. static BLENDMODE_STANDARD: number;
  71453. /**
  71454. * Add current color and particle color multiplied by particle’s alpha
  71455. */
  71456. static BLENDMODE_ADD: number;
  71457. /**
  71458. * Multiply current color with particle color
  71459. */
  71460. static BLENDMODE_MULTIPLY: number;
  71461. /**
  71462. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  71463. */
  71464. static BLENDMODE_MULTIPLYADD: number;
  71465. /**
  71466. * List of animations used by the particle system.
  71467. */
  71468. animations: Animation[];
  71469. /**
  71470. * The id of the Particle system.
  71471. */
  71472. id: string;
  71473. /**
  71474. * The friendly name of the Particle system.
  71475. */
  71476. name: string;
  71477. /**
  71478. * The rendering group used by the Particle system to chose when to render.
  71479. */
  71480. renderingGroupId: number;
  71481. /**
  71482. * The emitter represents the Mesh or position we are attaching the particle system to.
  71483. */
  71484. emitter: Nullable<AbstractMesh | Vector3>;
  71485. /**
  71486. * The maximum number of particles to emit per frame
  71487. */
  71488. emitRate: number;
  71489. /**
  71490. * If you want to launch only a few particles at once, that can be done, as well.
  71491. */
  71492. manualEmitCount: number;
  71493. /**
  71494. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71495. */
  71496. updateSpeed: number;
  71497. /**
  71498. * The amount of time the particle system is running (depends of the overall update speed).
  71499. */
  71500. targetStopDuration: number;
  71501. /**
  71502. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71503. */
  71504. disposeOnStop: boolean;
  71505. /**
  71506. * Minimum power of emitting particles.
  71507. */
  71508. minEmitPower: number;
  71509. /**
  71510. * Maximum power of emitting particles.
  71511. */
  71512. maxEmitPower: number;
  71513. /**
  71514. * Minimum life time of emitting particles.
  71515. */
  71516. minLifeTime: number;
  71517. /**
  71518. * Maximum life time of emitting particles.
  71519. */
  71520. maxLifeTime: number;
  71521. /**
  71522. * Minimum Size of emitting particles.
  71523. */
  71524. minSize: number;
  71525. /**
  71526. * Maximum Size of emitting particles.
  71527. */
  71528. maxSize: number;
  71529. /**
  71530. * Minimum scale of emitting particles on X axis.
  71531. */
  71532. minScaleX: number;
  71533. /**
  71534. * Maximum scale of emitting particles on X axis.
  71535. */
  71536. maxScaleX: number;
  71537. /**
  71538. * Minimum scale of emitting particles on Y axis.
  71539. */
  71540. minScaleY: number;
  71541. /**
  71542. * Maximum scale of emitting particles on Y axis.
  71543. */
  71544. maxScaleY: number;
  71545. /**
  71546. * Gets or sets the minimal initial rotation in radians.
  71547. */
  71548. minInitialRotation: number;
  71549. /**
  71550. * Gets or sets the maximal initial rotation in radians.
  71551. */
  71552. maxInitialRotation: number;
  71553. /**
  71554. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71555. */
  71556. minAngularSpeed: number;
  71557. /**
  71558. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71559. */
  71560. maxAngularSpeed: number;
  71561. /**
  71562. * The texture used to render each particle. (this can be a spritesheet)
  71563. */
  71564. particleTexture: Nullable<Texture>;
  71565. /**
  71566. * The layer mask we are rendering the particles through.
  71567. */
  71568. layerMask: number;
  71569. /**
  71570. * This can help using your own shader to render the particle system.
  71571. * The according effect will be created
  71572. */
  71573. customShader: any;
  71574. /**
  71575. * By default particle system starts as soon as they are created. This prevents the
  71576. * automatic start to happen and let you decide when to start emitting particles.
  71577. */
  71578. preventAutoStart: boolean;
  71579. private _noiseTexture;
  71580. /**
  71581. * Gets or sets a texture used to add random noise to particle positions
  71582. */
  71583. noiseTexture: Nullable<ProceduralTexture>;
  71584. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71585. noiseStrength: Vector3;
  71586. /**
  71587. * Callback triggered when the particle animation is ending.
  71588. */
  71589. onAnimationEnd: Nullable<() => void>;
  71590. /**
  71591. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  71592. */
  71593. blendMode: number;
  71594. /**
  71595. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71596. * to override the particles.
  71597. */
  71598. forceDepthWrite: boolean;
  71599. /** 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 */
  71600. preWarmCycles: number;
  71601. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  71602. preWarmStepOffset: number;
  71603. /**
  71604. * 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)
  71605. */
  71606. spriteCellChangeSpeed: number;
  71607. /**
  71608. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71609. */
  71610. startSpriteCellID: number;
  71611. /**
  71612. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71613. */
  71614. endSpriteCellID: number;
  71615. /**
  71616. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71617. */
  71618. spriteCellWidth: number;
  71619. /**
  71620. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71621. */
  71622. spriteCellHeight: number;
  71623. /**
  71624. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71625. */
  71626. spriteRandomStartCell: boolean;
  71627. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71628. translationPivot: Vector2;
  71629. /** @hidden */
  71630. protected _isAnimationSheetEnabled: boolean;
  71631. /**
  71632. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71633. */
  71634. beginAnimationOnStart: boolean;
  71635. /**
  71636. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71637. */
  71638. beginAnimationFrom: number;
  71639. /**
  71640. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71641. */
  71642. beginAnimationTo: number;
  71643. /**
  71644. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71645. */
  71646. beginAnimationLoop: boolean;
  71647. /**
  71648. * Gets or sets a world offset applied to all particles
  71649. */
  71650. worldOffset: Vector3;
  71651. /**
  71652. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  71653. */
  71654. isAnimationSheetEnabled: boolean;
  71655. /**
  71656. * Get hosting scene
  71657. * @returns the scene
  71658. */
  71659. getScene(): Scene;
  71660. /**
  71661. * You can use gravity if you want to give an orientation to your particles.
  71662. */
  71663. gravity: Vector3;
  71664. protected _colorGradients: Nullable<Array<ColorGradient>>;
  71665. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  71666. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  71667. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  71668. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  71669. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  71670. protected _dragGradients: Nullable<Array<FactorGradient>>;
  71671. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  71672. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  71673. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  71674. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  71675. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  71676. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  71677. /**
  71678. * Defines the delay in milliseconds before starting the system (0 by default)
  71679. */
  71680. startDelay: number;
  71681. /**
  71682. * Gets the current list of drag gradients.
  71683. * You must use addDragGradient and removeDragGradient to udpate this list
  71684. * @returns the list of drag gradients
  71685. */
  71686. getDragGradients(): Nullable<Array<FactorGradient>>;
  71687. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71688. limitVelocityDamping: number;
  71689. /**
  71690. * Gets the current list of limit velocity gradients.
  71691. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71692. * @returns the list of limit velocity gradients
  71693. */
  71694. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71695. /**
  71696. * Gets the current list of color gradients.
  71697. * You must use addColorGradient and removeColorGradient to udpate this list
  71698. * @returns the list of color gradients
  71699. */
  71700. getColorGradients(): Nullable<Array<ColorGradient>>;
  71701. /**
  71702. * Gets the current list of size gradients.
  71703. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71704. * @returns the list of size gradients
  71705. */
  71706. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71707. /**
  71708. * Gets the current list of color remap gradients.
  71709. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71710. * @returns the list of color remap gradients
  71711. */
  71712. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71713. /**
  71714. * Gets the current list of alpha remap gradients.
  71715. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71716. * @returns the list of alpha remap gradients
  71717. */
  71718. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71719. /**
  71720. * Gets the current list of life time gradients.
  71721. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71722. * @returns the list of life time gradients
  71723. */
  71724. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71725. /**
  71726. * Gets the current list of angular speed gradients.
  71727. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71728. * @returns the list of angular speed gradients
  71729. */
  71730. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71731. /**
  71732. * Gets the current list of velocity gradients.
  71733. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71734. * @returns the list of velocity gradients
  71735. */
  71736. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71737. /**
  71738. * Gets the current list of start size gradients.
  71739. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71740. * @returns the list of start size gradients
  71741. */
  71742. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71743. /**
  71744. * Gets the current list of emit rate gradients.
  71745. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71746. * @returns the list of emit rate gradients
  71747. */
  71748. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71749. /**
  71750. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71751. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71752. */
  71753. direction1: Vector3;
  71754. /**
  71755. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  71756. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71757. */
  71758. direction2: Vector3;
  71759. /**
  71760. * 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.
  71761. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71762. */
  71763. minEmitBox: Vector3;
  71764. /**
  71765. * 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.
  71766. * This only works when particleEmitterTyps is a BoxParticleEmitter
  71767. */
  71768. maxEmitBox: Vector3;
  71769. /**
  71770. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71771. */
  71772. color1: Color4;
  71773. /**
  71774. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  71775. */
  71776. color2: Color4;
  71777. /**
  71778. * Color the particle will have at the end of its lifetime
  71779. */
  71780. colorDead: Color4;
  71781. /**
  71782. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  71783. */
  71784. textureMask: Color4;
  71785. /**
  71786. * The particle emitter type defines the emitter used by the particle system.
  71787. * It can be for example box, sphere, or cone...
  71788. */
  71789. particleEmitterType: IParticleEmitterType;
  71790. /** @hidden */
  71791. _isSubEmitter: boolean;
  71792. /**
  71793. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71794. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71795. */
  71796. billboardMode: number;
  71797. protected _isBillboardBased: boolean;
  71798. /**
  71799. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71800. */
  71801. isBillboardBased: boolean;
  71802. /**
  71803. * The scene the particle system belongs to.
  71804. */
  71805. protected _scene: Scene;
  71806. /**
  71807. * Local cache of defines for image processing.
  71808. */
  71809. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  71810. /**
  71811. * Default configuration related to image processing available in the standard Material.
  71812. */
  71813. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  71814. /**
  71815. * Gets the image processing configuration used either in this material.
  71816. */
  71817. /**
  71818. * Sets the Default image processing configuration used either in the this material.
  71819. *
  71820. * If sets to null, the scene one is in use.
  71821. */
  71822. imageProcessingConfiguration: ImageProcessingConfiguration;
  71823. /**
  71824. * Attaches a new image processing configuration to the Standard Material.
  71825. * @param configuration
  71826. */
  71827. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  71828. /** @hidden */
  71829. protected _reset(): void;
  71830. /** @hidden */
  71831. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  71832. /**
  71833. * Instantiates a particle system.
  71834. * 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.
  71835. * @param name The name of the particle system
  71836. */
  71837. constructor(name: string);
  71838. /**
  71839. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71842. * @returns the emitter
  71843. */
  71844. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71845. /**
  71846. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71847. * @param radius The radius of the hemisphere to emit from
  71848. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71849. * @returns the emitter
  71850. */
  71851. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  71852. /**
  71853. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71854. * @param radius The radius of the sphere to emit from
  71855. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71856. * @returns the emitter
  71857. */
  71858. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  71859. /**
  71860. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71861. * @param radius The radius of the sphere to emit from
  71862. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71863. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71864. * @returns the emitter
  71865. */
  71866. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  71867. /**
  71868. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71869. * @param radius The radius of the emission cylinder
  71870. * @param height The height of the emission cylinder
  71871. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71872. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71873. * @returns the emitter
  71874. */
  71875. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  71876. /**
  71877. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71878. * @param radius The radius of the cylinder to emit from
  71879. * @param height The height of the emission cylinder
  71880. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71881. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71882. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71883. * @returns the emitter
  71884. */
  71885. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  71886. /**
  71887. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71888. * @param radius The radius of the cone to emit from
  71889. * @param angle The base angle of the cone
  71890. * @returns the emitter
  71891. */
  71892. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  71893. /**
  71894. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71895. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71896. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71897. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71898. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71899. * @returns the emitter
  71900. */
  71901. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71902. }
  71903. }
  71904. declare module BABYLON {
  71905. /**
  71906. * Type of sub emitter
  71907. */
  71908. export enum SubEmitterType {
  71909. /**
  71910. * Attached to the particle over it's lifetime
  71911. */
  71912. ATTACHED = 0,
  71913. /**
  71914. * Created when the particle dies
  71915. */
  71916. END = 1
  71917. }
  71918. /**
  71919. * Sub emitter class used to emit particles from an existing particle
  71920. */
  71921. export class SubEmitter {
  71922. /**
  71923. * the particle system to be used by the sub emitter
  71924. */
  71925. particleSystem: ParticleSystem;
  71926. /**
  71927. * Type of the submitter (Default: END)
  71928. */
  71929. type: SubEmitterType;
  71930. /**
  71931. * 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)
  71932. * Note: This only is supported when using an emitter of type Mesh
  71933. */
  71934. inheritDirection: boolean;
  71935. /**
  71936. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  71937. */
  71938. inheritedVelocityAmount: number;
  71939. /**
  71940. * Creates a sub emitter
  71941. * @param particleSystem the particle system to be used by the sub emitter
  71942. */
  71943. constructor(
  71944. /**
  71945. * the particle system to be used by the sub emitter
  71946. */
  71947. particleSystem: ParticleSystem);
  71948. /**
  71949. * Clones the sub emitter
  71950. * @returns the cloned sub emitter
  71951. */
  71952. clone(): SubEmitter;
  71953. /**
  71954. * Serialize current object to a JSON object
  71955. * @returns the serialized object
  71956. */
  71957. serialize(): any;
  71958. /** @hidden */
  71959. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  71960. /**
  71961. * Creates a new SubEmitter from a serialized JSON version
  71962. * @param serializationObject defines the JSON object to read from
  71963. * @param scene defines the hosting scene
  71964. * @param rootUrl defines the rootUrl for data loading
  71965. * @returns a new SubEmitter
  71966. */
  71967. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  71968. /** Release associated resources */
  71969. dispose(): void;
  71970. }
  71971. }
  71972. declare module BABYLON {
  71973. /** @hidden */
  71974. export var clipPlaneFragmentDeclaration: {
  71975. name: string;
  71976. shader: string;
  71977. };
  71978. }
  71979. declare module BABYLON {
  71980. /** @hidden */
  71981. export var imageProcessingDeclaration: {
  71982. name: string;
  71983. shader: string;
  71984. };
  71985. }
  71986. declare module BABYLON {
  71987. /** @hidden */
  71988. export var imageProcessingFunctions: {
  71989. name: string;
  71990. shader: string;
  71991. };
  71992. }
  71993. declare module BABYLON {
  71994. /** @hidden */
  71995. export var clipPlaneFragment: {
  71996. name: string;
  71997. shader: string;
  71998. };
  71999. }
  72000. declare module BABYLON {
  72001. /** @hidden */
  72002. export var particlesPixelShader: {
  72003. name: string;
  72004. shader: string;
  72005. };
  72006. }
  72007. declare module BABYLON {
  72008. /** @hidden */
  72009. export var clipPlaneVertexDeclaration: {
  72010. name: string;
  72011. shader: string;
  72012. };
  72013. }
  72014. declare module BABYLON {
  72015. /** @hidden */
  72016. export var clipPlaneVertex: {
  72017. name: string;
  72018. shader: string;
  72019. };
  72020. }
  72021. declare module BABYLON {
  72022. /** @hidden */
  72023. export var particlesVertexShader: {
  72024. name: string;
  72025. shader: string;
  72026. };
  72027. }
  72028. declare module BABYLON {
  72029. /**
  72030. * This represents a particle system in Babylon.
  72031. * 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.
  72032. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72033. * @example https://doc.babylonjs.com/babylon101/particles
  72034. */
  72035. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72036. /**
  72037. * Billboard mode will only apply to Y axis
  72038. */
  72039. static readonly BILLBOARDMODE_Y: number;
  72040. /**
  72041. * Billboard mode will apply to all axes
  72042. */
  72043. static readonly BILLBOARDMODE_ALL: number;
  72044. /**
  72045. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72046. */
  72047. static readonly BILLBOARDMODE_STRETCHED: number;
  72048. /**
  72049. * This function can be defined to provide custom update for active particles.
  72050. * This function will be called instead of regular update (age, position, color, etc.).
  72051. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72052. */
  72053. updateFunction: (particles: Particle[]) => void;
  72054. private _emitterWorldMatrix;
  72055. /**
  72056. * This function can be defined to specify initial direction for every new particle.
  72057. * It by default use the emitterType defined function
  72058. */
  72059. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72060. /**
  72061. * This function can be defined to specify initial position for every new particle.
  72062. * It by default use the emitterType defined function
  72063. */
  72064. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72065. /**
  72066. * @hidden
  72067. */
  72068. _inheritedVelocityOffset: Vector3;
  72069. /**
  72070. * An event triggered when the system is disposed
  72071. */
  72072. onDisposeObservable: Observable<ParticleSystem>;
  72073. private _onDisposeObserver;
  72074. /**
  72075. * Sets a callback that will be triggered when the system is disposed
  72076. */
  72077. onDispose: () => void;
  72078. private _particles;
  72079. private _epsilon;
  72080. private _capacity;
  72081. private _stockParticles;
  72082. private _newPartsExcess;
  72083. private _vertexData;
  72084. private _vertexBuffer;
  72085. private _vertexBuffers;
  72086. private _spriteBuffer;
  72087. private _indexBuffer;
  72088. private _effect;
  72089. private _customEffect;
  72090. private _cachedDefines;
  72091. private _scaledColorStep;
  72092. private _colorDiff;
  72093. private _scaledDirection;
  72094. private _scaledGravity;
  72095. private _currentRenderId;
  72096. private _alive;
  72097. private _useInstancing;
  72098. private _started;
  72099. private _stopped;
  72100. private _actualFrame;
  72101. private _scaledUpdateSpeed;
  72102. private _vertexBufferSize;
  72103. /** @hidden */
  72104. _currentEmitRateGradient: Nullable<FactorGradient>;
  72105. /** @hidden */
  72106. _currentEmitRate1: number;
  72107. /** @hidden */
  72108. _currentEmitRate2: number;
  72109. /** @hidden */
  72110. _currentStartSizeGradient: Nullable<FactorGradient>;
  72111. /** @hidden */
  72112. _currentStartSize1: number;
  72113. /** @hidden */
  72114. _currentStartSize2: number;
  72115. private readonly _rawTextureWidth;
  72116. private _rampGradientsTexture;
  72117. private _useRampGradients;
  72118. /** Gets or sets a boolean indicating that ramp gradients must be used
  72119. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72120. */
  72121. useRampGradients: boolean;
  72122. /**
  72123. * 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.
  72124. * 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: [])
  72125. */
  72126. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  72127. private _subEmitters;
  72128. /**
  72129. * @hidden
  72130. * If the particle systems emitter should be disposed when the particle system is disposed
  72131. */
  72132. _disposeEmitterOnDispose: boolean;
  72133. /**
  72134. * The current active Sub-systems, this property is used by the root particle system only.
  72135. */
  72136. activeSubSystems: Array<ParticleSystem>;
  72137. private _rootParticleSystem;
  72138. /**
  72139. * Gets the current list of active particles
  72140. */
  72141. readonly particles: Particle[];
  72142. /**
  72143. * Returns the string "ParticleSystem"
  72144. * @returns a string containing the class name
  72145. */
  72146. getClassName(): string;
  72147. /**
  72148. * Instantiates a particle system.
  72149. * 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.
  72150. * @param name The name of the particle system
  72151. * @param capacity The max number of particles alive at the same time
  72152. * @param scene The scene the particle system belongs to
  72153. * @param customEffect a custom effect used to change the way particles are rendered by default
  72154. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72155. * @param epsilon Offset used to render the particles
  72156. */
  72157. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  72158. private _addFactorGradient;
  72159. private _removeFactorGradient;
  72160. /**
  72161. * Adds a new life time gradient
  72162. * @param gradient defines the gradient to use (between 0 and 1)
  72163. * @param factor defines the life time factor to affect to the specified gradient
  72164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72165. * @returns the current particle system
  72166. */
  72167. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72168. /**
  72169. * Remove a specific life time gradient
  72170. * @param gradient defines the gradient to remove
  72171. * @returns the current particle system
  72172. */
  72173. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72174. /**
  72175. * Adds a new size gradient
  72176. * @param gradient defines the gradient to use (between 0 and 1)
  72177. * @param factor defines the size factor to affect to the specified gradient
  72178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72179. * @returns the current particle system
  72180. */
  72181. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72182. /**
  72183. * Remove a specific size gradient
  72184. * @param gradient defines the gradient to remove
  72185. * @returns the current particle system
  72186. */
  72187. removeSizeGradient(gradient: number): IParticleSystem;
  72188. /**
  72189. * Adds a new color remap gradient
  72190. * @param gradient defines the gradient to use (between 0 and 1)
  72191. * @param min defines the color remap minimal range
  72192. * @param max defines the color remap maximal range
  72193. * @returns the current particle system
  72194. */
  72195. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72196. /**
  72197. * Remove a specific color remap gradient
  72198. * @param gradient defines the gradient to remove
  72199. * @returns the current particle system
  72200. */
  72201. removeColorRemapGradient(gradient: number): IParticleSystem;
  72202. /**
  72203. * Adds a new alpha remap gradient
  72204. * @param gradient defines the gradient to use (between 0 and 1)
  72205. * @param min defines the alpha remap minimal range
  72206. * @param max defines the alpha remap maximal range
  72207. * @returns the current particle system
  72208. */
  72209. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72210. /**
  72211. * Remove a specific alpha remap gradient
  72212. * @param gradient defines the gradient to remove
  72213. * @returns the current particle system
  72214. */
  72215. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  72216. /**
  72217. * Adds a new angular speed gradient
  72218. * @param gradient defines the gradient to use (between 0 and 1)
  72219. * @param factor defines the angular speed to affect to the specified gradient
  72220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72221. * @returns the current particle system
  72222. */
  72223. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72224. /**
  72225. * Remove a specific angular speed gradient
  72226. * @param gradient defines the gradient to remove
  72227. * @returns the current particle system
  72228. */
  72229. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  72230. /**
  72231. * Adds a new velocity gradient
  72232. * @param gradient defines the gradient to use (between 0 and 1)
  72233. * @param factor defines the velocity to affect to the specified gradient
  72234. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72235. * @returns the current particle system
  72236. */
  72237. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72238. /**
  72239. * Remove a specific velocity gradient
  72240. * @param gradient defines the gradient to remove
  72241. * @returns the current particle system
  72242. */
  72243. removeVelocityGradient(gradient: number): IParticleSystem;
  72244. /**
  72245. * Adds a new limit velocity gradient
  72246. * @param gradient defines the gradient to use (between 0 and 1)
  72247. * @param factor defines the limit velocity value to affect to the specified gradient
  72248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72249. * @returns the current particle system
  72250. */
  72251. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72252. /**
  72253. * Remove a specific limit velocity gradient
  72254. * @param gradient defines the gradient to remove
  72255. * @returns the current particle system
  72256. */
  72257. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  72258. /**
  72259. * Adds a new drag gradient
  72260. * @param gradient defines the gradient to use (between 0 and 1)
  72261. * @param factor defines the drag value to affect to the specified gradient
  72262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72263. * @returns the current particle system
  72264. */
  72265. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72266. /**
  72267. * Remove a specific drag gradient
  72268. * @param gradient defines the gradient to remove
  72269. * @returns the current particle system
  72270. */
  72271. removeDragGradient(gradient: number): IParticleSystem;
  72272. /**
  72273. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  72274. * @param gradient defines the gradient to use (between 0 and 1)
  72275. * @param factor defines the emit rate value to affect to the specified gradient
  72276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72277. * @returns the current particle system
  72278. */
  72279. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72280. /**
  72281. * Remove a specific emit rate gradient
  72282. * @param gradient defines the gradient to remove
  72283. * @returns the current particle system
  72284. */
  72285. removeEmitRateGradient(gradient: number): IParticleSystem;
  72286. /**
  72287. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  72288. * @param gradient defines the gradient to use (between 0 and 1)
  72289. * @param factor defines the start size value to affect to the specified gradient
  72290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72291. * @returns the current particle system
  72292. */
  72293. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72294. /**
  72295. * Remove a specific start size gradient
  72296. * @param gradient defines the gradient to remove
  72297. * @returns the current particle system
  72298. */
  72299. removeStartSizeGradient(gradient: number): IParticleSystem;
  72300. private _createRampGradientTexture;
  72301. /**
  72302. * Gets the current list of ramp gradients.
  72303. * You must use addRampGradient and removeRampGradient to udpate this list
  72304. * @returns the list of ramp gradients
  72305. */
  72306. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72307. /**
  72308. * Adds a new ramp gradient used to remap particle colors
  72309. * @param gradient defines the gradient to use (between 0 and 1)
  72310. * @param color defines the color to affect to the specified gradient
  72311. * @returns the current particle system
  72312. */
  72313. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  72314. /**
  72315. * Remove a specific ramp gradient
  72316. * @param gradient defines the gradient to remove
  72317. * @returns the current particle system
  72318. */
  72319. removeRampGradient(gradient: number): ParticleSystem;
  72320. /**
  72321. * Adds a new color gradient
  72322. * @param gradient defines the gradient to use (between 0 and 1)
  72323. * @param color1 defines the color to affect to the specified gradient
  72324. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72325. * @returns this particle system
  72326. */
  72327. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  72328. /**
  72329. * Remove a specific color gradient
  72330. * @param gradient defines the gradient to remove
  72331. * @returns this particle system
  72332. */
  72333. removeColorGradient(gradient: number): IParticleSystem;
  72334. private _fetchR;
  72335. protected _reset(): void;
  72336. private _resetEffect;
  72337. private _createVertexBuffers;
  72338. private _createIndexBuffer;
  72339. /**
  72340. * Gets the maximum number of particles active at the same time.
  72341. * @returns The max number of active particles.
  72342. */
  72343. getCapacity(): number;
  72344. /**
  72345. * Gets whether there are still active particles in the system.
  72346. * @returns True if it is alive, otherwise false.
  72347. */
  72348. isAlive(): boolean;
  72349. /**
  72350. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72351. * @returns True if it has been started, otherwise false.
  72352. */
  72353. isStarted(): boolean;
  72354. private _prepareSubEmitterInternalArray;
  72355. /**
  72356. * Starts the particle system and begins to emit
  72357. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72358. */
  72359. start(delay?: number): void;
  72360. /**
  72361. * Stops the particle system.
  72362. * @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.
  72363. */
  72364. stop(stopSubEmitters?: boolean): void;
  72365. /**
  72366. * Remove all active particles
  72367. */
  72368. reset(): void;
  72369. /**
  72370. * @hidden (for internal use only)
  72371. */
  72372. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  72373. /**
  72374. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  72375. * Its lifetime will start back at 0.
  72376. */
  72377. recycleParticle: (particle: Particle) => void;
  72378. private _stopSubEmitters;
  72379. private _createParticle;
  72380. private _removeFromRoot;
  72381. private _emitFromParticle;
  72382. private _update;
  72383. /** @hidden */
  72384. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  72385. /** @hidden */
  72386. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  72387. /** @hidden */
  72388. private _getEffect;
  72389. /**
  72390. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72391. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  72392. */
  72393. animate(preWarmOnly?: boolean): void;
  72394. private _appendParticleVertices;
  72395. /**
  72396. * Rebuilds the particle system.
  72397. */
  72398. rebuild(): void;
  72399. /**
  72400. * Is this system ready to be used/rendered
  72401. * @return true if the system is ready
  72402. */
  72403. isReady(): boolean;
  72404. private _render;
  72405. /**
  72406. * Renders the particle system in its current state.
  72407. * @returns the current number of particles
  72408. */
  72409. render(): number;
  72410. /**
  72411. * Disposes the particle system and free the associated resources
  72412. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72413. */
  72414. dispose(disposeTexture?: boolean): void;
  72415. /**
  72416. * Clones the particle system.
  72417. * @param name The name of the cloned object
  72418. * @param newEmitter The new emitter to use
  72419. * @returns the cloned particle system
  72420. */
  72421. clone(name: string, newEmitter: any): ParticleSystem;
  72422. /**
  72423. * Serializes the particle system to a JSON object.
  72424. * @returns the JSON object
  72425. */
  72426. serialize(): any;
  72427. /** @hidden */
  72428. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  72429. /** @hidden */
  72430. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  72431. /**
  72432. * Parses a JSON object to create a particle system.
  72433. * @param parsedParticleSystem The JSON object to parse
  72434. * @param scene The scene to create the particle system in
  72435. * @param rootUrl The root url to use to load external dependencies like texture
  72436. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72437. * @returns the Parsed particle system
  72438. */
  72439. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  72440. }
  72441. }
  72442. declare module BABYLON {
  72443. /**
  72444. * A particle represents one of the element emitted by a particle system.
  72445. * This is mainly define by its coordinates, direction, velocity and age.
  72446. */
  72447. export class Particle {
  72448. /**
  72449. * The particle system the particle belongs to.
  72450. */
  72451. particleSystem: ParticleSystem;
  72452. private static _Count;
  72453. /**
  72454. * Unique ID of the particle
  72455. */
  72456. id: number;
  72457. /**
  72458. * The world position of the particle in the scene.
  72459. */
  72460. position: Vector3;
  72461. /**
  72462. * The world direction of the particle in the scene.
  72463. */
  72464. direction: Vector3;
  72465. /**
  72466. * The color of the particle.
  72467. */
  72468. color: Color4;
  72469. /**
  72470. * The color change of the particle per step.
  72471. */
  72472. colorStep: Color4;
  72473. /**
  72474. * Defines how long will the life of the particle be.
  72475. */
  72476. lifeTime: number;
  72477. /**
  72478. * The current age of the particle.
  72479. */
  72480. age: number;
  72481. /**
  72482. * The current size of the particle.
  72483. */
  72484. size: number;
  72485. /**
  72486. * The current scale of the particle.
  72487. */
  72488. scale: Vector2;
  72489. /**
  72490. * The current angle of the particle.
  72491. */
  72492. angle: number;
  72493. /**
  72494. * Defines how fast is the angle changing.
  72495. */
  72496. angularSpeed: number;
  72497. /**
  72498. * Defines the cell index used by the particle to be rendered from a sprite.
  72499. */
  72500. cellIndex: number;
  72501. /**
  72502. * The information required to support color remapping
  72503. */
  72504. remapData: Vector4;
  72505. /** @hidden */
  72506. _randomCellOffset?: number;
  72507. /** @hidden */
  72508. _initialDirection: Nullable<Vector3>;
  72509. /** @hidden */
  72510. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  72511. /** @hidden */
  72512. _initialStartSpriteCellID: number;
  72513. /** @hidden */
  72514. _initialEndSpriteCellID: number;
  72515. /** @hidden */
  72516. _currentColorGradient: Nullable<ColorGradient>;
  72517. /** @hidden */
  72518. _currentColor1: Color4;
  72519. /** @hidden */
  72520. _currentColor2: Color4;
  72521. /** @hidden */
  72522. _currentSizeGradient: Nullable<FactorGradient>;
  72523. /** @hidden */
  72524. _currentSize1: number;
  72525. /** @hidden */
  72526. _currentSize2: number;
  72527. /** @hidden */
  72528. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  72529. /** @hidden */
  72530. _currentAngularSpeed1: number;
  72531. /** @hidden */
  72532. _currentAngularSpeed2: number;
  72533. /** @hidden */
  72534. _currentVelocityGradient: Nullable<FactorGradient>;
  72535. /** @hidden */
  72536. _currentVelocity1: number;
  72537. /** @hidden */
  72538. _currentVelocity2: number;
  72539. /** @hidden */
  72540. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  72541. /** @hidden */
  72542. _currentLimitVelocity1: number;
  72543. /** @hidden */
  72544. _currentLimitVelocity2: number;
  72545. /** @hidden */
  72546. _currentDragGradient: Nullable<FactorGradient>;
  72547. /** @hidden */
  72548. _currentDrag1: number;
  72549. /** @hidden */
  72550. _currentDrag2: number;
  72551. /** @hidden */
  72552. _randomNoiseCoordinates1: Vector3;
  72553. /** @hidden */
  72554. _randomNoiseCoordinates2: Vector3;
  72555. /**
  72556. * Creates a new instance Particle
  72557. * @param particleSystem the particle system the particle belongs to
  72558. */
  72559. constructor(
  72560. /**
  72561. * The particle system the particle belongs to.
  72562. */
  72563. particleSystem: ParticleSystem);
  72564. private updateCellInfoFromSystem;
  72565. /**
  72566. * Defines how the sprite cell index is updated for the particle
  72567. */
  72568. updateCellIndex(): void;
  72569. /** @hidden */
  72570. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  72571. /** @hidden */
  72572. _inheritParticleInfoToSubEmitters(): void;
  72573. /** @hidden */
  72574. _reset(): void;
  72575. /**
  72576. * Copy the properties of particle to another one.
  72577. * @param other the particle to copy the information to.
  72578. */
  72579. copyTo(other: Particle): void;
  72580. }
  72581. }
  72582. declare module BABYLON {
  72583. /**
  72584. * Particle emitter represents a volume emitting particles.
  72585. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  72586. */
  72587. export interface IParticleEmitterType {
  72588. /**
  72589. * Called by the particle System when the direction is computed for the created particle.
  72590. * @param worldMatrix is the world matrix of the particle system
  72591. * @param directionToUpdate is the direction vector to update with the result
  72592. * @param particle is the particle we are computed the direction for
  72593. */
  72594. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72595. /**
  72596. * Called by the particle System when the position is computed for the created particle.
  72597. * @param worldMatrix is the world matrix of the particle system
  72598. * @param positionToUpdate is the position vector to update with the result
  72599. * @param particle is the particle we are computed the position for
  72600. */
  72601. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72602. /**
  72603. * Clones the current emitter and returns a copy of it
  72604. * @returns the new emitter
  72605. */
  72606. clone(): IParticleEmitterType;
  72607. /**
  72608. * Called by the GPUParticleSystem to setup the update shader
  72609. * @param effect defines the update shader
  72610. */
  72611. applyToShader(effect: Effect): void;
  72612. /**
  72613. * Returns a string to use to update the GPU particles update shader
  72614. * @returns the effect defines string
  72615. */
  72616. getEffectDefines(): string;
  72617. /**
  72618. * Returns a string representing the class name
  72619. * @returns a string containing the class name
  72620. */
  72621. getClassName(): string;
  72622. /**
  72623. * Serializes the particle system to a JSON object.
  72624. * @returns the JSON object
  72625. */
  72626. serialize(): any;
  72627. /**
  72628. * Parse properties from a JSON object
  72629. * @param serializationObject defines the JSON object
  72630. */
  72631. parse(serializationObject: any): void;
  72632. }
  72633. }
  72634. declare module BABYLON {
  72635. /**
  72636. * Particle emitter emitting particles from the inside of a box.
  72637. * It emits the particles randomly between 2 given directions.
  72638. */
  72639. export class BoxParticleEmitter implements IParticleEmitterType {
  72640. /**
  72641. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72642. */
  72643. direction1: Vector3;
  72644. /**
  72645. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72646. */
  72647. direction2: Vector3;
  72648. /**
  72649. * 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.
  72650. */
  72651. minEmitBox: Vector3;
  72652. /**
  72653. * 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.
  72654. */
  72655. maxEmitBox: Vector3;
  72656. /**
  72657. * Creates a new instance BoxParticleEmitter
  72658. */
  72659. constructor();
  72660. /**
  72661. * Called by the particle System when the direction is computed for the created particle.
  72662. * @param worldMatrix is the world matrix of the particle system
  72663. * @param directionToUpdate is the direction vector to update with the result
  72664. * @param particle is the particle we are computed the direction for
  72665. */
  72666. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72667. /**
  72668. * Called by the particle System when the position is computed for the created particle.
  72669. * @param worldMatrix is the world matrix of the particle system
  72670. * @param positionToUpdate is the position vector to update with the result
  72671. * @param particle is the particle we are computed the position for
  72672. */
  72673. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72674. /**
  72675. * Clones the current emitter and returns a copy of it
  72676. * @returns the new emitter
  72677. */
  72678. clone(): BoxParticleEmitter;
  72679. /**
  72680. * Called by the GPUParticleSystem to setup the update shader
  72681. * @param effect defines the update shader
  72682. */
  72683. applyToShader(effect: Effect): void;
  72684. /**
  72685. * Returns a string to use to update the GPU particles update shader
  72686. * @returns a string containng the defines string
  72687. */
  72688. getEffectDefines(): string;
  72689. /**
  72690. * Returns the string "BoxParticleEmitter"
  72691. * @returns a string containing the class name
  72692. */
  72693. getClassName(): string;
  72694. /**
  72695. * Serializes the particle system to a JSON object.
  72696. * @returns the JSON object
  72697. */
  72698. serialize(): any;
  72699. /**
  72700. * Parse properties from a JSON object
  72701. * @param serializationObject defines the JSON object
  72702. */
  72703. parse(serializationObject: any): void;
  72704. }
  72705. }
  72706. declare module BABYLON {
  72707. /**
  72708. * Particle emitter emitting particles from the inside of a cone.
  72709. * It emits the particles alongside the cone volume from the base to the particle.
  72710. * The emission direction might be randomized.
  72711. */
  72712. export class ConeParticleEmitter implements IParticleEmitterType {
  72713. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72714. directionRandomizer: number;
  72715. private _radius;
  72716. private _angle;
  72717. private _height;
  72718. /**
  72719. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  72720. */
  72721. radiusRange: number;
  72722. /**
  72723. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  72724. */
  72725. heightRange: number;
  72726. /**
  72727. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  72728. */
  72729. emitFromSpawnPointOnly: boolean;
  72730. /**
  72731. * Gets or sets the radius of the emission cone
  72732. */
  72733. radius: number;
  72734. /**
  72735. * Gets or sets the angle of the emission cone
  72736. */
  72737. angle: number;
  72738. private _buildHeight;
  72739. /**
  72740. * Creates a new instance ConeParticleEmitter
  72741. * @param radius the radius of the emission cone (1 by default)
  72742. * @param angle the cone base angle (PI by default)
  72743. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  72744. */
  72745. constructor(radius?: number, angle?: number,
  72746. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  72747. directionRandomizer?: number);
  72748. /**
  72749. * Called by the particle System when the direction is computed for the created particle.
  72750. * @param worldMatrix is the world matrix of the particle system
  72751. * @param directionToUpdate is the direction vector to update with the result
  72752. * @param particle is the particle we are computed the direction for
  72753. */
  72754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72755. /**
  72756. * Called by the particle System when the position is computed for the created particle.
  72757. * @param worldMatrix is the world matrix of the particle system
  72758. * @param positionToUpdate is the position vector to update with the result
  72759. * @param particle is the particle we are computed the position for
  72760. */
  72761. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72762. /**
  72763. * Clones the current emitter and returns a copy of it
  72764. * @returns the new emitter
  72765. */
  72766. clone(): ConeParticleEmitter;
  72767. /**
  72768. * Called by the GPUParticleSystem to setup the update shader
  72769. * @param effect defines the update shader
  72770. */
  72771. applyToShader(effect: Effect): void;
  72772. /**
  72773. * Returns a string to use to update the GPU particles update shader
  72774. * @returns a string containng the defines string
  72775. */
  72776. getEffectDefines(): string;
  72777. /**
  72778. * Returns the string "ConeParticleEmitter"
  72779. * @returns a string containing the class name
  72780. */
  72781. getClassName(): string;
  72782. /**
  72783. * Serializes the particle system to a JSON object.
  72784. * @returns the JSON object
  72785. */
  72786. serialize(): any;
  72787. /**
  72788. * Parse properties from a JSON object
  72789. * @param serializationObject defines the JSON object
  72790. */
  72791. parse(serializationObject: any): void;
  72792. }
  72793. }
  72794. declare module BABYLON {
  72795. /**
  72796. * Particle emitter emitting particles from the inside of a cylinder.
  72797. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  72798. */
  72799. export class CylinderParticleEmitter implements IParticleEmitterType {
  72800. /**
  72801. * The radius of the emission cylinder.
  72802. */
  72803. radius: number;
  72804. /**
  72805. * The height of the emission cylinder.
  72806. */
  72807. height: number;
  72808. /**
  72809. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72810. */
  72811. radiusRange: number;
  72812. /**
  72813. * How much to randomize the particle direction [0-1].
  72814. */
  72815. directionRandomizer: number;
  72816. /**
  72817. * Creates a new instance CylinderParticleEmitter
  72818. * @param radius the radius of the emission cylinder (1 by default)
  72819. * @param height the height of the emission cylinder (1 by default)
  72820. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72821. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72822. */
  72823. constructor(
  72824. /**
  72825. * The radius of the emission cylinder.
  72826. */
  72827. radius?: number,
  72828. /**
  72829. * The height of the emission cylinder.
  72830. */
  72831. height?: number,
  72832. /**
  72833. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72834. */
  72835. radiusRange?: number,
  72836. /**
  72837. * How much to randomize the particle direction [0-1].
  72838. */
  72839. directionRandomizer?: number);
  72840. /**
  72841. * Called by the particle System when the direction is computed for the created particle.
  72842. * @param worldMatrix is the world matrix of the particle system
  72843. * @param directionToUpdate is the direction vector to update with the result
  72844. * @param particle is the particle we are computed the direction for
  72845. */
  72846. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72847. /**
  72848. * Called by the particle System when the position is computed for the created particle.
  72849. * @param worldMatrix is the world matrix of the particle system
  72850. * @param positionToUpdate is the position vector to update with the result
  72851. * @param particle is the particle we are computed the position for
  72852. */
  72853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  72854. /**
  72855. * Clones the current emitter and returns a copy of it
  72856. * @returns the new emitter
  72857. */
  72858. clone(): CylinderParticleEmitter;
  72859. /**
  72860. * Called by the GPUParticleSystem to setup the update shader
  72861. * @param effect defines the update shader
  72862. */
  72863. applyToShader(effect: Effect): void;
  72864. /**
  72865. * Returns a string to use to update the GPU particles update shader
  72866. * @returns a string containng the defines string
  72867. */
  72868. getEffectDefines(): string;
  72869. /**
  72870. * Returns the string "CylinderParticleEmitter"
  72871. * @returns a string containing the class name
  72872. */
  72873. getClassName(): string;
  72874. /**
  72875. * Serializes the particle system to a JSON object.
  72876. * @returns the JSON object
  72877. */
  72878. serialize(): any;
  72879. /**
  72880. * Parse properties from a JSON object
  72881. * @param serializationObject defines the JSON object
  72882. */
  72883. parse(serializationObject: any): void;
  72884. }
  72885. /**
  72886. * Particle emitter emitting particles from the inside of a cylinder.
  72887. * It emits the particles randomly between two vectors.
  72888. */
  72889. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  72890. /**
  72891. * The min limit of the emission direction.
  72892. */
  72893. direction1: Vector3;
  72894. /**
  72895. * The max limit of the emission direction.
  72896. */
  72897. direction2: Vector3;
  72898. /**
  72899. * Creates a new instance CylinderDirectedParticleEmitter
  72900. * @param radius the radius of the emission cylinder (1 by default)
  72901. * @param height the height of the emission cylinder (1 by default)
  72902. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72903. * @param direction1 the min limit of the emission direction (up vector by default)
  72904. * @param direction2 the max limit of the emission direction (up vector by default)
  72905. */
  72906. constructor(radius?: number, height?: number, radiusRange?: number,
  72907. /**
  72908. * The min limit of the emission direction.
  72909. */
  72910. direction1?: Vector3,
  72911. /**
  72912. * The max limit of the emission direction.
  72913. */
  72914. direction2?: Vector3);
  72915. /**
  72916. * Called by the particle System when the direction is computed for the created particle.
  72917. * @param worldMatrix is the world matrix of the particle system
  72918. * @param directionToUpdate is the direction vector to update with the result
  72919. * @param particle is the particle we are computed the direction for
  72920. */
  72921. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72922. /**
  72923. * Clones the current emitter and returns a copy of it
  72924. * @returns the new emitter
  72925. */
  72926. clone(): CylinderDirectedParticleEmitter;
  72927. /**
  72928. * Called by the GPUParticleSystem to setup the update shader
  72929. * @param effect defines the update shader
  72930. */
  72931. applyToShader(effect: Effect): void;
  72932. /**
  72933. * Returns a string to use to update the GPU particles update shader
  72934. * @returns a string containng the defines string
  72935. */
  72936. getEffectDefines(): string;
  72937. /**
  72938. * Returns the string "CylinderDirectedParticleEmitter"
  72939. * @returns a string containing the class name
  72940. */
  72941. getClassName(): string;
  72942. /**
  72943. * Serializes the particle system to a JSON object.
  72944. * @returns the JSON object
  72945. */
  72946. serialize(): any;
  72947. /**
  72948. * Parse properties from a JSON object
  72949. * @param serializationObject defines the JSON object
  72950. */
  72951. parse(serializationObject: any): void;
  72952. }
  72953. }
  72954. declare module BABYLON {
  72955. /**
  72956. * Particle emitter emitting particles from the inside of a hemisphere.
  72957. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  72958. */
  72959. export class HemisphericParticleEmitter implements IParticleEmitterType {
  72960. /**
  72961. * The radius of the emission hemisphere.
  72962. */
  72963. radius: number;
  72964. /**
  72965. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72966. */
  72967. radiusRange: number;
  72968. /**
  72969. * How much to randomize the particle direction [0-1].
  72970. */
  72971. directionRandomizer: number;
  72972. /**
  72973. * Creates a new instance HemisphericParticleEmitter
  72974. * @param radius the radius of the emission hemisphere (1 by default)
  72975. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72976. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  72977. */
  72978. constructor(
  72979. /**
  72980. * The radius of the emission hemisphere.
  72981. */
  72982. radius?: number,
  72983. /**
  72984. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  72985. */
  72986. radiusRange?: number,
  72987. /**
  72988. * How much to randomize the particle direction [0-1].
  72989. */
  72990. directionRandomizer?: number);
  72991. /**
  72992. * Called by the particle System when the direction is computed for the created particle.
  72993. * @param worldMatrix is the world matrix of the particle system
  72994. * @param directionToUpdate is the direction vector to update with the result
  72995. * @param particle is the particle we are computed the direction for
  72996. */
  72997. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  72998. /**
  72999. * Called by the particle System when the position is computed for the created particle.
  73000. * @param worldMatrix is the world matrix of the particle system
  73001. * @param positionToUpdate is the position vector to update with the result
  73002. * @param particle is the particle we are computed the position for
  73003. */
  73004. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73005. /**
  73006. * Clones the current emitter and returns a copy of it
  73007. * @returns the new emitter
  73008. */
  73009. clone(): HemisphericParticleEmitter;
  73010. /**
  73011. * Called by the GPUParticleSystem to setup the update shader
  73012. * @param effect defines the update shader
  73013. */
  73014. applyToShader(effect: Effect): void;
  73015. /**
  73016. * Returns a string to use to update the GPU particles update shader
  73017. * @returns a string containng the defines string
  73018. */
  73019. getEffectDefines(): string;
  73020. /**
  73021. * Returns the string "HemisphericParticleEmitter"
  73022. * @returns a string containing the class name
  73023. */
  73024. getClassName(): string;
  73025. /**
  73026. * Serializes the particle system to a JSON object.
  73027. * @returns the JSON object
  73028. */
  73029. serialize(): any;
  73030. /**
  73031. * Parse properties from a JSON object
  73032. * @param serializationObject defines the JSON object
  73033. */
  73034. parse(serializationObject: any): void;
  73035. }
  73036. }
  73037. declare module BABYLON {
  73038. /**
  73039. * Particle emitter emitting particles from a point.
  73040. * It emits the particles randomly between 2 given directions.
  73041. */
  73042. export class PointParticleEmitter implements IParticleEmitterType {
  73043. /**
  73044. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73045. */
  73046. direction1: Vector3;
  73047. /**
  73048. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73049. */
  73050. direction2: Vector3;
  73051. /**
  73052. * Creates a new instance PointParticleEmitter
  73053. */
  73054. constructor();
  73055. /**
  73056. * Called by the particle System when the direction is computed for the created particle.
  73057. * @param worldMatrix is the world matrix of the particle system
  73058. * @param directionToUpdate is the direction vector to update with the result
  73059. * @param particle is the particle we are computed the direction for
  73060. */
  73061. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73062. /**
  73063. * Called by the particle System when the position is computed for the created particle.
  73064. * @param worldMatrix is the world matrix of the particle system
  73065. * @param positionToUpdate is the position vector to update with the result
  73066. * @param particle is the particle we are computed the position for
  73067. */
  73068. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73069. /**
  73070. * Clones the current emitter and returns a copy of it
  73071. * @returns the new emitter
  73072. */
  73073. clone(): PointParticleEmitter;
  73074. /**
  73075. * Called by the GPUParticleSystem to setup the update shader
  73076. * @param effect defines the update shader
  73077. */
  73078. applyToShader(effect: Effect): void;
  73079. /**
  73080. * Returns a string to use to update the GPU particles update shader
  73081. * @returns a string containng the defines string
  73082. */
  73083. getEffectDefines(): string;
  73084. /**
  73085. * Returns the string "PointParticleEmitter"
  73086. * @returns a string containing the class name
  73087. */
  73088. getClassName(): string;
  73089. /**
  73090. * Serializes the particle system to a JSON object.
  73091. * @returns the JSON object
  73092. */
  73093. serialize(): any;
  73094. /**
  73095. * Parse properties from a JSON object
  73096. * @param serializationObject defines the JSON object
  73097. */
  73098. parse(serializationObject: any): void;
  73099. }
  73100. }
  73101. declare module BABYLON {
  73102. /**
  73103. * Particle emitter emitting particles from the inside of a sphere.
  73104. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73105. */
  73106. export class SphereParticleEmitter implements IParticleEmitterType {
  73107. /**
  73108. * The radius of the emission sphere.
  73109. */
  73110. radius: number;
  73111. /**
  73112. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73113. */
  73114. radiusRange: number;
  73115. /**
  73116. * How much to randomize the particle direction [0-1].
  73117. */
  73118. directionRandomizer: number;
  73119. /**
  73120. * Creates a new instance SphereParticleEmitter
  73121. * @param radius the radius of the emission sphere (1 by default)
  73122. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73123. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73124. */
  73125. constructor(
  73126. /**
  73127. * The radius of the emission sphere.
  73128. */
  73129. radius?: number,
  73130. /**
  73131. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73132. */
  73133. radiusRange?: number,
  73134. /**
  73135. * How much to randomize the particle direction [0-1].
  73136. */
  73137. directionRandomizer?: number);
  73138. /**
  73139. * Called by the particle System when the direction is computed for the created particle.
  73140. * @param worldMatrix is the world matrix of the particle system
  73141. * @param directionToUpdate is the direction vector to update with the result
  73142. * @param particle is the particle we are computed the direction for
  73143. */
  73144. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73145. /**
  73146. * Called by the particle System when the position is computed for the created particle.
  73147. * @param worldMatrix is the world matrix of the particle system
  73148. * @param positionToUpdate is the position vector to update with the result
  73149. * @param particle is the particle we are computed the position for
  73150. */
  73151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73152. /**
  73153. * Clones the current emitter and returns a copy of it
  73154. * @returns the new emitter
  73155. */
  73156. clone(): SphereParticleEmitter;
  73157. /**
  73158. * Called by the GPUParticleSystem to setup the update shader
  73159. * @param effect defines the update shader
  73160. */
  73161. applyToShader(effect: Effect): void;
  73162. /**
  73163. * Returns a string to use to update the GPU particles update shader
  73164. * @returns a string containng the defines string
  73165. */
  73166. getEffectDefines(): string;
  73167. /**
  73168. * Returns the string "SphereParticleEmitter"
  73169. * @returns a string containing the class name
  73170. */
  73171. getClassName(): string;
  73172. /**
  73173. * Serializes the particle system to a JSON object.
  73174. * @returns the JSON object
  73175. */
  73176. serialize(): any;
  73177. /**
  73178. * Parse properties from a JSON object
  73179. * @param serializationObject defines the JSON object
  73180. */
  73181. parse(serializationObject: any): void;
  73182. }
  73183. /**
  73184. * Particle emitter emitting particles from the inside of a sphere.
  73185. * It emits the particles randomly between two vectors.
  73186. */
  73187. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  73188. /**
  73189. * The min limit of the emission direction.
  73190. */
  73191. direction1: Vector3;
  73192. /**
  73193. * The max limit of the emission direction.
  73194. */
  73195. direction2: Vector3;
  73196. /**
  73197. * Creates a new instance SphereDirectedParticleEmitter
  73198. * @param radius the radius of the emission sphere (1 by default)
  73199. * @param direction1 the min limit of the emission direction (up vector by default)
  73200. * @param direction2 the max limit of the emission direction (up vector by default)
  73201. */
  73202. constructor(radius?: number,
  73203. /**
  73204. * The min limit of the emission direction.
  73205. */
  73206. direction1?: Vector3,
  73207. /**
  73208. * The max limit of the emission direction.
  73209. */
  73210. direction2?: Vector3);
  73211. /**
  73212. * Called by the particle System when the direction is computed for the created particle.
  73213. * @param worldMatrix is the world matrix of the particle system
  73214. * @param directionToUpdate is the direction vector to update with the result
  73215. * @param particle is the particle we are computed the direction for
  73216. */
  73217. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73218. /**
  73219. * Clones the current emitter and returns a copy of it
  73220. * @returns the new emitter
  73221. */
  73222. clone(): SphereDirectedParticleEmitter;
  73223. /**
  73224. * Called by the GPUParticleSystem to setup the update shader
  73225. * @param effect defines the update shader
  73226. */
  73227. applyToShader(effect: Effect): void;
  73228. /**
  73229. * Returns a string to use to update the GPU particles update shader
  73230. * @returns a string containng the defines string
  73231. */
  73232. getEffectDefines(): string;
  73233. /**
  73234. * Returns the string "SphereDirectedParticleEmitter"
  73235. * @returns a string containing the class name
  73236. */
  73237. getClassName(): string;
  73238. /**
  73239. * Serializes the particle system to a JSON object.
  73240. * @returns the JSON object
  73241. */
  73242. serialize(): any;
  73243. /**
  73244. * Parse properties from a JSON object
  73245. * @param serializationObject defines the JSON object
  73246. */
  73247. parse(serializationObject: any): void;
  73248. }
  73249. }
  73250. declare module BABYLON {
  73251. /**
  73252. * Interface representing a particle system in Babylon.js.
  73253. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  73254. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  73255. */
  73256. export interface IParticleSystem {
  73257. /**
  73258. * List of animations used by the particle system.
  73259. */
  73260. animations: Animation[];
  73261. /**
  73262. * The id of the Particle system.
  73263. */
  73264. id: string;
  73265. /**
  73266. * The name of the Particle system.
  73267. */
  73268. name: string;
  73269. /**
  73270. * The emitter represents the Mesh or position we are attaching the particle system to.
  73271. */
  73272. emitter: Nullable<AbstractMesh | Vector3>;
  73273. /**
  73274. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73275. */
  73276. isBillboardBased: boolean;
  73277. /**
  73278. * The rendering group used by the Particle system to chose when to render.
  73279. */
  73280. renderingGroupId: number;
  73281. /**
  73282. * The layer mask we are rendering the particles through.
  73283. */
  73284. layerMask: number;
  73285. /**
  73286. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73287. */
  73288. updateSpeed: number;
  73289. /**
  73290. * The amount of time the particle system is running (depends of the overall update speed).
  73291. */
  73292. targetStopDuration: number;
  73293. /**
  73294. * The texture used to render each particle. (this can be a spritesheet)
  73295. */
  73296. particleTexture: Nullable<Texture>;
  73297. /**
  73298. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  73299. */
  73300. blendMode: number;
  73301. /**
  73302. * Minimum life time of emitting particles.
  73303. */
  73304. minLifeTime: number;
  73305. /**
  73306. * Maximum life time of emitting particles.
  73307. */
  73308. maxLifeTime: number;
  73309. /**
  73310. * Minimum Size of emitting particles.
  73311. */
  73312. minSize: number;
  73313. /**
  73314. * Maximum Size of emitting particles.
  73315. */
  73316. maxSize: number;
  73317. /**
  73318. * Minimum scale of emitting particles on X axis.
  73319. */
  73320. minScaleX: number;
  73321. /**
  73322. * Maximum scale of emitting particles on X axis.
  73323. */
  73324. maxScaleX: number;
  73325. /**
  73326. * Minimum scale of emitting particles on Y axis.
  73327. */
  73328. minScaleY: number;
  73329. /**
  73330. * Maximum scale of emitting particles on Y axis.
  73331. */
  73332. maxScaleY: number;
  73333. /**
  73334. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73335. */
  73336. color1: Color4;
  73337. /**
  73338. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  73339. */
  73340. color2: Color4;
  73341. /**
  73342. * Color the particle will have at the end of its lifetime.
  73343. */
  73344. colorDead: Color4;
  73345. /**
  73346. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  73347. */
  73348. emitRate: number;
  73349. /**
  73350. * You can use gravity if you want to give an orientation to your particles.
  73351. */
  73352. gravity: Vector3;
  73353. /**
  73354. * Minimum power of emitting particles.
  73355. */
  73356. minEmitPower: number;
  73357. /**
  73358. * Maximum power of emitting particles.
  73359. */
  73360. maxEmitPower: number;
  73361. /**
  73362. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73363. */
  73364. minAngularSpeed: number;
  73365. /**
  73366. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73367. */
  73368. maxAngularSpeed: number;
  73369. /**
  73370. * Gets or sets the minimal initial rotation in radians.
  73371. */
  73372. minInitialRotation: number;
  73373. /**
  73374. * Gets or sets the maximal initial rotation in radians.
  73375. */
  73376. maxInitialRotation: number;
  73377. /**
  73378. * The particle emitter type defines the emitter used by the particle system.
  73379. * It can be for example box, sphere, or cone...
  73380. */
  73381. particleEmitterType: Nullable<IParticleEmitterType>;
  73382. /**
  73383. * Defines the delay in milliseconds before starting the system (0 by default)
  73384. */
  73385. startDelay: number;
  73386. /**
  73387. * 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
  73388. */
  73389. preWarmCycles: number;
  73390. /**
  73391. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  73392. */
  73393. preWarmStepOffset: number;
  73394. /**
  73395. * 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)
  73396. */
  73397. spriteCellChangeSpeed: number;
  73398. /**
  73399. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73400. */
  73401. startSpriteCellID: number;
  73402. /**
  73403. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73404. */
  73405. endSpriteCellID: number;
  73406. /**
  73407. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73408. */
  73409. spriteCellWidth: number;
  73410. /**
  73411. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73412. */
  73413. spriteCellHeight: number;
  73414. /**
  73415. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73416. */
  73417. spriteRandomStartCell: boolean;
  73418. /**
  73419. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  73420. */
  73421. isAnimationSheetEnabled: boolean;
  73422. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73423. translationPivot: Vector2;
  73424. /**
  73425. * Gets or sets a texture used to add random noise to particle positions
  73426. */
  73427. noiseTexture: Nullable<BaseTexture>;
  73428. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73429. noiseStrength: Vector3;
  73430. /**
  73431. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73432. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73433. */
  73434. billboardMode: number;
  73435. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73436. limitVelocityDamping: number;
  73437. /**
  73438. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73439. */
  73440. beginAnimationOnStart: boolean;
  73441. /**
  73442. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73443. */
  73444. beginAnimationFrom: number;
  73445. /**
  73446. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73447. */
  73448. beginAnimationTo: number;
  73449. /**
  73450. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73451. */
  73452. beginAnimationLoop: boolean;
  73453. /**
  73454. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73455. */
  73456. disposeOnStop: boolean;
  73457. /**
  73458. * Gets the maximum number of particles active at the same time.
  73459. * @returns The max number of active particles.
  73460. */
  73461. getCapacity(): number;
  73462. /**
  73463. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73464. * @returns True if it has been started, otherwise false.
  73465. */
  73466. isStarted(): boolean;
  73467. /**
  73468. * Animates the particle system for this frame.
  73469. */
  73470. animate(): void;
  73471. /**
  73472. * Renders the particle system in its current state.
  73473. * @returns the current number of particles
  73474. */
  73475. render(): number;
  73476. /**
  73477. * Dispose the particle system and frees its associated resources.
  73478. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73479. */
  73480. dispose(disposeTexture?: boolean): void;
  73481. /**
  73482. * Clones the particle system.
  73483. * @param name The name of the cloned object
  73484. * @param newEmitter The new emitter to use
  73485. * @returns the cloned particle system
  73486. */
  73487. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  73488. /**
  73489. * Serializes the particle system to a JSON object.
  73490. * @returns the JSON object
  73491. */
  73492. serialize(): any;
  73493. /**
  73494. * Rebuild the particle system
  73495. */
  73496. rebuild(): void;
  73497. /**
  73498. * Starts the particle system and begins to emit
  73499. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  73500. */
  73501. start(delay?: number): void;
  73502. /**
  73503. * Stops the particle system.
  73504. */
  73505. stop(): void;
  73506. /**
  73507. * Remove all active particles
  73508. */
  73509. reset(): void;
  73510. /**
  73511. * Is this system ready to be used/rendered
  73512. * @return true if the system is ready
  73513. */
  73514. isReady(): boolean;
  73515. /**
  73516. * Adds a new color gradient
  73517. * @param gradient defines the gradient to use (between 0 and 1)
  73518. * @param color1 defines the color to affect to the specified gradient
  73519. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73520. * @returns the current particle system
  73521. */
  73522. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73523. /**
  73524. * Remove a specific color gradient
  73525. * @param gradient defines the gradient to remove
  73526. * @returns the current particle system
  73527. */
  73528. removeColorGradient(gradient: number): IParticleSystem;
  73529. /**
  73530. * Adds a new size gradient
  73531. * @param gradient defines the gradient to use (between 0 and 1)
  73532. * @param factor defines the size factor to affect to the specified gradient
  73533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73534. * @returns the current particle system
  73535. */
  73536. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73537. /**
  73538. * Remove a specific size gradient
  73539. * @param gradient defines the gradient to remove
  73540. * @returns the current particle system
  73541. */
  73542. removeSizeGradient(gradient: number): IParticleSystem;
  73543. /**
  73544. * Gets the current list of color gradients.
  73545. * You must use addColorGradient and removeColorGradient to udpate this list
  73546. * @returns the list of color gradients
  73547. */
  73548. getColorGradients(): Nullable<Array<ColorGradient>>;
  73549. /**
  73550. * Gets the current list of size gradients.
  73551. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73552. * @returns the list of size gradients
  73553. */
  73554. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73555. /**
  73556. * Gets the current list of angular speed gradients.
  73557. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73558. * @returns the list of angular speed gradients
  73559. */
  73560. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73561. /**
  73562. * Adds a new angular speed gradient
  73563. * @param gradient defines the gradient to use (between 0 and 1)
  73564. * @param factor defines the angular speed to affect to the specified gradient
  73565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73566. * @returns the current particle system
  73567. */
  73568. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73569. /**
  73570. * Remove a specific angular speed gradient
  73571. * @param gradient defines the gradient to remove
  73572. * @returns the current particle system
  73573. */
  73574. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73575. /**
  73576. * Gets the current list of velocity gradients.
  73577. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73578. * @returns the list of velocity gradients
  73579. */
  73580. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73581. /**
  73582. * Adds a new velocity gradient
  73583. * @param gradient defines the gradient to use (between 0 and 1)
  73584. * @param factor defines the velocity to affect to the specified gradient
  73585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73586. * @returns the current particle system
  73587. */
  73588. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73589. /**
  73590. * Remove a specific velocity gradient
  73591. * @param gradient defines the gradient to remove
  73592. * @returns the current particle system
  73593. */
  73594. removeVelocityGradient(gradient: number): IParticleSystem;
  73595. /**
  73596. * Gets the current list of limit velocity gradients.
  73597. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73598. * @returns the list of limit velocity gradients
  73599. */
  73600. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73601. /**
  73602. * Adds a new limit velocity gradient
  73603. * @param gradient defines the gradient to use (between 0 and 1)
  73604. * @param factor defines the limit velocity to affect to the specified gradient
  73605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73606. * @returns the current particle system
  73607. */
  73608. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73609. /**
  73610. * Remove a specific limit velocity gradient
  73611. * @param gradient defines the gradient to remove
  73612. * @returns the current particle system
  73613. */
  73614. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73615. /**
  73616. * Adds a new drag gradient
  73617. * @param gradient defines the gradient to use (between 0 and 1)
  73618. * @param factor defines the drag to affect to the specified gradient
  73619. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73620. * @returns the current particle system
  73621. */
  73622. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73623. /**
  73624. * Remove a specific drag gradient
  73625. * @param gradient defines the gradient to remove
  73626. * @returns the current particle system
  73627. */
  73628. removeDragGradient(gradient: number): IParticleSystem;
  73629. /**
  73630. * Gets the current list of drag gradients.
  73631. * You must use addDragGradient and removeDragGradient to udpate this list
  73632. * @returns the list of drag gradients
  73633. */
  73634. getDragGradients(): Nullable<Array<FactorGradient>>;
  73635. /**
  73636. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73637. * @param gradient defines the gradient to use (between 0 and 1)
  73638. * @param factor defines the emit rate to affect to the specified gradient
  73639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73640. * @returns the current particle system
  73641. */
  73642. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73643. /**
  73644. * Remove a specific emit rate gradient
  73645. * @param gradient defines the gradient to remove
  73646. * @returns the current particle system
  73647. */
  73648. removeEmitRateGradient(gradient: number): IParticleSystem;
  73649. /**
  73650. * Gets the current list of emit rate gradients.
  73651. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73652. * @returns the list of emit rate gradients
  73653. */
  73654. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73655. /**
  73656. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73657. * @param gradient defines the gradient to use (between 0 and 1)
  73658. * @param factor defines the start size to affect to the specified gradient
  73659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73660. * @returns the current particle system
  73661. */
  73662. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73663. /**
  73664. * Remove a specific start size gradient
  73665. * @param gradient defines the gradient to remove
  73666. * @returns the current particle system
  73667. */
  73668. removeStartSizeGradient(gradient: number): IParticleSystem;
  73669. /**
  73670. * Gets the current list of start size gradients.
  73671. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73672. * @returns the list of start size gradients
  73673. */
  73674. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73675. /**
  73676. * Adds a new life time gradient
  73677. * @param gradient defines the gradient to use (between 0 and 1)
  73678. * @param factor defines the life time factor to affect to the specified gradient
  73679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73680. * @returns the current particle system
  73681. */
  73682. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73683. /**
  73684. * Remove a specific life time gradient
  73685. * @param gradient defines the gradient to remove
  73686. * @returns the current particle system
  73687. */
  73688. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73689. /**
  73690. * Gets the current list of life time gradients.
  73691. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73692. * @returns the list of life time gradients
  73693. */
  73694. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73695. /**
  73696. * Gets the current list of color gradients.
  73697. * You must use addColorGradient and removeColorGradient to udpate this list
  73698. * @returns the list of color gradients
  73699. */
  73700. getColorGradients(): Nullable<Array<ColorGradient>>;
  73701. /**
  73702. * Adds a new ramp gradient used to remap particle colors
  73703. * @param gradient defines the gradient to use (between 0 and 1)
  73704. * @param color defines the color to affect to the specified gradient
  73705. * @returns the current particle system
  73706. */
  73707. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  73708. /**
  73709. * Gets the current list of ramp gradients.
  73710. * You must use addRampGradient and removeRampGradient to udpate this list
  73711. * @returns the list of ramp gradients
  73712. */
  73713. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73714. /** Gets or sets a boolean indicating that ramp gradients must be used
  73715. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73716. */
  73717. useRampGradients: boolean;
  73718. /**
  73719. * Adds a new color remap gradient
  73720. * @param gradient defines the gradient to use (between 0 and 1)
  73721. * @param min defines the color remap minimal range
  73722. * @param max defines the color remap maximal range
  73723. * @returns the current particle system
  73724. */
  73725. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73726. /**
  73727. * Gets the current list of color remap gradients.
  73728. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73729. * @returns the list of color remap gradients
  73730. */
  73731. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73732. /**
  73733. * Adds a new alpha remap gradient
  73734. * @param gradient defines the gradient to use (between 0 and 1)
  73735. * @param min defines the alpha remap minimal range
  73736. * @param max defines the alpha remap maximal range
  73737. * @returns the current particle system
  73738. */
  73739. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73740. /**
  73741. * Gets the current list of alpha remap gradients.
  73742. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73743. * @returns the list of alpha remap gradients
  73744. */
  73745. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73746. /**
  73747. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73748. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73749. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73750. * @returns the emitter
  73751. */
  73752. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73753. /**
  73754. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73755. * @param radius The radius of the hemisphere to emit from
  73756. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73757. * @returns the emitter
  73758. */
  73759. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  73760. /**
  73761. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73762. * @param radius The radius of the sphere to emit from
  73763. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73764. * @returns the emitter
  73765. */
  73766. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  73767. /**
  73768. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73769. * @param radius The radius of the sphere to emit from
  73770. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73771. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73772. * @returns the emitter
  73773. */
  73774. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73775. /**
  73776. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73777. * @param radius The radius of the emission cylinder
  73778. * @param height The height of the emission cylinder
  73779. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73780. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73781. * @returns the emitter
  73782. */
  73783. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  73784. /**
  73785. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73786. * @param radius The radius of the cylinder to emit from
  73787. * @param height The height of the emission cylinder
  73788. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73789. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73790. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73791. * @returns the emitter
  73792. */
  73793. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  73794. /**
  73795. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73796. * @param radius The radius of the cone to emit from
  73797. * @param angle The base angle of the cone
  73798. * @returns the emitter
  73799. */
  73800. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  73801. /**
  73802. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73803. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73804. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73805. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73806. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73807. * @returns the emitter
  73808. */
  73809. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73810. /**
  73811. * Get hosting scene
  73812. * @returns the scene
  73813. */
  73814. getScene(): Scene;
  73815. }
  73816. }
  73817. declare module BABYLON {
  73818. /**
  73819. * Creates an instance based on a source mesh.
  73820. */
  73821. export class InstancedMesh extends AbstractMesh {
  73822. private _sourceMesh;
  73823. private _currentLOD;
  73824. /** @hidden */
  73825. _indexInSourceMeshInstanceArray: number;
  73826. constructor(name: string, source: Mesh);
  73827. /**
  73828. * Returns the string "InstancedMesh".
  73829. */
  73830. getClassName(): string;
  73831. /**
  73832. * If the source mesh receives shadows
  73833. */
  73834. readonly receiveShadows: boolean;
  73835. /**
  73836. * The material of the source mesh
  73837. */
  73838. readonly material: Nullable<Material>;
  73839. /**
  73840. * Visibility of the source mesh
  73841. */
  73842. readonly visibility: number;
  73843. /**
  73844. * Skeleton of the source mesh
  73845. */
  73846. readonly skeleton: Nullable<Skeleton>;
  73847. /**
  73848. * Rendering ground id of the source mesh
  73849. */
  73850. renderingGroupId: number;
  73851. /**
  73852. * Returns the total number of vertices (integer).
  73853. */
  73854. getTotalVertices(): number;
  73855. /**
  73856. * Returns a positive integer : the total number of indices in this mesh geometry.
  73857. * @returns the numner of indices or zero if the mesh has no geometry.
  73858. */
  73859. getTotalIndices(): number;
  73860. /**
  73861. * The source mesh of the instance
  73862. */
  73863. readonly sourceMesh: Mesh;
  73864. /**
  73865. * Is this node ready to be used/rendered
  73866. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  73867. * @return {boolean} is it ready
  73868. */
  73869. isReady(completeCheck?: boolean): boolean;
  73870. /**
  73871. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  73872. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  73873. * @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.
  73874. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  73875. */
  73876. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  73877. /**
  73878. * Sets the vertex data of the mesh geometry for the requested `kind`.
  73879. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  73880. * The `data` are either a numeric array either a Float32Array.
  73881. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  73882. * 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).
  73883. * Note that a new underlying VertexBuffer object is created each call.
  73884. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  73885. *
  73886. * Possible `kind` values :
  73887. * - VertexBuffer.PositionKind
  73888. * - VertexBuffer.UVKind
  73889. * - VertexBuffer.UV2Kind
  73890. * - VertexBuffer.UV3Kind
  73891. * - VertexBuffer.UV4Kind
  73892. * - VertexBuffer.UV5Kind
  73893. * - VertexBuffer.UV6Kind
  73894. * - VertexBuffer.ColorKind
  73895. * - VertexBuffer.MatricesIndicesKind
  73896. * - VertexBuffer.MatricesIndicesExtraKind
  73897. * - VertexBuffer.MatricesWeightsKind
  73898. * - VertexBuffer.MatricesWeightsExtraKind
  73899. *
  73900. * Returns the Mesh.
  73901. */
  73902. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  73903. /**
  73904. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  73905. * If the mesh has no geometry, it is simply returned as it is.
  73906. * The `data` are either a numeric array either a Float32Array.
  73907. * No new underlying VertexBuffer object is created.
  73908. * 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.
  73909. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  73910. *
  73911. * Possible `kind` values :
  73912. * - VertexBuffer.PositionKind
  73913. * - VertexBuffer.UVKind
  73914. * - VertexBuffer.UV2Kind
  73915. * - VertexBuffer.UV3Kind
  73916. * - VertexBuffer.UV4Kind
  73917. * - VertexBuffer.UV5Kind
  73918. * - VertexBuffer.UV6Kind
  73919. * - VertexBuffer.ColorKind
  73920. * - VertexBuffer.MatricesIndicesKind
  73921. * - VertexBuffer.MatricesIndicesExtraKind
  73922. * - VertexBuffer.MatricesWeightsKind
  73923. * - VertexBuffer.MatricesWeightsExtraKind
  73924. *
  73925. * Returns the Mesh.
  73926. */
  73927. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  73928. /**
  73929. * Sets the mesh indices.
  73930. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  73931. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  73932. * This method creates a new index buffer each call.
  73933. * Returns the Mesh.
  73934. */
  73935. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  73936. /**
  73937. * Boolean : True if the mesh owns the requested kind of data.
  73938. */
  73939. isVerticesDataPresent(kind: string): boolean;
  73940. /**
  73941. * Returns an array of indices (IndicesArray).
  73942. */
  73943. getIndices(): Nullable<IndicesArray>;
  73944. readonly _positions: Nullable<Vector3[]>;
  73945. /**
  73946. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  73947. * This means the mesh underlying bounding box and sphere are recomputed.
  73948. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  73949. * @returns the current mesh
  73950. */
  73951. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  73952. /** @hidden */
  73953. _preActivate(): InstancedMesh;
  73954. /** @hidden */
  73955. _activate(renderId: number): InstancedMesh;
  73956. /**
  73957. * Returns the current associated LOD AbstractMesh.
  73958. */
  73959. getLOD(camera: Camera): AbstractMesh;
  73960. /** @hidden */
  73961. _syncSubMeshes(): InstancedMesh;
  73962. /** @hidden */
  73963. _generatePointsArray(): boolean;
  73964. /**
  73965. * Creates a new InstancedMesh from the current mesh.
  73966. * - name (string) : the cloned mesh name
  73967. * - newParent (optional Node) : the optional Node to parent the clone to.
  73968. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  73969. *
  73970. * Returns the clone.
  73971. */
  73972. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  73973. /**
  73974. * Disposes the InstancedMesh.
  73975. * Returns nothing.
  73976. */
  73977. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73978. }
  73979. }
  73980. declare module BABYLON {
  73981. /**
  73982. * Defines the options associated with the creation of a shader material.
  73983. */
  73984. export interface IShaderMaterialOptions {
  73985. /**
  73986. * Does the material work in alpha blend mode
  73987. */
  73988. needAlphaBlending: boolean;
  73989. /**
  73990. * Does the material work in alpha test mode
  73991. */
  73992. needAlphaTesting: boolean;
  73993. /**
  73994. * The list of attribute names used in the shader
  73995. */
  73996. attributes: string[];
  73997. /**
  73998. * The list of unifrom names used in the shader
  73999. */
  74000. uniforms: string[];
  74001. /**
  74002. * The list of UBO names used in the shader
  74003. */
  74004. uniformBuffers: string[];
  74005. /**
  74006. * The list of sampler names used in the shader
  74007. */
  74008. samplers: string[];
  74009. /**
  74010. * The list of defines used in the shader
  74011. */
  74012. defines: string[];
  74013. }
  74014. /**
  74015. * 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.
  74016. *
  74017. * This returned material effects how the mesh will look based on the code in the shaders.
  74018. *
  74019. * @see http://doc.babylonjs.com/how_to/shader_material
  74020. */
  74021. export class ShaderMaterial extends Material {
  74022. private _shaderPath;
  74023. private _options;
  74024. private _textures;
  74025. private _textureArrays;
  74026. private _floats;
  74027. private _ints;
  74028. private _floatsArrays;
  74029. private _colors3;
  74030. private _colors3Arrays;
  74031. private _colors4;
  74032. private _vectors2;
  74033. private _vectors3;
  74034. private _vectors4;
  74035. private _matrices;
  74036. private _matrices3x3;
  74037. private _matrices2x2;
  74038. private _vectors2Arrays;
  74039. private _vectors3Arrays;
  74040. private _cachedWorldViewMatrix;
  74041. private _renderId;
  74042. /**
  74043. * Instantiate a new shader material.
  74044. * 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.
  74045. * This returned material effects how the mesh will look based on the code in the shaders.
  74046. * @see http://doc.babylonjs.com/how_to/shader_material
  74047. * @param name Define the name of the material in the scene
  74048. * @param scene Define the scene the material belongs to
  74049. * @param shaderPath Defines the route to the shader code in one of three ways:
  74050. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74051. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74052. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74053. * @param options Define the options used to create the shader
  74054. */
  74055. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74056. /**
  74057. * Gets the current class name of the material e.g. "ShaderMaterial"
  74058. * Mainly use in serialization.
  74059. * @returns the class name
  74060. */
  74061. getClassName(): string;
  74062. /**
  74063. * Specifies if the material will require alpha blending
  74064. * @returns a boolean specifying if alpha blending is needed
  74065. */
  74066. needAlphaBlending(): boolean;
  74067. /**
  74068. * Specifies if this material should be rendered in alpha test mode
  74069. * @returns a boolean specifying if an alpha test is needed.
  74070. */
  74071. needAlphaTesting(): boolean;
  74072. private _checkUniform;
  74073. /**
  74074. * Set a texture in the shader.
  74075. * @param name Define the name of the uniform samplers as defined in the shader
  74076. * @param texture Define the texture to bind to this sampler
  74077. * @return the material itself allowing "fluent" like uniform updates
  74078. */
  74079. setTexture(name: string, texture: Texture): ShaderMaterial;
  74080. /**
  74081. * Set a texture array in the shader.
  74082. * @param name Define the name of the uniform sampler array as defined in the shader
  74083. * @param textures Define the list of textures to bind to this sampler
  74084. * @return the material itself allowing "fluent" like uniform updates
  74085. */
  74086. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74087. /**
  74088. * Set a float in the shader.
  74089. * @param name Define the name of the uniform as defined in the shader
  74090. * @param value Define the value to give to the uniform
  74091. * @return the material itself allowing "fluent" like uniform updates
  74092. */
  74093. setFloat(name: string, value: number): ShaderMaterial;
  74094. /**
  74095. * Set a int in the shader.
  74096. * @param name Define the name of the uniform as defined in the shader
  74097. * @param value Define the value to give to the uniform
  74098. * @return the material itself allowing "fluent" like uniform updates
  74099. */
  74100. setInt(name: string, value: number): ShaderMaterial;
  74101. /**
  74102. * Set an array of floats in the shader.
  74103. * @param name Define the name of the uniform as defined in the shader
  74104. * @param value Define the value to give to the uniform
  74105. * @return the material itself allowing "fluent" like uniform updates
  74106. */
  74107. setFloats(name: string, value: number[]): ShaderMaterial;
  74108. /**
  74109. * Set a vec3 in the shader from a Color3.
  74110. * @param name Define the name of the uniform as defined in the shader
  74111. * @param value Define the value to give to the uniform
  74112. * @return the material itself allowing "fluent" like uniform updates
  74113. */
  74114. setColor3(name: string, value: Color3): ShaderMaterial;
  74115. /**
  74116. * Set a vec3 array in the shader from a Color3 array.
  74117. * @param name Define the name of the uniform as defined in the shader
  74118. * @param value Define the value to give to the uniform
  74119. * @return the material itself allowing "fluent" like uniform updates
  74120. */
  74121. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74122. /**
  74123. * Set a vec4 in the shader from a Color4.
  74124. * @param name Define the name of the uniform as defined in the shader
  74125. * @param value Define the value to give to the uniform
  74126. * @return the material itself allowing "fluent" like uniform updates
  74127. */
  74128. setColor4(name: string, value: Color4): ShaderMaterial;
  74129. /**
  74130. * Set a vec2 in the shader from a Vector2.
  74131. * @param name Define the name of the uniform as defined in the shader
  74132. * @param value Define the value to give to the uniform
  74133. * @return the material itself allowing "fluent" like uniform updates
  74134. */
  74135. setVector2(name: string, value: Vector2): ShaderMaterial;
  74136. /**
  74137. * Set a vec3 in the shader from a Vector3.
  74138. * @param name Define the name of the uniform as defined in the shader
  74139. * @param value Define the value to give to the uniform
  74140. * @return the material itself allowing "fluent" like uniform updates
  74141. */
  74142. setVector3(name: string, value: Vector3): ShaderMaterial;
  74143. /**
  74144. * Set a vec4 in the shader from a Vector4.
  74145. * @param name Define the name of the uniform as defined in the shader
  74146. * @param value Define the value to give to the uniform
  74147. * @return the material itself allowing "fluent" like uniform updates
  74148. */
  74149. setVector4(name: string, value: Vector4): ShaderMaterial;
  74150. /**
  74151. * Set a mat4 in the shader from a Matrix.
  74152. * @param name Define the name of the uniform as defined in the shader
  74153. * @param value Define the value to give to the uniform
  74154. * @return the material itself allowing "fluent" like uniform updates
  74155. */
  74156. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74157. /**
  74158. * Set a mat3 in the shader from a Float32Array.
  74159. * @param name Define the name of the uniform as defined in the shader
  74160. * @param value Define the value to give to the uniform
  74161. * @return the material itself allowing "fluent" like uniform updates
  74162. */
  74163. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74164. /**
  74165. * Set a mat2 in the shader from a Float32Array.
  74166. * @param name Define the name of the uniform as defined in the shader
  74167. * @param value Define the value to give to the uniform
  74168. * @return the material itself allowing "fluent" like uniform updates
  74169. */
  74170. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  74171. /**
  74172. * Set a vec2 array in the shader from a number array.
  74173. * @param name Define the name of the uniform as defined in the shader
  74174. * @param value Define the value to give to the uniform
  74175. * @return the material itself allowing "fluent" like uniform updates
  74176. */
  74177. setArray2(name: string, value: number[]): ShaderMaterial;
  74178. /**
  74179. * Set a vec3 array in the shader from a number array.
  74180. * @param name Define the name of the uniform as defined in the shader
  74181. * @param value Define the value to give to the uniform
  74182. * @return the material itself allowing "fluent" like uniform updates
  74183. */
  74184. setArray3(name: string, value: number[]): ShaderMaterial;
  74185. private _checkCache;
  74186. /**
  74187. * Checks if the material is ready to render the requested mesh
  74188. * @param mesh Define the mesh to render
  74189. * @param useInstances Define whether or not the material is used with instances
  74190. * @returns true if ready, otherwise false
  74191. */
  74192. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  74193. /**
  74194. * Binds the world matrix to the material
  74195. * @param world defines the world transformation matrix
  74196. */
  74197. bindOnlyWorldMatrix(world: Matrix): void;
  74198. /**
  74199. * Binds the material to the mesh
  74200. * @param world defines the world transformation matrix
  74201. * @param mesh defines the mesh to bind the material to
  74202. */
  74203. bind(world: Matrix, mesh?: Mesh): void;
  74204. /**
  74205. * Gets the active textures from the material
  74206. * @returns an array of textures
  74207. */
  74208. getActiveTextures(): BaseTexture[];
  74209. /**
  74210. * Specifies if the material uses a texture
  74211. * @param texture defines the texture to check against the material
  74212. * @returns a boolean specifying if the material uses the texture
  74213. */
  74214. hasTexture(texture: BaseTexture): boolean;
  74215. /**
  74216. * Makes a duplicate of the material, and gives it a new name
  74217. * @param name defines the new name for the duplicated material
  74218. * @returns the cloned material
  74219. */
  74220. clone(name: string): ShaderMaterial;
  74221. /**
  74222. * Disposes the material
  74223. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  74224. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  74225. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  74226. */
  74227. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  74228. /**
  74229. * Serializes this material in a JSON representation
  74230. * @returns the serialized material object
  74231. */
  74232. serialize(): any;
  74233. /**
  74234. * Creates a shader material from parsed shader material data
  74235. * @param source defines the JSON represnetation of the material
  74236. * @param scene defines the hosting scene
  74237. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  74238. * @returns a new material
  74239. */
  74240. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  74241. }
  74242. }
  74243. declare module BABYLON {
  74244. /** @hidden */
  74245. export var colorPixelShader: {
  74246. name: string;
  74247. shader: string;
  74248. };
  74249. }
  74250. declare module BABYLON {
  74251. /** @hidden */
  74252. export var colorVertexShader: {
  74253. name: string;
  74254. shader: string;
  74255. };
  74256. }
  74257. declare module BABYLON {
  74258. /**
  74259. * Line mesh
  74260. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  74261. */
  74262. export class LinesMesh extends Mesh {
  74263. /**
  74264. * If vertex color should be applied to the mesh
  74265. */
  74266. useVertexColor?: boolean | undefined;
  74267. /**
  74268. * If vertex alpha should be applied to the mesh
  74269. */
  74270. useVertexAlpha?: boolean | undefined;
  74271. /**
  74272. * Color of the line (Default: White)
  74273. */
  74274. color: Color3;
  74275. /**
  74276. * Alpha of the line (Default: 1)
  74277. */
  74278. alpha: number;
  74279. /**
  74280. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74281. * This margin is expressed in world space coordinates, so its value may vary.
  74282. * Default value is 0.1
  74283. */
  74284. intersectionThreshold: number;
  74285. private _colorShader;
  74286. /**
  74287. * Creates a new LinesMesh
  74288. * @param name defines the name
  74289. * @param scene defines the hosting scene
  74290. * @param parent defines the parent mesh if any
  74291. * @param source defines the optional source LinesMesh used to clone data from
  74292. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74293. * When false, achieved by calling a clone(), also passing False.
  74294. * This will make creation of children, recursive.
  74295. * @param useVertexColor defines if this LinesMesh supports vertex color
  74296. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  74297. */
  74298. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  74299. /**
  74300. * If vertex color should be applied to the mesh
  74301. */
  74302. useVertexColor?: boolean | undefined,
  74303. /**
  74304. * If vertex alpha should be applied to the mesh
  74305. */
  74306. useVertexAlpha?: boolean | undefined);
  74307. /**
  74308. * Returns the string "LineMesh"
  74309. */
  74310. getClassName(): string;
  74311. /**
  74312. * @hidden
  74313. */
  74314. /**
  74315. * @hidden
  74316. */
  74317. material: Material;
  74318. /**
  74319. * @hidden
  74320. */
  74321. readonly checkCollisions: boolean;
  74322. /** @hidden */
  74323. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  74324. /** @hidden */
  74325. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  74326. /**
  74327. * Disposes of the line mesh
  74328. * @param doNotRecurse If children should be disposed
  74329. */
  74330. dispose(doNotRecurse?: boolean): void;
  74331. /**
  74332. * Returns a new LineMesh object cloned from the current one.
  74333. */
  74334. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  74335. /**
  74336. * Creates a new InstancedLinesMesh object from the mesh model.
  74337. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74338. * @param name defines the name of the new instance
  74339. * @returns a new InstancedLinesMesh
  74340. */
  74341. createInstance(name: string): InstancedLinesMesh;
  74342. }
  74343. /**
  74344. * Creates an instance based on a source LinesMesh
  74345. */
  74346. export class InstancedLinesMesh extends InstancedMesh {
  74347. /**
  74348. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  74349. * This margin is expressed in world space coordinates, so its value may vary.
  74350. * Initilized with the intersectionThreshold value of the source LinesMesh
  74351. */
  74352. intersectionThreshold: number;
  74353. constructor(name: string, source: LinesMesh);
  74354. /**
  74355. * Returns the string "InstancedLinesMesh".
  74356. */
  74357. getClassName(): string;
  74358. }
  74359. }
  74360. declare module BABYLON {
  74361. /** @hidden */
  74362. export var linePixelShader: {
  74363. name: string;
  74364. shader: string;
  74365. };
  74366. }
  74367. declare module BABYLON {
  74368. /** @hidden */
  74369. export var lineVertexShader: {
  74370. name: string;
  74371. shader: string;
  74372. };
  74373. }
  74374. declare module BABYLON {
  74375. interface AbstractMesh {
  74376. /**
  74377. * Disables the mesh edge rendering mode
  74378. * @returns the currentAbstractMesh
  74379. */
  74380. disableEdgesRendering(): AbstractMesh;
  74381. /**
  74382. * Enables the edge rendering mode on the mesh.
  74383. * This mode makes the mesh edges visible
  74384. * @param epsilon defines the maximal distance between two angles to detect a face
  74385. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74386. * @returns the currentAbstractMesh
  74387. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74388. */
  74389. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74390. /**
  74391. * Gets the edgesRenderer associated with the mesh
  74392. */
  74393. edgesRenderer: Nullable<EdgesRenderer>;
  74394. }
  74395. interface LinesMesh {
  74396. /**
  74397. * Enables the edge rendering mode on the mesh.
  74398. * This mode makes the mesh edges visible
  74399. * @param epsilon defines the maximal distance between two angles to detect a face
  74400. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74401. * @returns the currentAbstractMesh
  74402. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74403. */
  74404. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  74405. }
  74406. interface InstancedLinesMesh {
  74407. /**
  74408. * Enables the edge rendering mode on the mesh.
  74409. * This mode makes the mesh edges visible
  74410. * @param epsilon defines the maximal distance between two angles to detect a face
  74411. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  74412. * @returns the current InstancedLinesMesh
  74413. * @see https://www.babylonjs-playground.com/#19O9TU#0
  74414. */
  74415. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  74416. }
  74417. /**
  74418. * Defines the minimum contract an Edges renderer should follow.
  74419. */
  74420. export interface IEdgesRenderer extends IDisposable {
  74421. /**
  74422. * Gets or sets a boolean indicating if the edgesRenderer is active
  74423. */
  74424. isEnabled: boolean;
  74425. /**
  74426. * Renders the edges of the attached mesh,
  74427. */
  74428. render(): void;
  74429. /**
  74430. * Checks wether or not the edges renderer is ready to render.
  74431. * @return true if ready, otherwise false.
  74432. */
  74433. isReady(): boolean;
  74434. }
  74435. /**
  74436. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  74437. */
  74438. export class EdgesRenderer implements IEdgesRenderer {
  74439. /**
  74440. * Define the size of the edges with an orthographic camera
  74441. */
  74442. edgesWidthScalerForOrthographic: number;
  74443. /**
  74444. * Define the size of the edges with a perspective camera
  74445. */
  74446. edgesWidthScalerForPerspective: number;
  74447. protected _source: AbstractMesh;
  74448. protected _linesPositions: number[];
  74449. protected _linesNormals: number[];
  74450. protected _linesIndices: number[];
  74451. protected _epsilon: number;
  74452. protected _indicesCount: number;
  74453. protected _lineShader: ShaderMaterial;
  74454. protected _ib: WebGLBuffer;
  74455. protected _buffers: {
  74456. [key: string]: Nullable<VertexBuffer>;
  74457. };
  74458. protected _checkVerticesInsteadOfIndices: boolean;
  74459. private _meshRebuildObserver;
  74460. private _meshDisposeObserver;
  74461. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  74462. isEnabled: boolean;
  74463. /**
  74464. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  74465. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  74466. * @param source Mesh used to create edges
  74467. * @param epsilon sum of angles in adjacency to check for edge
  74468. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  74469. * @param generateEdgesLines - should generate Lines or only prepare resources.
  74470. */
  74471. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  74472. protected _prepareRessources(): void;
  74473. /** @hidden */
  74474. _rebuild(): void;
  74475. /**
  74476. * Releases the required resources for the edges renderer
  74477. */
  74478. dispose(): void;
  74479. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  74480. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  74481. /**
  74482. * Checks if the pair of p0 and p1 is en edge
  74483. * @param faceIndex
  74484. * @param edge
  74485. * @param faceNormals
  74486. * @param p0
  74487. * @param p1
  74488. * @private
  74489. */
  74490. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  74491. /**
  74492. * push line into the position, normal and index buffer
  74493. * @protected
  74494. */
  74495. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  74496. /**
  74497. * Generates lines edges from adjacencjes
  74498. * @private
  74499. */
  74500. _generateEdgesLines(): void;
  74501. /**
  74502. * Checks wether or not the edges renderer is ready to render.
  74503. * @return true if ready, otherwise false.
  74504. */
  74505. isReady(): boolean;
  74506. /**
  74507. * Renders the edges of the attached mesh,
  74508. */
  74509. render(): void;
  74510. }
  74511. /**
  74512. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  74513. */
  74514. export class LineEdgesRenderer extends EdgesRenderer {
  74515. /**
  74516. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  74517. * @param source LineMesh used to generate edges
  74518. * @param epsilon not important (specified angle for edge detection)
  74519. * @param checkVerticesInsteadOfIndices not important for LineMesh
  74520. */
  74521. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  74522. /**
  74523. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  74524. */
  74525. _generateEdgesLines(): void;
  74526. }
  74527. }
  74528. declare module BABYLON {
  74529. /**
  74530. * This represents the object necessary to create a rendering group.
  74531. * This is exclusively used and created by the rendering manager.
  74532. * To modify the behavior, you use the available helpers in your scene or meshes.
  74533. * @hidden
  74534. */
  74535. export class RenderingGroup {
  74536. index: number;
  74537. private _scene;
  74538. private _opaqueSubMeshes;
  74539. private _transparentSubMeshes;
  74540. private _alphaTestSubMeshes;
  74541. private _depthOnlySubMeshes;
  74542. private _particleSystems;
  74543. private _spriteManagers;
  74544. private _opaqueSortCompareFn;
  74545. private _alphaTestSortCompareFn;
  74546. private _transparentSortCompareFn;
  74547. private _renderOpaque;
  74548. private _renderAlphaTest;
  74549. private _renderTransparent;
  74550. private _edgesRenderers;
  74551. onBeforeTransparentRendering: () => void;
  74552. /**
  74553. * Set the opaque sort comparison function.
  74554. * If null the sub meshes will be render in the order they were created
  74555. */
  74556. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74557. /**
  74558. * Set the alpha test sort comparison function.
  74559. * If null the sub meshes will be render in the order they were created
  74560. */
  74561. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74562. /**
  74563. * Set the transparent sort comparison function.
  74564. * If null the sub meshes will be render in the order they were created
  74565. */
  74566. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  74567. /**
  74568. * Creates a new rendering group.
  74569. * @param index The rendering group index
  74570. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  74571. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  74572. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  74573. */
  74574. 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>);
  74575. /**
  74576. * Render all the sub meshes contained in the group.
  74577. * @param customRenderFunction Used to override the default render behaviour of the group.
  74578. * @returns true if rendered some submeshes.
  74579. */
  74580. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  74581. /**
  74582. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  74583. * @param subMeshes The submeshes to render
  74584. */
  74585. private renderOpaqueSorted;
  74586. /**
  74587. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  74588. * @param subMeshes The submeshes to render
  74589. */
  74590. private renderAlphaTestSorted;
  74591. /**
  74592. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  74593. * @param subMeshes The submeshes to render
  74594. */
  74595. private renderTransparentSorted;
  74596. /**
  74597. * Renders the submeshes in a specified order.
  74598. * @param subMeshes The submeshes to sort before render
  74599. * @param sortCompareFn The comparison function use to sort
  74600. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  74601. * @param transparent Specifies to activate blending if true
  74602. */
  74603. private static renderSorted;
  74604. /**
  74605. * Renders the submeshes in the order they were dispatched (no sort applied).
  74606. * @param subMeshes The submeshes to render
  74607. */
  74608. private static renderUnsorted;
  74609. /**
  74610. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74611. * are rendered back to front if in the same alpha index.
  74612. *
  74613. * @param a The first submesh
  74614. * @param b The second submesh
  74615. * @returns The result of the comparison
  74616. */
  74617. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  74618. /**
  74619. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74620. * are rendered back to front.
  74621. *
  74622. * @param a The first submesh
  74623. * @param b The second submesh
  74624. * @returns The result of the comparison
  74625. */
  74626. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  74627. /**
  74628. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  74629. * are rendered front to back (prevent overdraw).
  74630. *
  74631. * @param a The first submesh
  74632. * @param b The second submesh
  74633. * @returns The result of the comparison
  74634. */
  74635. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  74636. /**
  74637. * Resets the different lists of submeshes to prepare a new frame.
  74638. */
  74639. prepare(): void;
  74640. dispose(): void;
  74641. /**
  74642. * Inserts the submesh in its correct queue depending on its material.
  74643. * @param subMesh The submesh to dispatch
  74644. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74645. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74646. */
  74647. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74648. dispatchSprites(spriteManager: ISpriteManager): void;
  74649. dispatchParticles(particleSystem: IParticleSystem): void;
  74650. private _renderParticles;
  74651. private _renderSprites;
  74652. }
  74653. }
  74654. declare module BABYLON {
  74655. /**
  74656. * Interface describing the different options available in the rendering manager
  74657. * regarding Auto Clear between groups.
  74658. */
  74659. export interface IRenderingManagerAutoClearSetup {
  74660. /**
  74661. * Defines whether or not autoclear is enable.
  74662. */
  74663. autoClear: boolean;
  74664. /**
  74665. * Defines whether or not to autoclear the depth buffer.
  74666. */
  74667. depth: boolean;
  74668. /**
  74669. * Defines whether or not to autoclear the stencil buffer.
  74670. */
  74671. stencil: boolean;
  74672. }
  74673. /**
  74674. * This class is used by the onRenderingGroupObservable
  74675. */
  74676. export class RenderingGroupInfo {
  74677. /**
  74678. * The Scene that being rendered
  74679. */
  74680. scene: Scene;
  74681. /**
  74682. * The camera currently used for the rendering pass
  74683. */
  74684. camera: Nullable<Camera>;
  74685. /**
  74686. * The ID of the renderingGroup being processed
  74687. */
  74688. renderingGroupId: number;
  74689. }
  74690. /**
  74691. * This is the manager responsible of all the rendering for meshes sprites and particles.
  74692. * It is enable to manage the different groups as well as the different necessary sort functions.
  74693. * This should not be used directly aside of the few static configurations
  74694. */
  74695. export class RenderingManager {
  74696. /**
  74697. * The max id used for rendering groups (not included)
  74698. */
  74699. static MAX_RENDERINGGROUPS: number;
  74700. /**
  74701. * The min id used for rendering groups (included)
  74702. */
  74703. static MIN_RENDERINGGROUPS: number;
  74704. /**
  74705. * Used to globally prevent autoclearing scenes.
  74706. */
  74707. static AUTOCLEAR: boolean;
  74708. /**
  74709. * @hidden
  74710. */
  74711. _useSceneAutoClearSetup: boolean;
  74712. private _scene;
  74713. private _renderingGroups;
  74714. private _depthStencilBufferAlreadyCleaned;
  74715. private _autoClearDepthStencil;
  74716. private _customOpaqueSortCompareFn;
  74717. private _customAlphaTestSortCompareFn;
  74718. private _customTransparentSortCompareFn;
  74719. private _renderingGroupInfo;
  74720. /**
  74721. * Instantiates a new rendering group for a particular scene
  74722. * @param scene Defines the scene the groups belongs to
  74723. */
  74724. constructor(scene: Scene);
  74725. private _clearDepthStencilBuffer;
  74726. /**
  74727. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  74728. * @hidden
  74729. */
  74730. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  74731. /**
  74732. * Resets the different information of the group to prepare a new frame
  74733. * @hidden
  74734. */
  74735. reset(): void;
  74736. /**
  74737. * Dispose and release the group and its associated resources.
  74738. * @hidden
  74739. */
  74740. dispose(): void;
  74741. /**
  74742. * Clear the info related to rendering groups preventing retention points during dispose.
  74743. */
  74744. freeRenderingGroups(): void;
  74745. private _prepareRenderingGroup;
  74746. /**
  74747. * Add a sprite manager to the rendering manager in order to render it this frame.
  74748. * @param spriteManager Define the sprite manager to render
  74749. */
  74750. dispatchSprites(spriteManager: ISpriteManager): void;
  74751. /**
  74752. * Add a particle system to the rendering manager in order to render it this frame.
  74753. * @param particleSystem Define the particle system to render
  74754. */
  74755. dispatchParticles(particleSystem: IParticleSystem): void;
  74756. /**
  74757. * Add a submesh to the manager in order to render it this frame
  74758. * @param subMesh The submesh to dispatch
  74759. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  74760. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  74761. */
  74762. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  74763. /**
  74764. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  74765. * This allowed control for front to back rendering or reversly depending of the special needs.
  74766. *
  74767. * @param renderingGroupId The rendering group id corresponding to its index
  74768. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  74769. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  74770. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  74771. */
  74772. 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;
  74773. /**
  74774. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  74775. *
  74776. * @param renderingGroupId The rendering group id corresponding to its index
  74777. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  74778. * @param depth Automatically clears depth between groups if true and autoClear is true.
  74779. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  74780. */
  74781. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  74782. /**
  74783. * Gets the current auto clear configuration for one rendering group of the rendering
  74784. * manager.
  74785. * @param index the rendering group index to get the information for
  74786. * @returns The auto clear setup for the requested rendering group
  74787. */
  74788. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  74789. }
  74790. }
  74791. declare module BABYLON {
  74792. /**
  74793. * This Helps creating a texture that will be created from a camera in your scene.
  74794. * It is basically a dynamic texture that could be used to create special effects for instance.
  74795. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  74796. */
  74797. export class RenderTargetTexture extends Texture {
  74798. isCube: boolean;
  74799. /**
  74800. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  74801. */
  74802. static readonly REFRESHRATE_RENDER_ONCE: number;
  74803. /**
  74804. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  74805. */
  74806. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  74807. /**
  74808. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  74809. * the central point of your effect and can save a lot of performances.
  74810. */
  74811. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  74812. /**
  74813. * Use this predicate to dynamically define the list of mesh you want to render.
  74814. * If set, the renderList property will be overwritten.
  74815. */
  74816. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  74817. private _renderList;
  74818. /**
  74819. * Use this list to define the list of mesh you want to render.
  74820. */
  74821. renderList: Nullable<Array<AbstractMesh>>;
  74822. private _hookArray;
  74823. /**
  74824. * Define if particles should be rendered in your texture.
  74825. */
  74826. renderParticles: boolean;
  74827. /**
  74828. * Define if sprites should be rendered in your texture.
  74829. */
  74830. renderSprites: boolean;
  74831. /**
  74832. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  74833. */
  74834. coordinatesMode: number;
  74835. /**
  74836. * Define the camera used to render the texture.
  74837. */
  74838. activeCamera: Nullable<Camera>;
  74839. /**
  74840. * Override the render function of the texture with your own one.
  74841. */
  74842. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  74843. /**
  74844. * Define if camera post processes should be use while rendering the texture.
  74845. */
  74846. useCameraPostProcesses: boolean;
  74847. /**
  74848. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  74849. */
  74850. ignoreCameraViewport: boolean;
  74851. private _postProcessManager;
  74852. private _postProcesses;
  74853. private _resizeObserver;
  74854. /**
  74855. * An event triggered when the texture is unbind.
  74856. */
  74857. onBeforeBindObservable: Observable<RenderTargetTexture>;
  74858. /**
  74859. * An event triggered when the texture is unbind.
  74860. */
  74861. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  74862. private _onAfterUnbindObserver;
  74863. /**
  74864. * Set a after unbind callback in the texture.
  74865. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  74866. */
  74867. onAfterUnbind: () => void;
  74868. /**
  74869. * An event triggered before rendering the texture
  74870. */
  74871. onBeforeRenderObservable: Observable<number>;
  74872. private _onBeforeRenderObserver;
  74873. /**
  74874. * Set a before render callback in the texture.
  74875. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  74876. */
  74877. onBeforeRender: (faceIndex: number) => void;
  74878. /**
  74879. * An event triggered after rendering the texture
  74880. */
  74881. onAfterRenderObservable: Observable<number>;
  74882. private _onAfterRenderObserver;
  74883. /**
  74884. * Set a after render callback in the texture.
  74885. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  74886. */
  74887. onAfterRender: (faceIndex: number) => void;
  74888. /**
  74889. * An event triggered after the texture clear
  74890. */
  74891. onClearObservable: Observable<Engine>;
  74892. private _onClearObserver;
  74893. /**
  74894. * Set a clear callback in the texture.
  74895. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  74896. */
  74897. onClear: (Engine: Engine) => void;
  74898. /**
  74899. * Define the clear color of the Render Target if it should be different from the scene.
  74900. */
  74901. clearColor: Color4;
  74902. protected _size: number | {
  74903. width: number;
  74904. height: number;
  74905. };
  74906. protected _initialSizeParameter: number | {
  74907. width: number;
  74908. height: number;
  74909. } | {
  74910. ratio: number;
  74911. };
  74912. protected _sizeRatio: Nullable<number>;
  74913. /** @hidden */
  74914. _generateMipMaps: boolean;
  74915. protected _renderingManager: RenderingManager;
  74916. /** @hidden */
  74917. _waitingRenderList: string[];
  74918. protected _doNotChangeAspectRatio: boolean;
  74919. protected _currentRefreshId: number;
  74920. protected _refreshRate: number;
  74921. protected _textureMatrix: Matrix;
  74922. protected _samples: number;
  74923. protected _renderTargetOptions: RenderTargetCreationOptions;
  74924. /**
  74925. * Gets render target creation options that were used.
  74926. */
  74927. readonly renderTargetOptions: RenderTargetCreationOptions;
  74928. protected _engine: Engine;
  74929. protected _onRatioRescale(): void;
  74930. /**
  74931. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  74932. * It must define where the camera used to render the texture is set
  74933. */
  74934. boundingBoxPosition: Vector3;
  74935. private _boundingBoxSize;
  74936. /**
  74937. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  74938. * When defined, the cubemap will switch to local mode
  74939. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74940. * @example https://www.babylonjs-playground.com/#RNASML
  74941. */
  74942. boundingBoxSize: Vector3;
  74943. /**
  74944. * In case the RTT has been created with a depth texture, get the associated
  74945. * depth texture.
  74946. * Otherwise, return null.
  74947. */
  74948. depthStencilTexture: Nullable<InternalTexture>;
  74949. /**
  74950. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  74951. * or used a shadow, depth texture...
  74952. * @param name The friendly name of the texture
  74953. * @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)
  74954. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  74955. * @param generateMipMaps True if mip maps need to be generated after render.
  74956. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  74957. * @param type The type of the buffer in the RTT (int, half float, float...)
  74958. * @param isCube True if a cube texture needs to be created
  74959. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  74960. * @param generateDepthBuffer True to generate a depth buffer
  74961. * @param generateStencilBuffer True to generate a stencil buffer
  74962. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  74963. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  74964. * @param delayAllocation if the texture allocation should be delayed (default: false)
  74965. */
  74966. constructor(name: string, size: number | {
  74967. width: number;
  74968. height: number;
  74969. } | {
  74970. ratio: number;
  74971. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  74972. /**
  74973. * Creates a depth stencil texture.
  74974. * This is only available in WebGL 2 or with the depth texture extension available.
  74975. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  74976. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  74977. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  74978. */
  74979. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  74980. private _processSizeParameter;
  74981. /**
  74982. * Define the number of samples to use in case of MSAA.
  74983. * It defaults to one meaning no MSAA has been enabled.
  74984. */
  74985. samples: number;
  74986. /**
  74987. * Resets the refresh counter of the texture and start bak from scratch.
  74988. * Could be useful to regenerate the texture if it is setup to render only once.
  74989. */
  74990. resetRefreshCounter(): void;
  74991. /**
  74992. * Define the refresh rate of the texture or the rendering frequency.
  74993. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  74994. */
  74995. refreshRate: number;
  74996. /**
  74997. * Adds a post process to the render target rendering passes.
  74998. * @param postProcess define the post process to add
  74999. */
  75000. addPostProcess(postProcess: PostProcess): void;
  75001. /**
  75002. * Clear all the post processes attached to the render target
  75003. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75004. */
  75005. clearPostProcesses(dispose?: boolean): void;
  75006. /**
  75007. * Remove one of the post process from the list of attached post processes to the texture
  75008. * @param postProcess define the post process to remove from the list
  75009. */
  75010. removePostProcess(postProcess: PostProcess): void;
  75011. /** @hidden */
  75012. _shouldRender(): boolean;
  75013. /**
  75014. * Gets the actual render size of the texture.
  75015. * @returns the width of the render size
  75016. */
  75017. getRenderSize(): number;
  75018. /**
  75019. * Gets the actual render width of the texture.
  75020. * @returns the width of the render size
  75021. */
  75022. getRenderWidth(): number;
  75023. /**
  75024. * Gets the actual render height of the texture.
  75025. * @returns the height of the render size
  75026. */
  75027. getRenderHeight(): number;
  75028. /**
  75029. * Get if the texture can be rescaled or not.
  75030. */
  75031. readonly canRescale: boolean;
  75032. /**
  75033. * Resize the texture using a ratio.
  75034. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75035. */
  75036. scale(ratio: number): void;
  75037. /**
  75038. * Get the texture reflection matrix used to rotate/transform the reflection.
  75039. * @returns the reflection matrix
  75040. */
  75041. getReflectionTextureMatrix(): Matrix;
  75042. /**
  75043. * Resize the texture to a new desired size.
  75044. * Be carrefull as it will recreate all the data in the new texture.
  75045. * @param size Define the new size. It can be:
  75046. * - a number for squared texture,
  75047. * - an object containing { width: number, height: number }
  75048. * - or an object containing a ratio { ratio: number }
  75049. */
  75050. resize(size: number | {
  75051. width: number;
  75052. height: number;
  75053. } | {
  75054. ratio: number;
  75055. }): void;
  75056. /**
  75057. * Renders all the objects from the render list into the texture.
  75058. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75059. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75060. */
  75061. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75062. private _bestReflectionRenderTargetDimension;
  75063. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75064. private renderToTarget;
  75065. /**
  75066. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75067. * This allowed control for front to back rendering or reversly depending of the special needs.
  75068. *
  75069. * @param renderingGroupId The rendering group id corresponding to its index
  75070. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75071. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75072. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75073. */
  75074. 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;
  75075. /**
  75076. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75077. *
  75078. * @param renderingGroupId The rendering group id corresponding to its index
  75079. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75080. */
  75081. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75082. /**
  75083. * Clones the texture.
  75084. * @returns the cloned texture
  75085. */
  75086. clone(): RenderTargetTexture;
  75087. /**
  75088. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75089. * @returns The JSON representation of the texture
  75090. */
  75091. serialize(): any;
  75092. /**
  75093. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75094. */
  75095. disposeFramebufferObjects(): void;
  75096. /**
  75097. * Dispose the texture and release its associated resources.
  75098. */
  75099. dispose(): void;
  75100. /** @hidden */
  75101. _rebuild(): void;
  75102. /**
  75103. * Clear the info related to rendering groups preventing retention point in material dispose.
  75104. */
  75105. freeRenderingGroups(): void;
  75106. }
  75107. }
  75108. declare module BABYLON {
  75109. /**
  75110. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75111. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75112. * You can then easily use it as a reflectionTexture on a flat surface.
  75113. * In case the surface is not a plane, please consider relying on reflection probes.
  75114. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75115. */
  75116. export class MirrorTexture extends RenderTargetTexture {
  75117. private scene;
  75118. /**
  75119. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  75120. * 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.
  75121. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75122. */
  75123. mirrorPlane: Plane;
  75124. /**
  75125. * Define the blur ratio used to blur the reflection if needed.
  75126. */
  75127. blurRatio: number;
  75128. /**
  75129. * Define the adaptive blur kernel used to blur the reflection if needed.
  75130. * This will autocompute the closest best match for the `blurKernel`
  75131. */
  75132. adaptiveBlurKernel: number;
  75133. /**
  75134. * Define the blur kernel used to blur the reflection if needed.
  75135. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75136. */
  75137. blurKernel: number;
  75138. /**
  75139. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  75140. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75141. */
  75142. blurKernelX: number;
  75143. /**
  75144. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  75145. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  75146. */
  75147. blurKernelY: number;
  75148. private _autoComputeBlurKernel;
  75149. protected _onRatioRescale(): void;
  75150. private _updateGammaSpace;
  75151. private _imageProcessingConfigChangeObserver;
  75152. private _transformMatrix;
  75153. private _mirrorMatrix;
  75154. private _savedViewMatrix;
  75155. private _blurX;
  75156. private _blurY;
  75157. private _adaptiveBlurKernel;
  75158. private _blurKernelX;
  75159. private _blurKernelY;
  75160. private _blurRatio;
  75161. /**
  75162. * Instantiates a Mirror Texture.
  75163. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75164. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75165. * You can then easily use it as a reflectionTexture on a flat surface.
  75166. * In case the surface is not a plane, please consider relying on reflection probes.
  75167. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75168. * @param name
  75169. * @param size
  75170. * @param scene
  75171. * @param generateMipMaps
  75172. * @param type
  75173. * @param samplingMode
  75174. * @param generateDepthBuffer
  75175. */
  75176. constructor(name: string, size: number | {
  75177. width: number;
  75178. height: number;
  75179. } | {
  75180. ratio: number;
  75181. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  75182. private _preparePostProcesses;
  75183. /**
  75184. * Clone the mirror texture.
  75185. * @returns the cloned texture
  75186. */
  75187. clone(): MirrorTexture;
  75188. /**
  75189. * Serialize the texture to a JSON representation you could use in Parse later on
  75190. * @returns the serialized JSON representation
  75191. */
  75192. serialize(): any;
  75193. /**
  75194. * Dispose the texture and release its associated resources.
  75195. */
  75196. dispose(): void;
  75197. }
  75198. }
  75199. declare module BABYLON {
  75200. /**
  75201. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75202. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75203. */
  75204. export class Texture extends BaseTexture {
  75205. /** @hidden */
  75206. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  75207. /** @hidden */
  75208. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  75209. /** @hidden */
  75210. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  75211. /** nearest is mag = nearest and min = nearest and mip = linear */
  75212. static readonly NEAREST_SAMPLINGMODE: number;
  75213. /** nearest is mag = nearest and min = nearest and mip = linear */
  75214. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  75215. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75216. static readonly BILINEAR_SAMPLINGMODE: number;
  75217. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75218. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  75219. /** Trilinear is mag = linear and min = linear and mip = linear */
  75220. static readonly TRILINEAR_SAMPLINGMODE: number;
  75221. /** Trilinear is mag = linear and min = linear and mip = linear */
  75222. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  75223. /** mag = nearest and min = nearest and mip = nearest */
  75224. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  75225. /** mag = nearest and min = linear and mip = nearest */
  75226. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  75227. /** mag = nearest and min = linear and mip = linear */
  75228. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  75229. /** mag = nearest and min = linear and mip = none */
  75230. static readonly NEAREST_LINEAR: number;
  75231. /** mag = nearest and min = nearest and mip = none */
  75232. static readonly NEAREST_NEAREST: number;
  75233. /** mag = linear and min = nearest and mip = nearest */
  75234. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  75235. /** mag = linear and min = nearest and mip = linear */
  75236. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  75237. /** mag = linear and min = linear and mip = none */
  75238. static readonly LINEAR_LINEAR: number;
  75239. /** mag = linear and min = nearest and mip = none */
  75240. static readonly LINEAR_NEAREST: number;
  75241. /** Explicit coordinates mode */
  75242. static readonly EXPLICIT_MODE: number;
  75243. /** Spherical coordinates mode */
  75244. static readonly SPHERICAL_MODE: number;
  75245. /** Planar coordinates mode */
  75246. static readonly PLANAR_MODE: number;
  75247. /** Cubic coordinates mode */
  75248. static readonly CUBIC_MODE: number;
  75249. /** Projection coordinates mode */
  75250. static readonly PROJECTION_MODE: number;
  75251. /** Inverse Cubic coordinates mode */
  75252. static readonly SKYBOX_MODE: number;
  75253. /** Inverse Cubic coordinates mode */
  75254. static readonly INVCUBIC_MODE: number;
  75255. /** Equirectangular coordinates mode */
  75256. static readonly EQUIRECTANGULAR_MODE: number;
  75257. /** Equirectangular Fixed coordinates mode */
  75258. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  75259. /** Equirectangular Fixed Mirrored coordinates mode */
  75260. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75261. /** Texture is not repeating outside of 0..1 UVs */
  75262. static readonly CLAMP_ADDRESSMODE: number;
  75263. /** Texture is repeating outside of 0..1 UVs */
  75264. static readonly WRAP_ADDRESSMODE: number;
  75265. /** Texture is repeating and mirrored */
  75266. static readonly MIRROR_ADDRESSMODE: number;
  75267. /**
  75268. * 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
  75269. */
  75270. static UseSerializedUrlIfAny: boolean;
  75271. /**
  75272. * Define the url of the texture.
  75273. */
  75274. url: Nullable<string>;
  75275. /**
  75276. * Define an offset on the texture to offset the u coordinates of the UVs
  75277. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75278. */
  75279. uOffset: number;
  75280. /**
  75281. * Define an offset on the texture to offset the v coordinates of the UVs
  75282. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  75283. */
  75284. vOffset: number;
  75285. /**
  75286. * Define an offset on the texture to scale the u coordinates of the UVs
  75287. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75288. */
  75289. uScale: number;
  75290. /**
  75291. * Define an offset on the texture to scale the v coordinates of the UVs
  75292. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  75293. */
  75294. vScale: number;
  75295. /**
  75296. * Define an offset on the texture to rotate around the u coordinates of the UVs
  75297. * @see http://doc.babylonjs.com/how_to/more_materials
  75298. */
  75299. uAng: number;
  75300. /**
  75301. * Define an offset on the texture to rotate around the v coordinates of the UVs
  75302. * @see http://doc.babylonjs.com/how_to/more_materials
  75303. */
  75304. vAng: number;
  75305. /**
  75306. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  75307. * @see http://doc.babylonjs.com/how_to/more_materials
  75308. */
  75309. wAng: number;
  75310. /**
  75311. * Defines the center of rotation (U)
  75312. */
  75313. uRotationCenter: number;
  75314. /**
  75315. * Defines the center of rotation (V)
  75316. */
  75317. vRotationCenter: number;
  75318. /**
  75319. * Defines the center of rotation (W)
  75320. */
  75321. wRotationCenter: number;
  75322. /**
  75323. * Are mip maps generated for this texture or not.
  75324. */
  75325. readonly noMipmap: boolean;
  75326. private _noMipmap;
  75327. /** @hidden */
  75328. _invertY: boolean;
  75329. private _rowGenerationMatrix;
  75330. private _cachedTextureMatrix;
  75331. private _projectionModeMatrix;
  75332. private _t0;
  75333. private _t1;
  75334. private _t2;
  75335. private _cachedUOffset;
  75336. private _cachedVOffset;
  75337. private _cachedUScale;
  75338. private _cachedVScale;
  75339. private _cachedUAng;
  75340. private _cachedVAng;
  75341. private _cachedWAng;
  75342. private _cachedProjectionMatrixId;
  75343. private _cachedCoordinatesMode;
  75344. /** @hidden */
  75345. protected _initialSamplingMode: number;
  75346. /** @hidden */
  75347. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  75348. private _deleteBuffer;
  75349. protected _format: Nullable<number>;
  75350. private _delayedOnLoad;
  75351. private _delayedOnError;
  75352. /**
  75353. * Observable triggered once the texture has been loaded.
  75354. */
  75355. onLoadObservable: Observable<Texture>;
  75356. protected _isBlocking: boolean;
  75357. /**
  75358. * Is the texture preventing material to render while loading.
  75359. * If false, a default texture will be used instead of the loading one during the preparation step.
  75360. */
  75361. isBlocking: boolean;
  75362. /**
  75363. * Get the current sampling mode associated with the texture.
  75364. */
  75365. readonly samplingMode: number;
  75366. /**
  75367. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  75368. */
  75369. readonly invertY: boolean;
  75370. /**
  75371. * Instantiates a new texture.
  75372. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  75373. * @see http://doc.babylonjs.com/babylon101/materials#texture
  75374. * @param url define the url of the picture to load as a texture
  75375. * @param scene define the scene the texture will belong to
  75376. * @param noMipmap define if the texture will require mip maps or not
  75377. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75378. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75379. * @param onLoad define a callback triggered when the texture has been loaded
  75380. * @param onError define a callback triggered when an error occurred during the loading session
  75381. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75382. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75383. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75384. */
  75385. 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);
  75386. /**
  75387. * Update the url (and optional buffer) of this texture if url was null during construction.
  75388. * @param url the url of the texture
  75389. * @param buffer the buffer of the texture (defaults to null)
  75390. * @param onLoad callback called when the texture is loaded (defaults to null)
  75391. */
  75392. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  75393. /**
  75394. * Finish the loading sequence of a texture flagged as delayed load.
  75395. * @hidden
  75396. */
  75397. delayLoad(): void;
  75398. private _prepareRowForTextureGeneration;
  75399. /**
  75400. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  75401. * @returns the transform matrix of the texture.
  75402. */
  75403. getTextureMatrix(): Matrix;
  75404. /**
  75405. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  75406. * @returns The reflection texture transform
  75407. */
  75408. getReflectionTextureMatrix(): Matrix;
  75409. /**
  75410. * Clones the texture.
  75411. * @returns the cloned texture
  75412. */
  75413. clone(): Texture;
  75414. /**
  75415. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75416. * @returns The JSON representation of the texture
  75417. */
  75418. serialize(): any;
  75419. /**
  75420. * Get the current class name of the texture useful for serialization or dynamic coding.
  75421. * @returns "Texture"
  75422. */
  75423. getClassName(): string;
  75424. /**
  75425. * Dispose the texture and release its associated resources.
  75426. */
  75427. dispose(): void;
  75428. /**
  75429. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  75430. * @param parsedTexture Define the JSON representation of the texture
  75431. * @param scene Define the scene the parsed texture should be instantiated in
  75432. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  75433. * @returns The parsed texture if successful
  75434. */
  75435. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  75436. /**
  75437. * Creates a texture from its base 64 representation.
  75438. * @param data Define the base64 payload without the data: prefix
  75439. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75440. * @param scene Define the scene the texture should belong to
  75441. * @param noMipmap Forces the texture to not create mip map information if true
  75442. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75443. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75444. * @param onLoad define a callback triggered when the texture has been loaded
  75445. * @param onError define a callback triggered when an error occurred during the loading session
  75446. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75447. * @returns the created texture
  75448. */
  75449. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  75450. /**
  75451. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  75452. * @param data Define the base64 payload without the data: prefix
  75453. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  75454. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  75455. * @param scene Define the scene the texture should belong to
  75456. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  75457. * @param noMipmap Forces the texture to not create mip map information if true
  75458. * @param invertY define if the texture needs to be inverted on the y axis during loading
  75459. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  75460. * @param onLoad define a callback triggered when the texture has been loaded
  75461. * @param onError define a callback triggered when an error occurred during the loading session
  75462. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  75463. * @returns the created texture
  75464. */
  75465. 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;
  75466. }
  75467. }
  75468. declare module BABYLON {
  75469. /**
  75470. * Raw texture can help creating a texture directly from an array of data.
  75471. * This can be super useful if you either get the data from an uncompressed source or
  75472. * if you wish to create your texture pixel by pixel.
  75473. */
  75474. export class RawTexture extends Texture {
  75475. /**
  75476. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75477. */
  75478. format: number;
  75479. private _engine;
  75480. /**
  75481. * Instantiates a new RawTexture.
  75482. * Raw texture can help creating a texture directly from an array of data.
  75483. * This can be super useful if you either get the data from an uncompressed source or
  75484. * if you wish to create your texture pixel by pixel.
  75485. * @param data define the array of data to use to create the texture
  75486. * @param width define the width of the texture
  75487. * @param height define the height of the texture
  75488. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75489. * @param scene define the scene the texture belongs to
  75490. * @param generateMipMaps define whether mip maps should be generated or not
  75491. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75492. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75493. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75494. */
  75495. constructor(data: ArrayBufferView, width: number, height: number,
  75496. /**
  75497. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  75498. */
  75499. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  75500. /**
  75501. * Updates the texture underlying data.
  75502. * @param data Define the new data of the texture
  75503. */
  75504. update(data: ArrayBufferView): void;
  75505. /**
  75506. * Creates a luminance texture from some data.
  75507. * @param data Define the texture data
  75508. * @param width Define the width of the texture
  75509. * @param height Define the height of the texture
  75510. * @param scene Define the scene the texture belongs to
  75511. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75512. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75513. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75514. * @returns the luminance texture
  75515. */
  75516. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75517. /**
  75518. * Creates a luminance alpha texture from some data.
  75519. * @param data Define the texture data
  75520. * @param width Define the width of the texture
  75521. * @param height Define the height of the texture
  75522. * @param scene Define the scene the texture belongs to
  75523. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75524. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75525. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75526. * @returns the luminance alpha texture
  75527. */
  75528. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75529. /**
  75530. * Creates an alpha texture from some data.
  75531. * @param data Define the texture data
  75532. * @param width Define the width of the texture
  75533. * @param height Define the height of the texture
  75534. * @param scene Define the scene the texture belongs to
  75535. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75536. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75537. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75538. * @returns the alpha texture
  75539. */
  75540. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  75541. /**
  75542. * Creates a RGB texture from some data.
  75543. * @param data Define the texture data
  75544. * @param width Define the width of the texture
  75545. * @param height Define the height of the texture
  75546. * @param scene Define the scene the texture belongs to
  75547. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75548. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75549. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75550. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75551. * @returns the RGB alpha texture
  75552. */
  75553. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75554. /**
  75555. * Creates a RGBA texture from some data.
  75556. * @param data Define the texture data
  75557. * @param width Define the width of the texture
  75558. * @param height Define the height of the texture
  75559. * @param scene Define the scene the texture belongs to
  75560. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75561. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75562. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75563. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75564. * @returns the RGBA texture
  75565. */
  75566. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75567. /**
  75568. * Creates a R texture from some data.
  75569. * @param data Define the texture data
  75570. * @param width Define the width of the texture
  75571. * @param height Define the height of the texture
  75572. * @param scene Define the scene the texture belongs to
  75573. * @param generateMipMaps Define whether or not to create mip maps for the texture
  75574. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  75575. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  75576. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  75577. * @returns the R texture
  75578. */
  75579. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  75580. }
  75581. }
  75582. declare module BABYLON {
  75583. /**
  75584. * Defines a runtime animation
  75585. */
  75586. export class RuntimeAnimation {
  75587. private _events;
  75588. /**
  75589. * The current frame of the runtime animation
  75590. */
  75591. private _currentFrame;
  75592. /**
  75593. * The animation used by the runtime animation
  75594. */
  75595. private _animation;
  75596. /**
  75597. * The target of the runtime animation
  75598. */
  75599. private _target;
  75600. /**
  75601. * The initiating animatable
  75602. */
  75603. private _host;
  75604. /**
  75605. * The original value of the runtime animation
  75606. */
  75607. private _originalValue;
  75608. /**
  75609. * The original blend value of the runtime animation
  75610. */
  75611. private _originalBlendValue;
  75612. /**
  75613. * The offsets cache of the runtime animation
  75614. */
  75615. private _offsetsCache;
  75616. /**
  75617. * The high limits cache of the runtime animation
  75618. */
  75619. private _highLimitsCache;
  75620. /**
  75621. * Specifies if the runtime animation has been stopped
  75622. */
  75623. private _stopped;
  75624. /**
  75625. * The blending factor of the runtime animation
  75626. */
  75627. private _blendingFactor;
  75628. /**
  75629. * The BabylonJS scene
  75630. */
  75631. private _scene;
  75632. /**
  75633. * The current value of the runtime animation
  75634. */
  75635. private _currentValue;
  75636. /** @hidden */
  75637. _workValue: any;
  75638. /**
  75639. * The active target of the runtime animation
  75640. */
  75641. private _activeTarget;
  75642. /**
  75643. * The target path of the runtime animation
  75644. */
  75645. private _targetPath;
  75646. /**
  75647. * The weight of the runtime animation
  75648. */
  75649. private _weight;
  75650. /**
  75651. * The ratio offset of the runtime animation
  75652. */
  75653. private _ratioOffset;
  75654. /**
  75655. * The previous delay of the runtime animation
  75656. */
  75657. private _previousDelay;
  75658. /**
  75659. * The previous ratio of the runtime animation
  75660. */
  75661. private _previousRatio;
  75662. /**
  75663. * Gets the current frame of the runtime animation
  75664. */
  75665. readonly currentFrame: number;
  75666. /**
  75667. * Gets the weight of the runtime animation
  75668. */
  75669. readonly weight: number;
  75670. /**
  75671. * Gets the current value of the runtime animation
  75672. */
  75673. readonly currentValue: any;
  75674. /**
  75675. * Gets the target path of the runtime animation
  75676. */
  75677. readonly targetPath: string;
  75678. /**
  75679. * Gets the actual target of the runtime animation
  75680. */
  75681. readonly target: any;
  75682. /**
  75683. * Create a new RuntimeAnimation object
  75684. * @param target defines the target of the animation
  75685. * @param animation defines the source animation object
  75686. * @param scene defines the hosting scene
  75687. * @param host defines the initiating Animatable
  75688. */
  75689. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  75690. /**
  75691. * Gets the animation from the runtime animation
  75692. */
  75693. readonly animation: Animation;
  75694. /**
  75695. * Resets the runtime animation to the beginning
  75696. * @param restoreOriginal defines whether to restore the target property to the original value
  75697. */
  75698. reset(restoreOriginal?: boolean): void;
  75699. /**
  75700. * Specifies if the runtime animation is stopped
  75701. * @returns Boolean specifying if the runtime animation is stopped
  75702. */
  75703. isStopped(): boolean;
  75704. /**
  75705. * Disposes of the runtime animation
  75706. */
  75707. dispose(): void;
  75708. /**
  75709. * Interpolates the animation from the current frame
  75710. * @param currentFrame The frame to interpolate the animation to
  75711. * @param repeatCount The number of times that the animation should loop
  75712. * @param loopMode The type of looping mode to use
  75713. * @param offsetValue Animation offset value
  75714. * @param highLimitValue The high limit value
  75715. * @returns The interpolated value
  75716. */
  75717. private _interpolate;
  75718. /**
  75719. * Apply the interpolated value to the target
  75720. * @param currentValue defines the value computed by the animation
  75721. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  75722. */
  75723. setValue(currentValue: any, weight?: number): void;
  75724. private _setValue;
  75725. /**
  75726. * Gets the loop pmode of the runtime animation
  75727. * @returns Loop Mode
  75728. */
  75729. private _getCorrectLoopMode;
  75730. /**
  75731. * Move the current animation to a given frame
  75732. * @param frame defines the frame to move to
  75733. */
  75734. goToFrame(frame: number): void;
  75735. /**
  75736. * @hidden Internal use only
  75737. */
  75738. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  75739. /**
  75740. * Execute the current animation
  75741. * @param delay defines the delay to add to the current frame
  75742. * @param from defines the lower bound of the animation range
  75743. * @param to defines the upper bound of the animation range
  75744. * @param loop defines if the current animation must loop
  75745. * @param speedRatio defines the current speed ratio
  75746. * @param weight defines the weight of the animation (default is -1 so no weight)
  75747. * @param onLoop optional callback called when animation loops
  75748. * @returns a boolean indicating if the animation is running
  75749. */
  75750. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  75751. }
  75752. }
  75753. declare module BABYLON {
  75754. /**
  75755. * Class used to store an actual running animation
  75756. */
  75757. export class Animatable {
  75758. /** defines the target object */
  75759. target: any;
  75760. /** defines the starting frame number (default is 0) */
  75761. fromFrame: number;
  75762. /** defines the ending frame number (default is 100) */
  75763. toFrame: number;
  75764. /** defines if the animation must loop (default is false) */
  75765. loopAnimation: boolean;
  75766. /** defines a callback to call when animation ends if it is not looping */
  75767. onAnimationEnd?: (() => void) | null | undefined;
  75768. /** defines a callback to call when animation loops */
  75769. onAnimationLoop?: (() => void) | null | undefined;
  75770. private _localDelayOffset;
  75771. private _pausedDelay;
  75772. private _runtimeAnimations;
  75773. private _paused;
  75774. private _scene;
  75775. private _speedRatio;
  75776. private _weight;
  75777. private _syncRoot;
  75778. /**
  75779. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  75780. * This will only apply for non looping animation (default is true)
  75781. */
  75782. disposeOnEnd: boolean;
  75783. /**
  75784. * Gets a boolean indicating if the animation has started
  75785. */
  75786. animationStarted: boolean;
  75787. /**
  75788. * Observer raised when the animation ends
  75789. */
  75790. onAnimationEndObservable: Observable<Animatable>;
  75791. /**
  75792. * Observer raised when the animation loops
  75793. */
  75794. onAnimationLoopObservable: Observable<Animatable>;
  75795. /**
  75796. * Gets the root Animatable used to synchronize and normalize animations
  75797. */
  75798. readonly syncRoot: Animatable;
  75799. /**
  75800. * Gets the current frame of the first RuntimeAnimation
  75801. * Used to synchronize Animatables
  75802. */
  75803. readonly masterFrame: number;
  75804. /**
  75805. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  75806. */
  75807. weight: number;
  75808. /**
  75809. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  75810. */
  75811. speedRatio: number;
  75812. /**
  75813. * Creates a new Animatable
  75814. * @param scene defines the hosting scene
  75815. * @param target defines the target object
  75816. * @param fromFrame defines the starting frame number (default is 0)
  75817. * @param toFrame defines the ending frame number (default is 100)
  75818. * @param loopAnimation defines if the animation must loop (default is false)
  75819. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  75820. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  75821. * @param animations defines a group of animation to add to the new Animatable
  75822. * @param onAnimationLoop defines a callback to call when animation loops
  75823. */
  75824. constructor(scene: Scene,
  75825. /** defines the target object */
  75826. target: any,
  75827. /** defines the starting frame number (default is 0) */
  75828. fromFrame?: number,
  75829. /** defines the ending frame number (default is 100) */
  75830. toFrame?: number,
  75831. /** defines if the animation must loop (default is false) */
  75832. loopAnimation?: boolean, speedRatio?: number,
  75833. /** defines a callback to call when animation ends if it is not looping */
  75834. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  75835. /** defines a callback to call when animation loops */
  75836. onAnimationLoop?: (() => void) | null | undefined);
  75837. /**
  75838. * Synchronize and normalize current Animatable with a source Animatable
  75839. * This is useful when using animation weights and when animations are not of the same length
  75840. * @param root defines the root Animatable to synchronize with
  75841. * @returns the current Animatable
  75842. */
  75843. syncWith(root: Animatable): Animatable;
  75844. /**
  75845. * Gets the list of runtime animations
  75846. * @returns an array of RuntimeAnimation
  75847. */
  75848. getAnimations(): RuntimeAnimation[];
  75849. /**
  75850. * Adds more animations to the current animatable
  75851. * @param target defines the target of the animations
  75852. * @param animations defines the new animations to add
  75853. */
  75854. appendAnimations(target: any, animations: Animation[]): void;
  75855. /**
  75856. * Gets the source animation for a specific property
  75857. * @param property defines the propertyu to look for
  75858. * @returns null or the source animation for the given property
  75859. */
  75860. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  75861. /**
  75862. * Gets the runtime animation for a specific property
  75863. * @param property defines the propertyu to look for
  75864. * @returns null or the runtime animation for the given property
  75865. */
  75866. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  75867. /**
  75868. * Resets the animatable to its original state
  75869. */
  75870. reset(): void;
  75871. /**
  75872. * Allows the animatable to blend with current running animations
  75873. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75874. * @param blendingSpeed defines the blending speed to use
  75875. */
  75876. enableBlending(blendingSpeed: number): void;
  75877. /**
  75878. * Disable animation blending
  75879. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  75880. */
  75881. disableBlending(): void;
  75882. /**
  75883. * Jump directly to a given frame
  75884. * @param frame defines the frame to jump to
  75885. */
  75886. goToFrame(frame: number): void;
  75887. /**
  75888. * Pause the animation
  75889. */
  75890. pause(): void;
  75891. /**
  75892. * Restart the animation
  75893. */
  75894. restart(): void;
  75895. private _raiseOnAnimationEnd;
  75896. /**
  75897. * Stop and delete the current animation
  75898. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  75899. * @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)
  75900. */
  75901. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  75902. /**
  75903. * Wait asynchronously for the animation to end
  75904. * @returns a promise which will be fullfilled when the animation ends
  75905. */
  75906. waitAsync(): Promise<Animatable>;
  75907. /** @hidden */
  75908. _animate(delay: number): boolean;
  75909. }
  75910. interface Scene {
  75911. /** @hidden */
  75912. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  75913. /** @hidden */
  75914. _processLateAnimationBindingsForMatrices(holder: {
  75915. totalWeight: number;
  75916. animations: RuntimeAnimation[];
  75917. originalValue: Matrix;
  75918. }): any;
  75919. /** @hidden */
  75920. _processLateAnimationBindingsForQuaternions(holder: {
  75921. totalWeight: number;
  75922. animations: RuntimeAnimation[];
  75923. originalValue: Quaternion;
  75924. }, refQuaternion: Quaternion): Quaternion;
  75925. /** @hidden */
  75926. _processLateAnimationBindings(): void;
  75927. /**
  75928. * Will start the animation sequence of a given target
  75929. * @param target defines the target
  75930. * @param from defines from which frame should animation start
  75931. * @param to defines until which frame should animation run.
  75932. * @param weight defines the weight to apply to the animation (1.0 by default)
  75933. * @param loop defines if the animation loops
  75934. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75935. * @param onAnimationEnd defines the function to be executed when the animation ends
  75936. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75937. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75938. * @param onAnimationLoop defines the callback to call when an animation loops
  75939. * @returns the animatable object created for this animation
  75940. */
  75941. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75942. /**
  75943. * Will start the animation sequence of a given target
  75944. * @param target defines the target
  75945. * @param from defines from which frame should animation start
  75946. * @param to defines until which frame should animation run.
  75947. * @param loop defines if the animation loops
  75948. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75949. * @param onAnimationEnd defines the function to be executed when the animation ends
  75950. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75951. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75952. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  75953. * @param onAnimationLoop defines the callback to call when an animation loops
  75954. * @returns the animatable object created for this animation
  75955. */
  75956. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  75957. /**
  75958. * Will start the animation sequence of a given target and its hierarchy
  75959. * @param target defines the target
  75960. * @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.
  75961. * @param from defines from which frame should animation start
  75962. * @param to defines until which frame should animation run.
  75963. * @param loop defines if the animation loops
  75964. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  75965. * @param onAnimationEnd defines the function to be executed when the animation ends
  75966. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  75967. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  75968. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  75969. * @param onAnimationLoop defines the callback to call when an animation loops
  75970. * @returns the list of created animatables
  75971. */
  75972. 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[];
  75973. /**
  75974. * Begin a new animation on a given node
  75975. * @param target defines the target where the animation will take place
  75976. * @param animations defines the list of animations to start
  75977. * @param from defines the initial value
  75978. * @param to defines the final value
  75979. * @param loop defines if you want animation to loop (off by default)
  75980. * @param speedRatio defines the speed ratio to apply to all animations
  75981. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75982. * @param onAnimationLoop defines the callback to call when an animation loops
  75983. * @returns the list of created animatables
  75984. */
  75985. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  75986. /**
  75987. * Begin a new animation on a given node and its hierarchy
  75988. * @param target defines the root node where the animation will take place
  75989. * @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.
  75990. * @param animations defines the list of animations to start
  75991. * @param from defines the initial value
  75992. * @param to defines the final value
  75993. * @param loop defines if you want animation to loop (off by default)
  75994. * @param speedRatio defines the speed ratio to apply to all animations
  75995. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  75996. * @param onAnimationLoop defines the callback to call when an animation loops
  75997. * @returns the list of animatables created for all nodes
  75998. */
  75999. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76000. /**
  76001. * Gets the animatable associated with a specific target
  76002. * @param target defines the target of the animatable
  76003. * @returns the required animatable if found
  76004. */
  76005. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76006. /**
  76007. * Gets all animatables associated with a given target
  76008. * @param target defines the target to look animatables for
  76009. * @returns an array of Animatables
  76010. */
  76011. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76012. /**
  76013. * Will stop the animation of the given target
  76014. * @param target - the target
  76015. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76016. * @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)
  76017. */
  76018. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76019. /**
  76020. * Stops and removes all animations that have been applied to the scene
  76021. */
  76022. stopAllAnimations(): void;
  76023. }
  76024. interface Bone {
  76025. /**
  76026. * Copy an animation range from another bone
  76027. * @param source defines the source bone
  76028. * @param rangeName defines the range name to copy
  76029. * @param frameOffset defines the frame offset
  76030. * @param rescaleAsRequired defines if rescaling must be applied if required
  76031. * @param skelDimensionsRatio defines the scaling ratio
  76032. * @returns true if operation was successful
  76033. */
  76034. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76035. }
  76036. }
  76037. declare module BABYLON {
  76038. /**
  76039. * Class used to handle skinning animations
  76040. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76041. */
  76042. export class Skeleton implements IAnimatable {
  76043. /** defines the skeleton name */
  76044. name: string;
  76045. /** defines the skeleton Id */
  76046. id: string;
  76047. /**
  76048. * Defines the list of child bones
  76049. */
  76050. bones: Bone[];
  76051. /**
  76052. * Defines an estimate of the dimension of the skeleton at rest
  76053. */
  76054. dimensionsAtRest: Vector3;
  76055. /**
  76056. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76057. */
  76058. needInitialSkinMatrix: boolean;
  76059. /**
  76060. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76061. */
  76062. overrideMesh: Nullable<AbstractMesh>;
  76063. /**
  76064. * Gets the list of animations attached to this skeleton
  76065. */
  76066. animations: Array<Animation>;
  76067. private _scene;
  76068. private _isDirty;
  76069. private _transformMatrices;
  76070. private _transformMatrixTexture;
  76071. private _meshesWithPoseMatrix;
  76072. private _animatables;
  76073. private _identity;
  76074. private _synchronizedWithMesh;
  76075. private _ranges;
  76076. private _lastAbsoluteTransformsUpdateId;
  76077. private _canUseTextureForBones;
  76078. /** @hidden */
  76079. _numBonesWithLinkedTransformNode: number;
  76080. /**
  76081. * Specifies if the skeleton should be serialized
  76082. */
  76083. doNotSerialize: boolean;
  76084. /**
  76085. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76086. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76087. */
  76088. useTextureToStoreBoneMatrices: boolean;
  76089. private _animationPropertiesOverride;
  76090. /**
  76091. * Gets or sets the animation properties override
  76092. */
  76093. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76094. /**
  76095. * An observable triggered before computing the skeleton's matrices
  76096. */
  76097. onBeforeComputeObservable: Observable<Skeleton>;
  76098. /**
  76099. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76100. */
  76101. readonly isUsingTextureForMatrices: boolean;
  76102. /**
  76103. * Creates a new skeleton
  76104. * @param name defines the skeleton name
  76105. * @param id defines the skeleton Id
  76106. * @param scene defines the hosting scene
  76107. */
  76108. constructor(
  76109. /** defines the skeleton name */
  76110. name: string,
  76111. /** defines the skeleton Id */
  76112. id: string, scene: Scene);
  76113. /**
  76114. * Gets the current object class name.
  76115. * @return the class name
  76116. */
  76117. getClassName(): string;
  76118. /**
  76119. * Returns an array containing the root bones
  76120. * @returns an array containing the root bones
  76121. */
  76122. getChildren(): Array<Bone>;
  76123. /**
  76124. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76125. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76126. * @returns a Float32Array containing matrices data
  76127. */
  76128. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76129. /**
  76130. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76131. * @returns a raw texture containing the data
  76132. */
  76133. getTransformMatrixTexture(): Nullable<RawTexture>;
  76134. /**
  76135. * Gets the current hosting scene
  76136. * @returns a scene object
  76137. */
  76138. getScene(): Scene;
  76139. /**
  76140. * Gets a string representing the current skeleton data
  76141. * @param fullDetails defines a boolean indicating if we want a verbose version
  76142. * @returns a string representing the current skeleton data
  76143. */
  76144. toString(fullDetails?: boolean): string;
  76145. /**
  76146. * Get bone's index searching by name
  76147. * @param name defines bone's name to search for
  76148. * @return the indice of the bone. Returns -1 if not found
  76149. */
  76150. getBoneIndexByName(name: string): number;
  76151. /**
  76152. * Creater a new animation range
  76153. * @param name defines the name of the range
  76154. * @param from defines the start key
  76155. * @param to defines the end key
  76156. */
  76157. createAnimationRange(name: string, from: number, to: number): void;
  76158. /**
  76159. * Delete a specific animation range
  76160. * @param name defines the name of the range
  76161. * @param deleteFrames defines if frames must be removed as well
  76162. */
  76163. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76164. /**
  76165. * Gets a specific animation range
  76166. * @param name defines the name of the range to look for
  76167. * @returns the requested animation range or null if not found
  76168. */
  76169. getAnimationRange(name: string): Nullable<AnimationRange>;
  76170. /**
  76171. * Gets the list of all animation ranges defined on this skeleton
  76172. * @returns an array
  76173. */
  76174. getAnimationRanges(): Nullable<AnimationRange>[];
  76175. /**
  76176. * Copy animation range from a source skeleton.
  76177. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76178. * @param source defines the source skeleton
  76179. * @param name defines the name of the range to copy
  76180. * @param rescaleAsRequired defines if rescaling must be applied if required
  76181. * @returns true if operation was successful
  76182. */
  76183. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76184. /**
  76185. * Forces the skeleton to go to rest pose
  76186. */
  76187. returnToRest(): void;
  76188. private _getHighestAnimationFrame;
  76189. /**
  76190. * Begin a specific animation range
  76191. * @param name defines the name of the range to start
  76192. * @param loop defines if looping must be turned on (false by default)
  76193. * @param speedRatio defines the speed ratio to apply (1 by default)
  76194. * @param onAnimationEnd defines a callback which will be called when animation will end
  76195. * @returns a new animatable
  76196. */
  76197. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76198. /** @hidden */
  76199. _markAsDirty(): void;
  76200. /** @hidden */
  76201. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76202. /** @hidden */
  76203. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76204. private _computeTransformMatrices;
  76205. /**
  76206. * Build all resources required to render a skeleton
  76207. */
  76208. prepare(): void;
  76209. /**
  76210. * Gets the list of animatables currently running for this skeleton
  76211. * @returns an array of animatables
  76212. */
  76213. getAnimatables(): IAnimatable[];
  76214. /**
  76215. * Clone the current skeleton
  76216. * @param name defines the name of the new skeleton
  76217. * @param id defines the id of the enw skeleton
  76218. * @returns the new skeleton
  76219. */
  76220. clone(name: string, id: string): Skeleton;
  76221. /**
  76222. * Enable animation blending for this skeleton
  76223. * @param blendingSpeed defines the blending speed to apply
  76224. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76225. */
  76226. enableBlending(blendingSpeed?: number): void;
  76227. /**
  76228. * Releases all resources associated with the current skeleton
  76229. */
  76230. dispose(): void;
  76231. /**
  76232. * Serialize the skeleton in a JSON object
  76233. * @returns a JSON object
  76234. */
  76235. serialize(): any;
  76236. /**
  76237. * Creates a new skeleton from serialized data
  76238. * @param parsedSkeleton defines the serialized data
  76239. * @param scene defines the hosting scene
  76240. * @returns a new skeleton
  76241. */
  76242. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76243. /**
  76244. * Compute all node absolute transforms
  76245. * @param forceUpdate defines if computation must be done even if cache is up to date
  76246. */
  76247. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76248. /**
  76249. * Gets the root pose matrix
  76250. * @returns a matrix
  76251. */
  76252. getPoseMatrix(): Nullable<Matrix>;
  76253. /**
  76254. * Sorts bones per internal index
  76255. */
  76256. sortBones(): void;
  76257. private _sortBones;
  76258. }
  76259. }
  76260. declare module BABYLON {
  76261. /**
  76262. * Defines a target to use with MorphTargetManager
  76263. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76264. */
  76265. export class MorphTarget implements IAnimatable {
  76266. /** defines the name of the target */
  76267. name: string;
  76268. /**
  76269. * Gets or sets the list of animations
  76270. */
  76271. animations: Animation[];
  76272. private _scene;
  76273. private _positions;
  76274. private _normals;
  76275. private _tangents;
  76276. private _influence;
  76277. /**
  76278. * Observable raised when the influence changes
  76279. */
  76280. onInfluenceChanged: Observable<boolean>;
  76281. /** @hidden */
  76282. _onDataLayoutChanged: Observable<void>;
  76283. /**
  76284. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  76285. */
  76286. influence: number;
  76287. /**
  76288. * Gets or sets the id of the morph Target
  76289. */
  76290. id: string;
  76291. private _animationPropertiesOverride;
  76292. /**
  76293. * Gets or sets the animation properties override
  76294. */
  76295. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76296. /**
  76297. * Creates a new MorphTarget
  76298. * @param name defines the name of the target
  76299. * @param influence defines the influence to use
  76300. * @param scene defines the scene the morphtarget belongs to
  76301. */
  76302. constructor(
  76303. /** defines the name of the target */
  76304. name: string, influence?: number, scene?: Nullable<Scene>);
  76305. /**
  76306. * Gets a boolean defining if the target contains position data
  76307. */
  76308. readonly hasPositions: boolean;
  76309. /**
  76310. * Gets a boolean defining if the target contains normal data
  76311. */
  76312. readonly hasNormals: boolean;
  76313. /**
  76314. * Gets a boolean defining if the target contains tangent data
  76315. */
  76316. readonly hasTangents: boolean;
  76317. /**
  76318. * Affects position data to this target
  76319. * @param data defines the position data to use
  76320. */
  76321. setPositions(data: Nullable<FloatArray>): void;
  76322. /**
  76323. * Gets the position data stored in this target
  76324. * @returns a FloatArray containing the position data (or null if not present)
  76325. */
  76326. getPositions(): Nullable<FloatArray>;
  76327. /**
  76328. * Affects normal data to this target
  76329. * @param data defines the normal data to use
  76330. */
  76331. setNormals(data: Nullable<FloatArray>): void;
  76332. /**
  76333. * Gets the normal data stored in this target
  76334. * @returns a FloatArray containing the normal data (or null if not present)
  76335. */
  76336. getNormals(): Nullable<FloatArray>;
  76337. /**
  76338. * Affects tangent data to this target
  76339. * @param data defines the tangent data to use
  76340. */
  76341. setTangents(data: Nullable<FloatArray>): void;
  76342. /**
  76343. * Gets the tangent data stored in this target
  76344. * @returns a FloatArray containing the tangent data (or null if not present)
  76345. */
  76346. getTangents(): Nullable<FloatArray>;
  76347. /**
  76348. * Serializes the current target into a Serialization object
  76349. * @returns the serialized object
  76350. */
  76351. serialize(): any;
  76352. /**
  76353. * Returns the string "MorphTarget"
  76354. * @returns "MorphTarget"
  76355. */
  76356. getClassName(): string;
  76357. /**
  76358. * Creates a new target from serialized data
  76359. * @param serializationObject defines the serialized data to use
  76360. * @returns a new MorphTarget
  76361. */
  76362. static Parse(serializationObject: any): MorphTarget;
  76363. /**
  76364. * Creates a MorphTarget from mesh data
  76365. * @param mesh defines the source mesh
  76366. * @param name defines the name to use for the new target
  76367. * @param influence defines the influence to attach to the target
  76368. * @returns a new MorphTarget
  76369. */
  76370. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  76371. }
  76372. }
  76373. declare module BABYLON {
  76374. /**
  76375. * This class is used to deform meshes using morphing between different targets
  76376. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76377. */
  76378. export class MorphTargetManager {
  76379. private _targets;
  76380. private _targetInfluenceChangedObservers;
  76381. private _targetDataLayoutChangedObservers;
  76382. private _activeTargets;
  76383. private _scene;
  76384. private _influences;
  76385. private _supportsNormals;
  76386. private _supportsTangents;
  76387. private _vertexCount;
  76388. private _uniqueId;
  76389. private _tempInfluences;
  76390. /**
  76391. * Creates a new MorphTargetManager
  76392. * @param scene defines the current scene
  76393. */
  76394. constructor(scene?: Nullable<Scene>);
  76395. /**
  76396. * Gets the unique ID of this manager
  76397. */
  76398. readonly uniqueId: number;
  76399. /**
  76400. * Gets the number of vertices handled by this manager
  76401. */
  76402. readonly vertexCount: number;
  76403. /**
  76404. * Gets a boolean indicating if this manager supports morphing of normals
  76405. */
  76406. readonly supportsNormals: boolean;
  76407. /**
  76408. * Gets a boolean indicating if this manager supports morphing of tangents
  76409. */
  76410. readonly supportsTangents: boolean;
  76411. /**
  76412. * Gets the number of targets stored in this manager
  76413. */
  76414. readonly numTargets: number;
  76415. /**
  76416. * Gets the number of influencers (ie. the number of targets with influences > 0)
  76417. */
  76418. readonly numInfluencers: number;
  76419. /**
  76420. * Gets the list of influences (one per target)
  76421. */
  76422. readonly influences: Float32Array;
  76423. /**
  76424. * Gets the active target at specified index. An active target is a target with an influence > 0
  76425. * @param index defines the index to check
  76426. * @returns the requested target
  76427. */
  76428. getActiveTarget(index: number): MorphTarget;
  76429. /**
  76430. * Gets the target at specified index
  76431. * @param index defines the index to check
  76432. * @returns the requested target
  76433. */
  76434. getTarget(index: number): MorphTarget;
  76435. /**
  76436. * Add a new target to this manager
  76437. * @param target defines the target to add
  76438. */
  76439. addTarget(target: MorphTarget): void;
  76440. /**
  76441. * Removes a target from the manager
  76442. * @param target defines the target to remove
  76443. */
  76444. removeTarget(target: MorphTarget): void;
  76445. /**
  76446. * Serializes the current manager into a Serialization object
  76447. * @returns the serialized object
  76448. */
  76449. serialize(): any;
  76450. private _syncActiveTargets;
  76451. /**
  76452. * Syncrhonize the targets with all the meshes using this morph target manager
  76453. */
  76454. synchronize(): void;
  76455. /**
  76456. * Creates a new MorphTargetManager from serialized data
  76457. * @param serializationObject defines the serialized data
  76458. * @param scene defines the hosting scene
  76459. * @returns the new MorphTargetManager
  76460. */
  76461. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  76462. }
  76463. }
  76464. declare module BABYLON {
  76465. /**
  76466. * Mesh representing the gorund
  76467. */
  76468. export class GroundMesh extends Mesh {
  76469. /** If octree should be generated */
  76470. generateOctree: boolean;
  76471. private _heightQuads;
  76472. /** @hidden */
  76473. _subdivisionsX: number;
  76474. /** @hidden */
  76475. _subdivisionsY: number;
  76476. /** @hidden */
  76477. _width: number;
  76478. /** @hidden */
  76479. _height: number;
  76480. /** @hidden */
  76481. _minX: number;
  76482. /** @hidden */
  76483. _maxX: number;
  76484. /** @hidden */
  76485. _minZ: number;
  76486. /** @hidden */
  76487. _maxZ: number;
  76488. constructor(name: string, scene: Scene);
  76489. /**
  76490. * "GroundMesh"
  76491. * @returns "GroundMesh"
  76492. */
  76493. getClassName(): string;
  76494. /**
  76495. * The minimum of x and y subdivisions
  76496. */
  76497. readonly subdivisions: number;
  76498. /**
  76499. * X subdivisions
  76500. */
  76501. readonly subdivisionsX: number;
  76502. /**
  76503. * Y subdivisions
  76504. */
  76505. readonly subdivisionsY: number;
  76506. /**
  76507. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  76508. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  76509. * @param chunksCount the number of subdivisions for x and y
  76510. * @param octreeBlocksSize (Default: 32)
  76511. */
  76512. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  76513. /**
  76514. * Returns a height (y) value in the Worl system :
  76515. * the ground altitude at the coordinates (x, z) expressed in the World system.
  76516. * @param x x coordinate
  76517. * @param z z coordinate
  76518. * @returns the ground y position if (x, z) are outside the ground surface.
  76519. */
  76520. getHeightAtCoordinates(x: number, z: number): number;
  76521. /**
  76522. * Returns a normalized vector (Vector3) orthogonal to the ground
  76523. * at the ground coordinates (x, z) expressed in the World system.
  76524. * @param x x coordinate
  76525. * @param z z coordinate
  76526. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  76527. */
  76528. getNormalAtCoordinates(x: number, z: number): Vector3;
  76529. /**
  76530. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  76531. * at the ground coordinates (x, z) expressed in the World system.
  76532. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  76533. * @param x x coordinate
  76534. * @param z z coordinate
  76535. * @param ref vector to store the result
  76536. * @returns the GroundMesh.
  76537. */
  76538. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  76539. /**
  76540. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  76541. * if the ground has been updated.
  76542. * This can be used in the render loop.
  76543. * @returns the GroundMesh.
  76544. */
  76545. updateCoordinateHeights(): GroundMesh;
  76546. private _getFacetAt;
  76547. private _initHeightQuads;
  76548. private _computeHeightQuads;
  76549. /**
  76550. * Serializes this ground mesh
  76551. * @param serializationObject object to write serialization to
  76552. */
  76553. serialize(serializationObject: any): void;
  76554. /**
  76555. * Parses a serialized ground mesh
  76556. * @param parsedMesh the serialized mesh
  76557. * @param scene the scene to create the ground mesh in
  76558. * @returns the created ground mesh
  76559. */
  76560. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  76561. }
  76562. }
  76563. declare module BABYLON {
  76564. /**
  76565. * Interface for Physics-Joint data
  76566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76567. */
  76568. export interface PhysicsJointData {
  76569. /**
  76570. * The main pivot of the joint
  76571. */
  76572. mainPivot?: Vector3;
  76573. /**
  76574. * The connected pivot of the joint
  76575. */
  76576. connectedPivot?: Vector3;
  76577. /**
  76578. * The main axis of the joint
  76579. */
  76580. mainAxis?: Vector3;
  76581. /**
  76582. * The connected axis of the joint
  76583. */
  76584. connectedAxis?: Vector3;
  76585. /**
  76586. * The collision of the joint
  76587. */
  76588. collision?: boolean;
  76589. /**
  76590. * Native Oimo/Cannon/Energy data
  76591. */
  76592. nativeParams?: any;
  76593. }
  76594. /**
  76595. * This is a holder class for the physics joint created by the physics plugin
  76596. * It holds a set of functions to control the underlying joint
  76597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76598. */
  76599. export class PhysicsJoint {
  76600. /**
  76601. * The type of the physics joint
  76602. */
  76603. type: number;
  76604. /**
  76605. * The data for the physics joint
  76606. */
  76607. jointData: PhysicsJointData;
  76608. private _physicsJoint;
  76609. protected _physicsPlugin: IPhysicsEnginePlugin;
  76610. /**
  76611. * Initializes the physics joint
  76612. * @param type The type of the physics joint
  76613. * @param jointData The data for the physics joint
  76614. */
  76615. constructor(
  76616. /**
  76617. * The type of the physics joint
  76618. */
  76619. type: number,
  76620. /**
  76621. * The data for the physics joint
  76622. */
  76623. jointData: PhysicsJointData);
  76624. /**
  76625. * Gets the physics joint
  76626. */
  76627. /**
  76628. * Sets the physics joint
  76629. */
  76630. physicsJoint: any;
  76631. /**
  76632. * Sets the physics plugin
  76633. */
  76634. physicsPlugin: IPhysicsEnginePlugin;
  76635. /**
  76636. * Execute a function that is physics-plugin specific.
  76637. * @param {Function} func the function that will be executed.
  76638. * It accepts two parameters: the physics world and the physics joint
  76639. */
  76640. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  76641. /**
  76642. * Distance-Joint type
  76643. */
  76644. static DistanceJoint: number;
  76645. /**
  76646. * Hinge-Joint type
  76647. */
  76648. static HingeJoint: number;
  76649. /**
  76650. * Ball-and-Socket joint type
  76651. */
  76652. static BallAndSocketJoint: number;
  76653. /**
  76654. * Wheel-Joint type
  76655. */
  76656. static WheelJoint: number;
  76657. /**
  76658. * Slider-Joint type
  76659. */
  76660. static SliderJoint: number;
  76661. /**
  76662. * Prismatic-Joint type
  76663. */
  76664. static PrismaticJoint: number;
  76665. /**
  76666. * Universal-Joint type
  76667. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  76668. */
  76669. static UniversalJoint: number;
  76670. /**
  76671. * Hinge-Joint 2 type
  76672. */
  76673. static Hinge2Joint: number;
  76674. /**
  76675. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  76676. */
  76677. static PointToPointJoint: number;
  76678. /**
  76679. * Spring-Joint type
  76680. */
  76681. static SpringJoint: number;
  76682. /**
  76683. * Lock-Joint type
  76684. */
  76685. static LockJoint: number;
  76686. }
  76687. /**
  76688. * A class representing a physics distance joint
  76689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76690. */
  76691. export class DistanceJoint extends PhysicsJoint {
  76692. /**
  76693. *
  76694. * @param jointData The data for the Distance-Joint
  76695. */
  76696. constructor(jointData: DistanceJointData);
  76697. /**
  76698. * Update the predefined distance.
  76699. * @param maxDistance The maximum preferred distance
  76700. * @param minDistance The minimum preferred distance
  76701. */
  76702. updateDistance(maxDistance: number, minDistance?: number): void;
  76703. }
  76704. /**
  76705. * Represents a Motor-Enabled Joint
  76706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76707. */
  76708. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  76709. /**
  76710. * Initializes the Motor-Enabled Joint
  76711. * @param type The type of the joint
  76712. * @param jointData The physica joint data for the joint
  76713. */
  76714. constructor(type: number, jointData: PhysicsJointData);
  76715. /**
  76716. * Set the motor values.
  76717. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76718. * @param force the force to apply
  76719. * @param maxForce max force for this motor.
  76720. */
  76721. setMotor(force?: number, maxForce?: number): void;
  76722. /**
  76723. * Set the motor's limits.
  76724. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76725. * @param upperLimit The upper limit of the motor
  76726. * @param lowerLimit The lower limit of the motor
  76727. */
  76728. setLimit(upperLimit: number, lowerLimit?: number): void;
  76729. }
  76730. /**
  76731. * This class represents a single physics Hinge-Joint
  76732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76733. */
  76734. export class HingeJoint extends MotorEnabledJoint {
  76735. /**
  76736. * Initializes the Hinge-Joint
  76737. * @param jointData The joint data for the Hinge-Joint
  76738. */
  76739. constructor(jointData: PhysicsJointData);
  76740. /**
  76741. * Set the motor values.
  76742. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76743. * @param {number} force the force to apply
  76744. * @param {number} maxForce max force for this motor.
  76745. */
  76746. setMotor(force?: number, maxForce?: number): void;
  76747. /**
  76748. * Set the motor's limits.
  76749. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76750. * @param upperLimit The upper limit of the motor
  76751. * @param lowerLimit The lower limit of the motor
  76752. */
  76753. setLimit(upperLimit: number, lowerLimit?: number): void;
  76754. }
  76755. /**
  76756. * This class represents a dual hinge physics joint (same as wheel joint)
  76757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76758. */
  76759. export class Hinge2Joint extends MotorEnabledJoint {
  76760. /**
  76761. * Initializes the Hinge2-Joint
  76762. * @param jointData The joint data for the Hinge2-Joint
  76763. */
  76764. constructor(jointData: PhysicsJointData);
  76765. /**
  76766. * Set the motor values.
  76767. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76768. * @param {number} targetSpeed the speed the motor is to reach
  76769. * @param {number} maxForce max force for this motor.
  76770. * @param {motorIndex} the motor's index, 0 or 1.
  76771. */
  76772. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  76773. /**
  76774. * Set the motor limits.
  76775. * Attention, this function is plugin specific. Engines won't react 100% the same.
  76776. * @param {number} upperLimit the upper limit
  76777. * @param {number} lowerLimit lower limit
  76778. * @param {motorIndex} the motor's index, 0 or 1.
  76779. */
  76780. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76781. }
  76782. /**
  76783. * Interface for a motor enabled joint
  76784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76785. */
  76786. export interface IMotorEnabledJoint {
  76787. /**
  76788. * Physics joint
  76789. */
  76790. physicsJoint: any;
  76791. /**
  76792. * Sets the motor of the motor-enabled joint
  76793. * @param force The force of the motor
  76794. * @param maxForce The maximum force of the motor
  76795. * @param motorIndex The index of the motor
  76796. */
  76797. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  76798. /**
  76799. * Sets the limit of the motor
  76800. * @param upperLimit The upper limit of the motor
  76801. * @param lowerLimit The lower limit of the motor
  76802. * @param motorIndex The index of the motor
  76803. */
  76804. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76805. }
  76806. /**
  76807. * Joint data for a Distance-Joint
  76808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76809. */
  76810. export interface DistanceJointData extends PhysicsJointData {
  76811. /**
  76812. * Max distance the 2 joint objects can be apart
  76813. */
  76814. maxDistance: number;
  76815. }
  76816. /**
  76817. * Joint data from a spring joint
  76818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76819. */
  76820. export interface SpringJointData extends PhysicsJointData {
  76821. /**
  76822. * Length of the spring
  76823. */
  76824. length: number;
  76825. /**
  76826. * Stiffness of the spring
  76827. */
  76828. stiffness: number;
  76829. /**
  76830. * Damping of the spring
  76831. */
  76832. damping: number;
  76833. /** this callback will be called when applying the force to the impostors. */
  76834. forceApplicationCallback: () => void;
  76835. }
  76836. }
  76837. declare module BABYLON {
  76838. /**
  76839. * Interface used to describe a physics joint
  76840. */
  76841. export interface PhysicsImpostorJoint {
  76842. /** Defines the main impostor to which the joint is linked */
  76843. mainImpostor: PhysicsImpostor;
  76844. /** Defines the impostor that is connected to the main impostor using this joint */
  76845. connectedImpostor: PhysicsImpostor;
  76846. /** Defines the joint itself */
  76847. joint: PhysicsJoint;
  76848. }
  76849. /** @hidden */
  76850. export interface IPhysicsEnginePlugin {
  76851. world: any;
  76852. name: string;
  76853. setGravity(gravity: Vector3): void;
  76854. setTimeStep(timeStep: number): void;
  76855. getTimeStep(): number;
  76856. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  76857. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76858. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  76859. generatePhysicsBody(impostor: PhysicsImpostor): void;
  76860. removePhysicsBody(impostor: PhysicsImpostor): void;
  76861. generateJoint(joint: PhysicsImpostorJoint): void;
  76862. removeJoint(joint: PhysicsImpostorJoint): void;
  76863. isSupported(): boolean;
  76864. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  76865. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  76866. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76867. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  76868. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76869. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  76870. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  76871. getBodyMass(impostor: PhysicsImpostor): number;
  76872. getBodyFriction(impostor: PhysicsImpostor): number;
  76873. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  76874. getBodyRestitution(impostor: PhysicsImpostor): number;
  76875. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  76876. sleepBody(impostor: PhysicsImpostor): void;
  76877. wakeUpBody(impostor: PhysicsImpostor): void;
  76878. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  76879. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  76880. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  76881. getRadius(impostor: PhysicsImpostor): number;
  76882. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  76883. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  76884. dispose(): void;
  76885. }
  76886. /**
  76887. * Interface used to define a physics engine
  76888. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  76889. */
  76890. export interface IPhysicsEngine {
  76891. /**
  76892. * Gets the gravity vector used by the simulation
  76893. */
  76894. gravity: Vector3;
  76895. /**
  76896. * Sets the gravity vector used by the simulation
  76897. * @param gravity defines the gravity vector to use
  76898. */
  76899. setGravity(gravity: Vector3): void;
  76900. /**
  76901. * Set the time step of the physics engine.
  76902. * Default is 1/60.
  76903. * To slow it down, enter 1/600 for example.
  76904. * To speed it up, 1/30
  76905. * @param newTimeStep the new timestep to apply to this world.
  76906. */
  76907. setTimeStep(newTimeStep: number): void;
  76908. /**
  76909. * Get the time step of the physics engine.
  76910. * @returns the current time step
  76911. */
  76912. getTimeStep(): number;
  76913. /**
  76914. * Release all resources
  76915. */
  76916. dispose(): void;
  76917. /**
  76918. * Gets the name of the current physics plugin
  76919. * @returns the name of the plugin
  76920. */
  76921. getPhysicsPluginName(): string;
  76922. /**
  76923. * Adding a new impostor for the impostor tracking.
  76924. * This will be done by the impostor itself.
  76925. * @param impostor the impostor to add
  76926. */
  76927. addImpostor(impostor: PhysicsImpostor): void;
  76928. /**
  76929. * Remove an impostor from the engine.
  76930. * This impostor and its mesh will not longer be updated by the physics engine.
  76931. * @param impostor the impostor to remove
  76932. */
  76933. removeImpostor(impostor: PhysicsImpostor): void;
  76934. /**
  76935. * Add a joint to the physics engine
  76936. * @param mainImpostor defines the main impostor to which the joint is added.
  76937. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  76938. * @param joint defines the joint that will connect both impostors.
  76939. */
  76940. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76941. /**
  76942. * Removes a joint from the simulation
  76943. * @param mainImpostor defines the impostor used with the joint
  76944. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  76945. * @param joint defines the joint to remove
  76946. */
  76947. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  76948. /**
  76949. * Gets the current plugin used to run the simulation
  76950. * @returns current plugin
  76951. */
  76952. getPhysicsPlugin(): IPhysicsEnginePlugin;
  76953. /**
  76954. * Gets the list of physic impostors
  76955. * @returns an array of PhysicsImpostor
  76956. */
  76957. getImpostors(): Array<PhysicsImpostor>;
  76958. /**
  76959. * Gets the impostor for a physics enabled object
  76960. * @param object defines the object impersonated by the impostor
  76961. * @returns the PhysicsImpostor or null if not found
  76962. */
  76963. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76964. /**
  76965. * Gets the impostor for a physics body object
  76966. * @param body defines physics body used by the impostor
  76967. * @returns the PhysicsImpostor or null if not found
  76968. */
  76969. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  76970. /**
  76971. * Called by the scene. No need to call it.
  76972. * @param delta defines the timespam between frames
  76973. */
  76974. _step(delta: number): void;
  76975. }
  76976. }
  76977. declare module BABYLON {
  76978. /**
  76979. * The interface for the physics imposter parameters
  76980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76981. */
  76982. export interface PhysicsImpostorParameters {
  76983. /**
  76984. * The mass of the physics imposter
  76985. */
  76986. mass: number;
  76987. /**
  76988. * The friction of the physics imposter
  76989. */
  76990. friction?: number;
  76991. /**
  76992. * The coefficient of restitution of the physics imposter
  76993. */
  76994. restitution?: number;
  76995. /**
  76996. * The native options of the physics imposter
  76997. */
  76998. nativeOptions?: any;
  76999. /**
  77000. * Specifies if the parent should be ignored
  77001. */
  77002. ignoreParent?: boolean;
  77003. /**
  77004. * Specifies if bi-directional transformations should be disabled
  77005. */
  77006. disableBidirectionalTransformation?: boolean;
  77007. }
  77008. /**
  77009. * Interface for a physics-enabled object
  77010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77011. */
  77012. export interface IPhysicsEnabledObject {
  77013. /**
  77014. * The position of the physics-enabled object
  77015. */
  77016. position: Vector3;
  77017. /**
  77018. * The rotation of the physics-enabled object
  77019. */
  77020. rotationQuaternion: Nullable<Quaternion>;
  77021. /**
  77022. * The scale of the physics-enabled object
  77023. */
  77024. scaling: Vector3;
  77025. /**
  77026. * The rotation of the physics-enabled object
  77027. */
  77028. rotation?: Vector3;
  77029. /**
  77030. * The parent of the physics-enabled object
  77031. */
  77032. parent?: any;
  77033. /**
  77034. * The bounding info of the physics-enabled object
  77035. * @returns The bounding info of the physics-enabled object
  77036. */
  77037. getBoundingInfo(): BoundingInfo;
  77038. /**
  77039. * Computes the world matrix
  77040. * @param force Specifies if the world matrix should be computed by force
  77041. * @returns A world matrix
  77042. */
  77043. computeWorldMatrix(force: boolean): Matrix;
  77044. /**
  77045. * Gets the world matrix
  77046. * @returns A world matrix
  77047. */
  77048. getWorldMatrix?(): Matrix;
  77049. /**
  77050. * Gets the child meshes
  77051. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  77052. * @returns An array of abstract meshes
  77053. */
  77054. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  77055. /**
  77056. * Gets the vertex data
  77057. * @param kind The type of vertex data
  77058. * @returns A nullable array of numbers, or a float32 array
  77059. */
  77060. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  77061. /**
  77062. * Gets the indices from the mesh
  77063. * @returns A nullable array of index arrays
  77064. */
  77065. getIndices?(): Nullable<IndicesArray>;
  77066. /**
  77067. * Gets the scene from the mesh
  77068. * @returns the indices array or null
  77069. */
  77070. getScene?(): Scene;
  77071. /**
  77072. * Gets the absolute position from the mesh
  77073. * @returns the absolute position
  77074. */
  77075. getAbsolutePosition(): Vector3;
  77076. /**
  77077. * Gets the absolute pivot point from the mesh
  77078. * @returns the absolute pivot point
  77079. */
  77080. getAbsolutePivotPoint(): Vector3;
  77081. /**
  77082. * Rotates the mesh
  77083. * @param axis The axis of rotation
  77084. * @param amount The amount of rotation
  77085. * @param space The space of the rotation
  77086. * @returns The rotation transform node
  77087. */
  77088. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77089. /**
  77090. * Translates the mesh
  77091. * @param axis The axis of translation
  77092. * @param distance The distance of translation
  77093. * @param space The space of the translation
  77094. * @returns The transform node
  77095. */
  77096. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77097. /**
  77098. * Sets the absolute position of the mesh
  77099. * @param absolutePosition The absolute position of the mesh
  77100. * @returns The transform node
  77101. */
  77102. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77103. /**
  77104. * Gets the class name of the mesh
  77105. * @returns The class name
  77106. */
  77107. getClassName(): string;
  77108. }
  77109. /**
  77110. * Represents a physics imposter
  77111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77112. */
  77113. export class PhysicsImpostor {
  77114. /**
  77115. * The physics-enabled object used as the physics imposter
  77116. */
  77117. object: IPhysicsEnabledObject;
  77118. /**
  77119. * The type of the physics imposter
  77120. */
  77121. type: number;
  77122. private _options;
  77123. private _scene?;
  77124. /**
  77125. * The default object size of the imposter
  77126. */
  77127. static DEFAULT_OBJECT_SIZE: Vector3;
  77128. /**
  77129. * The identity quaternion of the imposter
  77130. */
  77131. static IDENTITY_QUATERNION: Quaternion;
  77132. /** @hidden */
  77133. _pluginData: any;
  77134. private _physicsEngine;
  77135. private _physicsBody;
  77136. private _bodyUpdateRequired;
  77137. private _onBeforePhysicsStepCallbacks;
  77138. private _onAfterPhysicsStepCallbacks;
  77139. /** @hidden */
  77140. _onPhysicsCollideCallbacks: Array<{
  77141. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  77142. otherImpostors: Array<PhysicsImpostor>;
  77143. }>;
  77144. private _deltaPosition;
  77145. private _deltaRotation;
  77146. private _deltaRotationConjugated;
  77147. private _parent;
  77148. private _isDisposed;
  77149. private static _tmpVecs;
  77150. private static _tmpQuat;
  77151. /**
  77152. * Specifies if the physics imposter is disposed
  77153. */
  77154. readonly isDisposed: boolean;
  77155. /**
  77156. * Gets the mass of the physics imposter
  77157. */
  77158. mass: number;
  77159. /**
  77160. * Gets the coefficient of friction
  77161. */
  77162. /**
  77163. * Sets the coefficient of friction
  77164. */
  77165. friction: number;
  77166. /**
  77167. * Gets the coefficient of restitution
  77168. */
  77169. /**
  77170. * Sets the coefficient of restitution
  77171. */
  77172. restitution: number;
  77173. /**
  77174. * The unique id of the physics imposter
  77175. * set by the physics engine when adding this impostor to the array
  77176. */
  77177. uniqueId: number;
  77178. private _joints;
  77179. /**
  77180. * Initializes the physics imposter
  77181. * @param object The physics-enabled object used as the physics imposter
  77182. * @param type The type of the physics imposter
  77183. * @param _options The options for the physics imposter
  77184. * @param _scene The Babylon scene
  77185. */
  77186. constructor(
  77187. /**
  77188. * The physics-enabled object used as the physics imposter
  77189. */
  77190. object: IPhysicsEnabledObject,
  77191. /**
  77192. * The type of the physics imposter
  77193. */
  77194. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  77195. /**
  77196. * This function will completly initialize this impostor.
  77197. * It will create a new body - but only if this mesh has no parent.
  77198. * If it has, this impostor will not be used other than to define the impostor
  77199. * of the child mesh.
  77200. * @hidden
  77201. */
  77202. _init(): void;
  77203. private _getPhysicsParent;
  77204. /**
  77205. * Should a new body be generated.
  77206. * @returns boolean specifying if body initialization is required
  77207. */
  77208. isBodyInitRequired(): boolean;
  77209. /**
  77210. * Sets the updated scaling
  77211. * @param updated Specifies if the scaling is updated
  77212. */
  77213. setScalingUpdated(): void;
  77214. /**
  77215. * Force a regeneration of this or the parent's impostor's body.
  77216. * Use under cautious - This will remove all joints already implemented.
  77217. */
  77218. forceUpdate(): void;
  77219. /**
  77220. * Gets the body that holds this impostor. Either its own, or its parent.
  77221. */
  77222. /**
  77223. * Set the physics body. Used mainly by the physics engine/plugin
  77224. */
  77225. physicsBody: any;
  77226. /**
  77227. * Get the parent of the physics imposter
  77228. * @returns Physics imposter or null
  77229. */
  77230. /**
  77231. * Sets the parent of the physics imposter
  77232. */
  77233. parent: Nullable<PhysicsImpostor>;
  77234. /**
  77235. * Resets the update flags
  77236. */
  77237. resetUpdateFlags(): void;
  77238. /**
  77239. * Gets the object extend size
  77240. * @returns the object extend size
  77241. */
  77242. getObjectExtendSize(): Vector3;
  77243. /**
  77244. * Gets the object center
  77245. * @returns The object center
  77246. */
  77247. getObjectCenter(): Vector3;
  77248. /**
  77249. * Get a specific parametes from the options parameter
  77250. * @param paramName The object parameter name
  77251. * @returns The object parameter
  77252. */
  77253. getParam(paramName: string): any;
  77254. /**
  77255. * Sets a specific parameter in the options given to the physics plugin
  77256. * @param paramName The parameter name
  77257. * @param value The value of the parameter
  77258. */
  77259. setParam(paramName: string, value: number): void;
  77260. /**
  77261. * Specifically change the body's mass option. Won't recreate the physics body object
  77262. * @param mass The mass of the physics imposter
  77263. */
  77264. setMass(mass: number): void;
  77265. /**
  77266. * Gets the linear velocity
  77267. * @returns linear velocity or null
  77268. */
  77269. getLinearVelocity(): Nullable<Vector3>;
  77270. /**
  77271. * Sets the linear velocity
  77272. * @param velocity linear velocity or null
  77273. */
  77274. setLinearVelocity(velocity: Nullable<Vector3>): void;
  77275. /**
  77276. * Gets the angular velocity
  77277. * @returns angular velocity or null
  77278. */
  77279. getAngularVelocity(): Nullable<Vector3>;
  77280. /**
  77281. * Sets the angular velocity
  77282. * @param velocity The velocity or null
  77283. */
  77284. setAngularVelocity(velocity: Nullable<Vector3>): void;
  77285. /**
  77286. * Execute a function with the physics plugin native code
  77287. * Provide a function the will have two variables - the world object and the physics body object
  77288. * @param func The function to execute with the physics plugin native code
  77289. */
  77290. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  77291. /**
  77292. * Register a function that will be executed before the physics world is stepping forward
  77293. * @param func The function to execute before the physics world is stepped forward
  77294. */
  77295. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77296. /**
  77297. * Unregister a function that will be executed before the physics world is stepping forward
  77298. * @param func The function to execute before the physics world is stepped forward
  77299. */
  77300. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77301. /**
  77302. * Register a function that will be executed after the physics step
  77303. * @param func The function to execute after physics step
  77304. */
  77305. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77306. /**
  77307. * Unregisters a function that will be executed after the physics step
  77308. * @param func The function to execute after physics step
  77309. */
  77310. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  77311. /**
  77312. * register a function that will be executed when this impostor collides against a different body
  77313. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  77314. * @param func Callback that is executed on collision
  77315. */
  77316. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  77317. /**
  77318. * Unregisters the physics imposter on contact
  77319. * @param collideAgainst The physics object to collide against
  77320. * @param func Callback to execute on collision
  77321. */
  77322. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  77323. private _tmpQuat;
  77324. private _tmpQuat2;
  77325. /**
  77326. * Get the parent rotation
  77327. * @returns The parent rotation
  77328. */
  77329. getParentsRotation(): Quaternion;
  77330. /**
  77331. * this function is executed by the physics engine.
  77332. */
  77333. beforeStep: () => void;
  77334. /**
  77335. * this function is executed by the physics engine
  77336. */
  77337. afterStep: () => void;
  77338. /**
  77339. * Legacy collision detection event support
  77340. */
  77341. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  77342. /**
  77343. * event and body object due to cannon's event-based architecture.
  77344. */
  77345. onCollide: (e: {
  77346. body: any;
  77347. }) => void;
  77348. /**
  77349. * Apply a force
  77350. * @param force The force to apply
  77351. * @param contactPoint The contact point for the force
  77352. * @returns The physics imposter
  77353. */
  77354. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77355. /**
  77356. * Apply an impulse
  77357. * @param force The impulse force
  77358. * @param contactPoint The contact point for the impulse force
  77359. * @returns The physics imposter
  77360. */
  77361. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  77362. /**
  77363. * A help function to create a joint
  77364. * @param otherImpostor A physics imposter used to create a joint
  77365. * @param jointType The type of joint
  77366. * @param jointData The data for the joint
  77367. * @returns The physics imposter
  77368. */
  77369. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  77370. /**
  77371. * Add a joint to this impostor with a different impostor
  77372. * @param otherImpostor A physics imposter used to add a joint
  77373. * @param joint The joint to add
  77374. * @returns The physics imposter
  77375. */
  77376. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  77377. /**
  77378. * Will keep this body still, in a sleep mode.
  77379. * @returns the physics imposter
  77380. */
  77381. sleep(): PhysicsImpostor;
  77382. /**
  77383. * Wake the body up.
  77384. * @returns The physics imposter
  77385. */
  77386. wakeUp(): PhysicsImpostor;
  77387. /**
  77388. * Clones the physics imposter
  77389. * @param newObject The physics imposter clones to this physics-enabled object
  77390. * @returns A nullable physics imposter
  77391. */
  77392. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77393. /**
  77394. * Disposes the physics imposter
  77395. */
  77396. dispose(): void;
  77397. /**
  77398. * Sets the delta position
  77399. * @param position The delta position amount
  77400. */
  77401. setDeltaPosition(position: Vector3): void;
  77402. /**
  77403. * Sets the delta rotation
  77404. * @param rotation The delta rotation amount
  77405. */
  77406. setDeltaRotation(rotation: Quaternion): void;
  77407. /**
  77408. * Gets the box size of the physics imposter and stores the result in the input parameter
  77409. * @param result Stores the box size
  77410. * @returns The physics imposter
  77411. */
  77412. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  77413. /**
  77414. * Gets the radius of the physics imposter
  77415. * @returns Radius of the physics imposter
  77416. */
  77417. getRadius(): number;
  77418. /**
  77419. * Sync a bone with this impostor
  77420. * @param bone The bone to sync to the impostor.
  77421. * @param boneMesh The mesh that the bone is influencing.
  77422. * @param jointPivot The pivot of the joint / bone in local space.
  77423. * @param distToJoint Optional distance from the impostor to the joint.
  77424. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77425. */
  77426. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  77427. /**
  77428. * Sync impostor to a bone
  77429. * @param bone The bone that the impostor will be synced to.
  77430. * @param boneMesh The mesh that the bone is influencing.
  77431. * @param jointPivot The pivot of the joint / bone in local space.
  77432. * @param distToJoint Optional distance from the impostor to the joint.
  77433. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  77434. * @param boneAxis Optional vector3 axis the bone is aligned with
  77435. */
  77436. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  77437. /**
  77438. * No-Imposter type
  77439. */
  77440. static NoImpostor: number;
  77441. /**
  77442. * Sphere-Imposter type
  77443. */
  77444. static SphereImpostor: number;
  77445. /**
  77446. * Box-Imposter type
  77447. */
  77448. static BoxImpostor: number;
  77449. /**
  77450. * Plane-Imposter type
  77451. */
  77452. static PlaneImpostor: number;
  77453. /**
  77454. * Mesh-imposter type
  77455. */
  77456. static MeshImpostor: number;
  77457. /**
  77458. * Cylinder-Imposter type
  77459. */
  77460. static CylinderImpostor: number;
  77461. /**
  77462. * Particle-Imposter type
  77463. */
  77464. static ParticleImpostor: number;
  77465. /**
  77466. * Heightmap-Imposter type
  77467. */
  77468. static HeightmapImpostor: number;
  77469. }
  77470. }
  77471. declare module BABYLON {
  77472. /**
  77473. * Class used to represent a specific level of detail of a mesh
  77474. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77475. */
  77476. export class MeshLODLevel {
  77477. /** Defines the distance where this level should star being displayed */
  77478. distance: number;
  77479. /** Defines the mesh to use to render this level */
  77480. mesh: Nullable<Mesh>;
  77481. /**
  77482. * Creates a new LOD level
  77483. * @param distance defines the distance where this level should star being displayed
  77484. * @param mesh defines the mesh to use to render this level
  77485. */
  77486. constructor(
  77487. /** Defines the distance where this level should star being displayed */
  77488. distance: number,
  77489. /** Defines the mesh to use to render this level */
  77490. mesh: Nullable<Mesh>);
  77491. }
  77492. /**
  77493. * @hidden
  77494. **/
  77495. export class _CreationDataStorage {
  77496. closePath?: boolean;
  77497. closeArray?: boolean;
  77498. idx: number[];
  77499. dashSize: number;
  77500. gapSize: number;
  77501. path3D: Path3D;
  77502. pathArray: Vector3[][];
  77503. arc: number;
  77504. radius: number;
  77505. cap: number;
  77506. tessellation: number;
  77507. }
  77508. /**
  77509. * @hidden
  77510. **/
  77511. class _InstanceDataStorage {
  77512. visibleInstances: any;
  77513. renderIdForInstances: number[];
  77514. batchCache: _InstancesBatch;
  77515. instancesBufferSize: number;
  77516. instancesBuffer: Nullable<Buffer>;
  77517. instancesData: Float32Array;
  77518. overridenInstanceCount: number;
  77519. }
  77520. /**
  77521. * @hidden
  77522. **/
  77523. export class _InstancesBatch {
  77524. mustReturn: boolean;
  77525. visibleInstances: Nullable<InstancedMesh[]>[];
  77526. renderSelf: boolean[];
  77527. }
  77528. /**
  77529. * Class used to represent renderable models
  77530. */
  77531. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  77532. /**
  77533. * Mesh side orientation : usually the external or front surface
  77534. */
  77535. static readonly FRONTSIDE: number;
  77536. /**
  77537. * Mesh side orientation : usually the internal or back surface
  77538. */
  77539. static readonly BACKSIDE: number;
  77540. /**
  77541. * Mesh side orientation : both internal and external or front and back surfaces
  77542. */
  77543. static readonly DOUBLESIDE: number;
  77544. /**
  77545. * Mesh side orientation : by default, `FRONTSIDE`
  77546. */
  77547. static readonly DEFAULTSIDE: number;
  77548. /**
  77549. * Mesh cap setting : no cap
  77550. */
  77551. static readonly NO_CAP: number;
  77552. /**
  77553. * Mesh cap setting : one cap at the beginning of the mesh
  77554. */
  77555. static readonly CAP_START: number;
  77556. /**
  77557. * Mesh cap setting : one cap at the end of the mesh
  77558. */
  77559. static readonly CAP_END: number;
  77560. /**
  77561. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  77562. */
  77563. static readonly CAP_ALL: number;
  77564. /**
  77565. * Gets the default side orientation.
  77566. * @param orientation the orientation to value to attempt to get
  77567. * @returns the default orientation
  77568. * @hidden
  77569. */
  77570. static _GetDefaultSideOrientation(orientation?: number): number;
  77571. private _onBeforeRenderObservable;
  77572. private _onBeforeBindObservable;
  77573. private _onAfterRenderObservable;
  77574. private _onBeforeDrawObservable;
  77575. /**
  77576. * An event triggered before rendering the mesh
  77577. */
  77578. readonly onBeforeRenderObservable: Observable<Mesh>;
  77579. /**
  77580. * An event triggered before binding the mesh
  77581. */
  77582. readonly onBeforeBindObservable: Observable<Mesh>;
  77583. /**
  77584. * An event triggered after rendering the mesh
  77585. */
  77586. readonly onAfterRenderObservable: Observable<Mesh>;
  77587. /**
  77588. * An event triggered before drawing the mesh
  77589. */
  77590. readonly onBeforeDrawObservable: Observable<Mesh>;
  77591. private _onBeforeDrawObserver;
  77592. /**
  77593. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  77594. */
  77595. onBeforeDraw: () => void;
  77596. /**
  77597. * Gets the delay loading state of the mesh (when delay loading is turned on)
  77598. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  77599. */
  77600. delayLoadState: number;
  77601. /**
  77602. * Gets the list of instances created from this mesh
  77603. * it is not supposed to be modified manually.
  77604. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  77605. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77606. */
  77607. instances: InstancedMesh[];
  77608. /**
  77609. * Gets the file containing delay loading data for this mesh
  77610. */
  77611. delayLoadingFile: string;
  77612. /** @hidden */
  77613. _binaryInfo: any;
  77614. private _LODLevels;
  77615. /**
  77616. * User defined function used to change how LOD level selection is done
  77617. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  77618. */
  77619. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  77620. private _morphTargetManager;
  77621. /**
  77622. * Gets or sets the morph target manager
  77623. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77624. */
  77625. morphTargetManager: Nullable<MorphTargetManager>;
  77626. /** @hidden */
  77627. _creationDataStorage: Nullable<_CreationDataStorage>;
  77628. /** @hidden */
  77629. _geometry: Nullable<Geometry>;
  77630. /** @hidden */
  77631. _delayInfo: Array<string>;
  77632. /** @hidden */
  77633. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  77634. /** @hidden */
  77635. _instanceDataStorage: _InstanceDataStorage;
  77636. private _effectiveMaterial;
  77637. /** @hidden */
  77638. _shouldGenerateFlatShading: boolean;
  77639. private _preActivateId;
  77640. /** @hidden */
  77641. _originalBuilderSideOrientation: number;
  77642. /**
  77643. * Use this property to change the original side orientation defined at construction time
  77644. */
  77645. overrideMaterialSideOrientation: Nullable<number>;
  77646. private _areNormalsFrozen;
  77647. private _sourcePositions;
  77648. private _sourceNormals;
  77649. private _source;
  77650. private meshMap;
  77651. /**
  77652. * Gets the source mesh (the one used to clone this one from)
  77653. */
  77654. readonly source: Nullable<Mesh>;
  77655. /**
  77656. * Gets or sets a boolean indicating that this mesh does not use index buffer
  77657. */
  77658. isUnIndexed: boolean;
  77659. /**
  77660. * @constructor
  77661. * @param name The value used by scene.getMeshByName() to do a lookup.
  77662. * @param scene The scene to add this mesh to.
  77663. * @param parent The parent of this mesh, if it has one
  77664. * @param source An optional Mesh from which geometry is shared, cloned.
  77665. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  77666. * When false, achieved by calling a clone(), also passing False.
  77667. * This will make creation of children, recursive.
  77668. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  77669. */
  77670. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  77671. /**
  77672. * Gets the class name
  77673. * @returns the string "Mesh".
  77674. */
  77675. getClassName(): string;
  77676. /** @hidden */
  77677. readonly _isMesh: boolean;
  77678. /**
  77679. * Returns a description of this mesh
  77680. * @param fullDetails define if full details about this mesh must be used
  77681. * @returns a descriptive string representing this mesh
  77682. */
  77683. toString(fullDetails?: boolean): string;
  77684. /** @hidden */
  77685. _unBindEffect(): void;
  77686. /**
  77687. * Gets a boolean indicating if this mesh has LOD
  77688. */
  77689. readonly hasLODLevels: boolean;
  77690. /**
  77691. * Gets the list of MeshLODLevel associated with the current mesh
  77692. * @returns an array of MeshLODLevel
  77693. */
  77694. getLODLevels(): MeshLODLevel[];
  77695. private _sortLODLevels;
  77696. /**
  77697. * Add a mesh as LOD level triggered at the given distance.
  77698. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77699. * @param distance The distance from the center of the object to show this level
  77700. * @param mesh The mesh to be added as LOD level (can be null)
  77701. * @return This mesh (for chaining)
  77702. */
  77703. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  77704. /**
  77705. * Returns the LOD level mesh at the passed distance or null if not found.
  77706. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77707. * @param distance The distance from the center of the object to show this level
  77708. * @returns a Mesh or `null`
  77709. */
  77710. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  77711. /**
  77712. * Remove a mesh from the LOD array
  77713. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77714. * @param mesh defines the mesh to be removed
  77715. * @return This mesh (for chaining)
  77716. */
  77717. removeLODLevel(mesh: Mesh): Mesh;
  77718. /**
  77719. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  77720. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  77721. * @param camera defines the camera to use to compute distance
  77722. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  77723. * @return This mesh (for chaining)
  77724. */
  77725. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  77726. /**
  77727. * Gets the mesh internal Geometry object
  77728. */
  77729. readonly geometry: Nullable<Geometry>;
  77730. /**
  77731. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  77732. * @returns the total number of vertices
  77733. */
  77734. getTotalVertices(): number;
  77735. /**
  77736. * Returns the content of an associated vertex buffer
  77737. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77738. * - VertexBuffer.PositionKind
  77739. * - VertexBuffer.UVKind
  77740. * - VertexBuffer.UV2Kind
  77741. * - VertexBuffer.UV3Kind
  77742. * - VertexBuffer.UV4Kind
  77743. * - VertexBuffer.UV5Kind
  77744. * - VertexBuffer.UV6Kind
  77745. * - VertexBuffer.ColorKind
  77746. * - VertexBuffer.MatricesIndicesKind
  77747. * - VertexBuffer.MatricesIndicesExtraKind
  77748. * - VertexBuffer.MatricesWeightsKind
  77749. * - VertexBuffer.MatricesWeightsExtraKind
  77750. * @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
  77751. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  77752. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  77753. */
  77754. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77755. /**
  77756. * Returns the mesh VertexBuffer object from the requested `kind`
  77757. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77758. * - VertexBuffer.PositionKind
  77759. * - VertexBuffer.UVKind
  77760. * - VertexBuffer.UV2Kind
  77761. * - VertexBuffer.UV3Kind
  77762. * - VertexBuffer.UV4Kind
  77763. * - VertexBuffer.UV5Kind
  77764. * - VertexBuffer.UV6Kind
  77765. * - VertexBuffer.ColorKind
  77766. * - VertexBuffer.MatricesIndicesKind
  77767. * - VertexBuffer.MatricesIndicesExtraKind
  77768. * - VertexBuffer.MatricesWeightsKind
  77769. * - VertexBuffer.MatricesWeightsExtraKind
  77770. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  77771. */
  77772. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77773. /**
  77774. * Tests if a specific vertex buffer is associated with this mesh
  77775. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77776. * - VertexBuffer.PositionKind
  77777. * - VertexBuffer.UVKind
  77778. * - VertexBuffer.UV2Kind
  77779. * - VertexBuffer.UV3Kind
  77780. * - VertexBuffer.UV4Kind
  77781. * - VertexBuffer.UV5Kind
  77782. * - VertexBuffer.UV6Kind
  77783. * - VertexBuffer.ColorKind
  77784. * - VertexBuffer.MatricesIndicesKind
  77785. * - VertexBuffer.MatricesIndicesExtraKind
  77786. * - VertexBuffer.MatricesWeightsKind
  77787. * - VertexBuffer.MatricesWeightsExtraKind
  77788. * @returns a boolean
  77789. */
  77790. isVerticesDataPresent(kind: string): boolean;
  77791. /**
  77792. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  77793. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  77794. * - VertexBuffer.PositionKind
  77795. * - VertexBuffer.UVKind
  77796. * - VertexBuffer.UV2Kind
  77797. * - VertexBuffer.UV3Kind
  77798. * - VertexBuffer.UV4Kind
  77799. * - VertexBuffer.UV5Kind
  77800. * - VertexBuffer.UV6Kind
  77801. * - VertexBuffer.ColorKind
  77802. * - VertexBuffer.MatricesIndicesKind
  77803. * - VertexBuffer.MatricesIndicesExtraKind
  77804. * - VertexBuffer.MatricesWeightsKind
  77805. * - VertexBuffer.MatricesWeightsExtraKind
  77806. * @returns a boolean
  77807. */
  77808. isVertexBufferUpdatable(kind: string): boolean;
  77809. /**
  77810. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  77811. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  77812. * - VertexBuffer.PositionKind
  77813. * - VertexBuffer.UVKind
  77814. * - VertexBuffer.UV2Kind
  77815. * - VertexBuffer.UV3Kind
  77816. * - VertexBuffer.UV4Kind
  77817. * - VertexBuffer.UV5Kind
  77818. * - VertexBuffer.UV6Kind
  77819. * - VertexBuffer.ColorKind
  77820. * - VertexBuffer.MatricesIndicesKind
  77821. * - VertexBuffer.MatricesIndicesExtraKind
  77822. * - VertexBuffer.MatricesWeightsKind
  77823. * - VertexBuffer.MatricesWeightsExtraKind
  77824. * @returns an array of strings
  77825. */
  77826. getVerticesDataKinds(): string[];
  77827. /**
  77828. * Returns a positive integer : the total number of indices in this mesh geometry.
  77829. * @returns the numner of indices or zero if the mesh has no geometry.
  77830. */
  77831. getTotalIndices(): number;
  77832. /**
  77833. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77834. * @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.
  77835. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77836. * @returns the indices array or an empty array if the mesh has no geometry
  77837. */
  77838. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77839. readonly isBlocked: boolean;
  77840. /**
  77841. * Determine if the current mesh is ready to be rendered
  77842. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  77843. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  77844. * @returns true if all associated assets are ready (material, textures, shaders)
  77845. */
  77846. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  77847. /**
  77848. * 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.
  77849. */
  77850. readonly areNormalsFrozen: boolean;
  77851. /**
  77852. * 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.
  77853. * @returns the current mesh
  77854. */
  77855. freezeNormals(): Mesh;
  77856. /**
  77857. * 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
  77858. * @returns the current mesh
  77859. */
  77860. unfreezeNormals(): Mesh;
  77861. /**
  77862. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  77863. */
  77864. overridenInstanceCount: number;
  77865. /** @hidden */
  77866. _preActivate(): Mesh;
  77867. /** @hidden */
  77868. _preActivateForIntermediateRendering(renderId: number): Mesh;
  77869. /** @hidden */
  77870. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  77871. /**
  77872. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  77873. * This means the mesh underlying bounding box and sphere are recomputed.
  77874. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  77875. * @returns the current mesh
  77876. */
  77877. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  77878. /** @hidden */
  77879. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  77880. /**
  77881. * This function will subdivide the mesh into multiple submeshes
  77882. * @param count defines the expected number of submeshes
  77883. */
  77884. subdivide(count: number): void;
  77885. /**
  77886. * Copy a FloatArray into a specific associated vertex buffer
  77887. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77888. * - VertexBuffer.PositionKind
  77889. * - VertexBuffer.UVKind
  77890. * - VertexBuffer.UV2Kind
  77891. * - VertexBuffer.UV3Kind
  77892. * - VertexBuffer.UV4Kind
  77893. * - VertexBuffer.UV5Kind
  77894. * - VertexBuffer.UV6Kind
  77895. * - VertexBuffer.ColorKind
  77896. * - VertexBuffer.MatricesIndicesKind
  77897. * - VertexBuffer.MatricesIndicesExtraKind
  77898. * - VertexBuffer.MatricesWeightsKind
  77899. * - VertexBuffer.MatricesWeightsExtraKind
  77900. * @param data defines the data source
  77901. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77902. * @param stride defines the data stride size (can be null)
  77903. * @returns the current mesh
  77904. */
  77905. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  77906. /**
  77907. * Flags an associated vertex buffer as updatable
  77908. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  77909. * - VertexBuffer.PositionKind
  77910. * - VertexBuffer.UVKind
  77911. * - VertexBuffer.UV2Kind
  77912. * - VertexBuffer.UV3Kind
  77913. * - VertexBuffer.UV4Kind
  77914. * - VertexBuffer.UV5Kind
  77915. * - VertexBuffer.UV6Kind
  77916. * - VertexBuffer.ColorKind
  77917. * - VertexBuffer.MatricesIndicesKind
  77918. * - VertexBuffer.MatricesIndicesExtraKind
  77919. * - VertexBuffer.MatricesWeightsKind
  77920. * - VertexBuffer.MatricesWeightsExtraKind
  77921. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  77922. */
  77923. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  77924. /**
  77925. * Sets the mesh global Vertex Buffer
  77926. * @param buffer defines the buffer to use
  77927. * @returns the current mesh
  77928. */
  77929. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  77930. /**
  77931. * Update a specific associated vertex buffer
  77932. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77933. * - VertexBuffer.PositionKind
  77934. * - VertexBuffer.UVKind
  77935. * - VertexBuffer.UV2Kind
  77936. * - VertexBuffer.UV3Kind
  77937. * - VertexBuffer.UV4Kind
  77938. * - VertexBuffer.UV5Kind
  77939. * - VertexBuffer.UV6Kind
  77940. * - VertexBuffer.ColorKind
  77941. * - VertexBuffer.MatricesIndicesKind
  77942. * - VertexBuffer.MatricesIndicesExtraKind
  77943. * - VertexBuffer.MatricesWeightsKind
  77944. * - VertexBuffer.MatricesWeightsExtraKind
  77945. * @param data defines the data source
  77946. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77947. * @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)
  77948. * @returns the current mesh
  77949. */
  77950. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  77951. /**
  77952. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  77953. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  77954. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  77955. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  77956. * @returns the current mesh
  77957. */
  77958. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  77959. /**
  77960. * Creates a un-shared specific occurence of the geometry for the mesh.
  77961. * @returns the current mesh
  77962. */
  77963. makeGeometryUnique(): Mesh;
  77964. /**
  77965. * Set the index buffer of this mesh
  77966. * @param indices defines the source data
  77967. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  77968. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  77969. * @returns the current mesh
  77970. */
  77971. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  77972. /**
  77973. * Update the current index buffer
  77974. * @param indices defines the source data
  77975. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  77976. * @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)
  77977. * @returns the current mesh
  77978. */
  77979. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  77980. /**
  77981. * Invert the geometry to move from a right handed system to a left handed one.
  77982. * @returns the current mesh
  77983. */
  77984. toLeftHanded(): Mesh;
  77985. /** @hidden */
  77986. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  77987. /** @hidden */
  77988. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  77989. /**
  77990. * Registers for this mesh a javascript function called just before the rendering process
  77991. * @param func defines the function to call before rendering this mesh
  77992. * @returns the current mesh
  77993. */
  77994. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77995. /**
  77996. * Disposes a previously registered javascript function called before the rendering
  77997. * @param func defines the function to remove
  77998. * @returns the current mesh
  77999. */
  78000. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  78001. /**
  78002. * Registers for this mesh a javascript function called just after the rendering is complete
  78003. * @param func defines the function to call after rendering this mesh
  78004. * @returns the current mesh
  78005. */
  78006. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78007. /**
  78008. * Disposes a previously registered javascript function called after the rendering.
  78009. * @param func defines the function to remove
  78010. * @returns the current mesh
  78011. */
  78012. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  78013. /** @hidden */
  78014. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  78015. /** @hidden */
  78016. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  78017. /** @hidden */
  78018. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  78019. /**
  78020. * 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
  78021. * @param subMesh defines the subMesh to render
  78022. * @param enableAlphaMode defines if alpha mode can be changed
  78023. * @returns the current mesh
  78024. */
  78025. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  78026. private _onBeforeDraw;
  78027. /**
  78028. * Renormalize the mesh and patch it up if there are no weights
  78029. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  78030. * However in the case of zero weights then we set just a single influence to 1.
  78031. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  78032. */
  78033. cleanMatrixWeights(): void;
  78034. private normalizeSkinFourWeights;
  78035. private normalizeSkinWeightsAndExtra;
  78036. /**
  78037. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  78038. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  78039. * the user know there was an issue with importing the mesh
  78040. * @returns a validation object with skinned, valid and report string
  78041. */
  78042. validateSkinning(): {
  78043. skinned: boolean;
  78044. valid: boolean;
  78045. report: string;
  78046. };
  78047. /** @hidden */
  78048. _checkDelayState(): Mesh;
  78049. private _queueLoad;
  78050. /**
  78051. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  78052. * A mesh is in the frustum if its bounding box intersects the frustum
  78053. * @param frustumPlanes defines the frustum to test
  78054. * @returns true if the mesh is in the frustum planes
  78055. */
  78056. isInFrustum(frustumPlanes: Plane[]): boolean;
  78057. /**
  78058. * Sets the mesh material by the material or multiMaterial `id` property
  78059. * @param id is a string identifying the material or the multiMaterial
  78060. * @returns the current mesh
  78061. */
  78062. setMaterialByID(id: string): Mesh;
  78063. /**
  78064. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  78065. * @returns an array of IAnimatable
  78066. */
  78067. getAnimatables(): IAnimatable[];
  78068. /**
  78069. * Modifies the mesh geometry according to the passed transformation matrix.
  78070. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  78071. * The mesh normals are modified using the same transformation.
  78072. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78073. * @param transform defines the transform matrix to use
  78074. * @see http://doc.babylonjs.com/resources/baking_transformations
  78075. * @returns the current mesh
  78076. */
  78077. bakeTransformIntoVertices(transform: Matrix): Mesh;
  78078. /**
  78079. * Modifies the mesh geometry according to its own current World Matrix.
  78080. * The mesh World Matrix is then reset.
  78081. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  78082. * Note that, under the hood, this method sets a new VertexBuffer each call.
  78083. * @see http://doc.babylonjs.com/resources/baking_transformations
  78084. * @returns the current mesh
  78085. */
  78086. bakeCurrentTransformIntoVertices(): Mesh;
  78087. /** @hidden */
  78088. readonly _positions: Nullable<Vector3[]>;
  78089. /** @hidden */
  78090. _resetPointsArrayCache(): Mesh;
  78091. /** @hidden */
  78092. _generatePointsArray(): boolean;
  78093. /**
  78094. * Returns a new Mesh object generated from the current mesh properties.
  78095. * This method must not get confused with createInstance()
  78096. * @param name is a string, the name given to the new mesh
  78097. * @param newParent can be any Node object (default `null`)
  78098. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  78099. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  78100. * @returns a new mesh
  78101. */
  78102. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  78103. /**
  78104. * Releases resources associated with this mesh.
  78105. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78106. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78107. */
  78108. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78109. /**
  78110. * Modifies the mesh geometry according to a displacement map.
  78111. * 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.
  78112. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78113. * @param url is a string, the URL from the image file is to be downloaded.
  78114. * @param minHeight is the lower limit of the displacement.
  78115. * @param maxHeight is the upper limit of the displacement.
  78116. * @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.
  78117. * @param uvOffset is an optional vector2 used to offset UV.
  78118. * @param uvScale is an optional vector2 used to scale UV.
  78119. * @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.
  78120. * @returns the Mesh.
  78121. */
  78122. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78123. /**
  78124. * Modifies the mesh geometry according to a displacementMap buffer.
  78125. * 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.
  78126. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  78127. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  78128. * @param heightMapWidth is the width of the buffer image.
  78129. * @param heightMapHeight is the height of the buffer image.
  78130. * @param minHeight is the lower limit of the displacement.
  78131. * @param maxHeight is the upper limit of the displacement.
  78132. * @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.
  78133. * @param uvOffset is an optional vector2 used to offset UV.
  78134. * @param uvScale is an optional vector2 used to scale UV.
  78135. * @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.
  78136. * @returns the Mesh.
  78137. */
  78138. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  78139. /**
  78140. * Modify the mesh to get a flat shading rendering.
  78141. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  78142. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  78143. * @returns current mesh
  78144. */
  78145. convertToFlatShadedMesh(): Mesh;
  78146. /**
  78147. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  78148. * In other words, more vertices, no more indices and a single bigger VBO.
  78149. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  78150. * @returns current mesh
  78151. */
  78152. convertToUnIndexedMesh(): Mesh;
  78153. /**
  78154. * Inverses facet orientations.
  78155. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  78156. * @param flipNormals will also inverts the normals
  78157. * @returns current mesh
  78158. */
  78159. flipFaces(flipNormals?: boolean): Mesh;
  78160. /** @hidden */
  78161. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  78162. /** @hidden */
  78163. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  78164. /**
  78165. * Creates a new InstancedMesh object from the mesh model.
  78166. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78167. * @param name defines the name of the new instance
  78168. * @returns a new InstancedMesh
  78169. */
  78170. createInstance(name: string): InstancedMesh;
  78171. /**
  78172. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  78173. * After this call, all the mesh instances have the same submeshes than the current mesh.
  78174. * @returns the current mesh
  78175. */
  78176. synchronizeInstances(): Mesh;
  78177. /**
  78178. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  78179. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  78180. * This should be used together with the simplification to avoid disappearing triangles.
  78181. * @param successCallback an optional success callback to be called after the optimization finished.
  78182. * @returns the current mesh
  78183. */
  78184. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  78185. /**
  78186. * Serialize current mesh
  78187. * @param serializationObject defines the object which will receive the serialization data
  78188. */
  78189. serialize(serializationObject: any): void;
  78190. /** @hidden */
  78191. _syncGeometryWithMorphTargetManager(): void;
  78192. /** @hidden */
  78193. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  78194. /**
  78195. * Returns a new Mesh object parsed from the source provided.
  78196. * @param parsedMesh is the source
  78197. * @param scene defines the hosting scene
  78198. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  78199. * @returns a new Mesh
  78200. */
  78201. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  78202. /**
  78203. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  78204. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78205. * @param name defines the name of the mesh to create
  78206. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  78207. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  78208. * @param closePath creates a seam between the first and the last points of each path of the path array
  78209. * @param offset is taken in account only if the `pathArray` is containing a single path
  78210. * @param scene defines the hosting scene
  78211. * @param updatable defines if the mesh must be flagged as updatable
  78212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78213. * @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)
  78214. * @returns a new Mesh
  78215. */
  78216. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78217. /**
  78218. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  78219. * @param name defines the name of the mesh to create
  78220. * @param radius sets the radius size (float) of the polygon (default 0.5)
  78221. * @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
  78222. * @param scene defines the hosting scene
  78223. * @param updatable defines if the mesh must be flagged as updatable
  78224. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78225. * @returns a new Mesh
  78226. */
  78227. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78228. /**
  78229. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  78230. * @param name defines the name of the mesh to create
  78231. * @param size sets the size (float) of each box side (default 1)
  78232. * @param scene defines the hosting scene
  78233. * @param updatable defines if the mesh must be flagged as updatable
  78234. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78235. * @returns a new Mesh
  78236. */
  78237. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  78238. /**
  78239. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  78240. * @param name defines the name of the mesh to create
  78241. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  78242. * @param diameter sets the diameter size (float) of the sphere (default 1)
  78243. * @param scene defines the hosting scene
  78244. * @param updatable defines if the mesh must be flagged as updatable
  78245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78246. * @returns a new Mesh
  78247. */
  78248. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78249. /**
  78250. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  78251. * @param name defines the name of the mesh to create
  78252. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  78253. * @param diameterTop set the top cap diameter (floats, default 1)
  78254. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  78255. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  78256. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  78257. * @param scene defines the hosting scene
  78258. * @param updatable defines if the mesh must be flagged as updatable
  78259. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78260. * @returns a new Mesh
  78261. */
  78262. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  78263. /**
  78264. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  78265. * @param name defines the name of the mesh to create
  78266. * @param diameter sets the diameter size (float) of the torus (default 1)
  78267. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  78268. * @param tessellation sets the number of torus sides (postive integer, default 16)
  78269. * @param scene defines the hosting scene
  78270. * @param updatable defines if the mesh must be flagged as updatable
  78271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78272. * @returns a new Mesh
  78273. */
  78274. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78275. /**
  78276. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  78277. * @param name defines the name of the mesh to create
  78278. * @param radius sets the global radius size (float) of the torus knot (default 2)
  78279. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  78280. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  78281. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  78282. * @param p the number of windings on X axis (positive integers, default 2)
  78283. * @param q the number of windings on Y axis (positive integers, default 3)
  78284. * @param scene defines the hosting scene
  78285. * @param updatable defines if the mesh must be flagged as updatable
  78286. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78287. * @returns a new Mesh
  78288. */
  78289. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78290. /**
  78291. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  78292. * @param name defines the name of the mesh to create
  78293. * @param points is an array successive Vector3
  78294. * @param scene defines the hosting scene
  78295. * @param updatable defines if the mesh must be flagged as updatable
  78296. * @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).
  78297. * @returns a new Mesh
  78298. */
  78299. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  78300. /**
  78301. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  78302. * @param name defines the name of the mesh to create
  78303. * @param points is an array successive Vector3
  78304. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  78305. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  78306. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  78307. * @param scene defines the hosting scene
  78308. * @param updatable defines if the mesh must be flagged as updatable
  78309. * @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)
  78310. * @returns a new Mesh
  78311. */
  78312. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  78313. /**
  78314. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  78315. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  78316. * 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.
  78317. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78318. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78319. * Remember you can only change the shape positions, not their number when updating a polygon.
  78320. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  78321. * @param name defines the name of the mesh to create
  78322. * @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
  78323. * @param scene defines the hosting scene
  78324. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78325. * @param updatable defines if the mesh must be flagged as updatable
  78326. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78327. * @param earcutInjection can be used to inject your own earcut reference
  78328. * @returns a new Mesh
  78329. */
  78330. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78331. /**
  78332. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  78333. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  78334. * @param name defines the name of the mesh to create
  78335. * @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
  78336. * @param depth defines the height of extrusion
  78337. * @param scene defines the hosting scene
  78338. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  78339. * @param updatable defines if the mesh must be flagged as updatable
  78340. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78341. * @param earcutInjection can be used to inject your own earcut reference
  78342. * @returns a new Mesh
  78343. */
  78344. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  78345. /**
  78346. * Creates an extruded shape mesh.
  78347. * 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
  78348. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78349. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78350. * @param name defines the name of the mesh to create
  78351. * @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
  78352. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78353. * @param scale is the value to scale the shape
  78354. * @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
  78355. * @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
  78356. * @param scene defines the hosting scene
  78357. * @param updatable defines if the mesh must be flagged as updatable
  78358. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78359. * @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)
  78360. * @returns a new Mesh
  78361. */
  78362. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78363. /**
  78364. * Creates an custom extruded shape mesh.
  78365. * The custom extrusion is a parametric shape.
  78366. * It has no predefined shape. Its final shape will depend on the input parameters.
  78367. * Please consider using the same method from the MeshBuilder class instead
  78368. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  78369. * @param name defines the name of the mesh to create
  78370. * @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
  78371. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  78372. * @param scaleFunction is a custom Javascript function called on each path point
  78373. * @param rotationFunction is a custom Javascript function called on each path point
  78374. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  78375. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  78376. * @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
  78377. * @param scene defines the hosting scene
  78378. * @param updatable defines if the mesh must be flagged as updatable
  78379. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78380. * @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)
  78381. * @returns a new Mesh
  78382. */
  78383. 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;
  78384. /**
  78385. * Creates lathe mesh.
  78386. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  78387. * Please consider using the same method from the MeshBuilder class instead
  78388. * @param name defines the name of the mesh to create
  78389. * @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
  78390. * @param radius is the radius value of the lathe
  78391. * @param tessellation is the side number of the lathe.
  78392. * @param scene defines the hosting scene
  78393. * @param updatable defines if the mesh must be flagged as updatable
  78394. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78395. * @returns a new Mesh
  78396. */
  78397. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78398. /**
  78399. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  78400. * @param name defines the name of the mesh to create
  78401. * @param size sets the size (float) of both sides of the plane at once (default 1)
  78402. * @param scene defines the hosting scene
  78403. * @param updatable defines if the mesh must be flagged as updatable
  78404. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78405. * @returns a new Mesh
  78406. */
  78407. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  78408. /**
  78409. * Creates a ground mesh.
  78410. * Please consider using the same method from the MeshBuilder class instead
  78411. * @param name defines the name of the mesh to create
  78412. * @param width set the width of the ground
  78413. * @param height set the height of the ground
  78414. * @param subdivisions sets the number of subdivisions per side
  78415. * @param scene defines the hosting scene
  78416. * @param updatable defines if the mesh must be flagged as updatable
  78417. * @returns a new Mesh
  78418. */
  78419. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  78420. /**
  78421. * Creates a tiled ground mesh.
  78422. * Please consider using the same method from the MeshBuilder class instead
  78423. * @param name defines the name of the mesh to create
  78424. * @param xmin set the ground minimum X coordinate
  78425. * @param zmin set the ground minimum Y coordinate
  78426. * @param xmax set the ground maximum X coordinate
  78427. * @param zmax set the ground maximum Z coordinate
  78428. * @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
  78429. * @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
  78430. * @param scene defines the hosting scene
  78431. * @param updatable defines if the mesh must be flagged as updatable
  78432. * @returns a new Mesh
  78433. */
  78434. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  78435. w: number;
  78436. h: number;
  78437. }, precision: {
  78438. w: number;
  78439. h: number;
  78440. }, scene: Scene, updatable?: boolean): Mesh;
  78441. /**
  78442. * Creates a ground mesh from a height map.
  78443. * Please consider using the same method from the MeshBuilder class instead
  78444. * @see http://doc.babylonjs.com/babylon101/height_map
  78445. * @param name defines the name of the mesh to create
  78446. * @param url sets the URL of the height map image resource
  78447. * @param width set the ground width size
  78448. * @param height set the ground height size
  78449. * @param subdivisions sets the number of subdivision per side
  78450. * @param minHeight is the minimum altitude on the ground
  78451. * @param maxHeight is the maximum altitude on the ground
  78452. * @param scene defines the hosting scene
  78453. * @param updatable defines if the mesh must be flagged as updatable
  78454. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  78455. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  78456. * @returns a new Mesh
  78457. */
  78458. 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;
  78459. /**
  78460. * Creates a tube mesh.
  78461. * The tube is a parametric shape.
  78462. * It has no predefined shape. Its final shape will depend on the input parameters.
  78463. * Please consider using the same method from the MeshBuilder class instead
  78464. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  78465. * @param name defines the name of the mesh to create
  78466. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  78467. * @param radius sets the tube radius size
  78468. * @param tessellation is the number of sides on the tubular surface
  78469. * @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
  78470. * @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
  78471. * @param scene defines the hosting scene
  78472. * @param updatable defines if the mesh must be flagged as updatable
  78473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  78474. * @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)
  78475. * @returns a new Mesh
  78476. */
  78477. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  78478. (i: number, distance: number): number;
  78479. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  78480. /**
  78481. * Creates a polyhedron mesh.
  78482. * Please consider using the same method from the MeshBuilder class instead.
  78483. * * 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
  78484. * * The parameter `size` (positive float, default 1) sets the polygon size
  78485. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  78486. * * 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`
  78487. * * 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
  78488. * * 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)`)
  78489. * * 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
  78490. * * 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
  78491. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78492. * * If you create a double-sided mesh, you can choose what parts of 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
  78493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78494. * @param name defines the name of the mesh to create
  78495. * @param options defines the options used to create the mesh
  78496. * @param scene defines the hosting scene
  78497. * @returns a new Mesh
  78498. */
  78499. static CreatePolyhedron(name: string, options: {
  78500. type?: number;
  78501. size?: number;
  78502. sizeX?: number;
  78503. sizeY?: number;
  78504. sizeZ?: number;
  78505. custom?: any;
  78506. faceUV?: Vector4[];
  78507. faceColors?: Color4[];
  78508. updatable?: boolean;
  78509. sideOrientation?: number;
  78510. }, scene: Scene): Mesh;
  78511. /**
  78512. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  78513. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  78514. * * 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`)
  78515. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  78516. * * 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
  78517. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78518. * * If you create a double-sided mesh, you can choose what parts of 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
  78519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78520. * @param name defines the name of the mesh
  78521. * @param options defines the options used to create the mesh
  78522. * @param scene defines the hosting scene
  78523. * @returns a new Mesh
  78524. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  78525. */
  78526. static CreateIcoSphere(name: string, options: {
  78527. radius?: number;
  78528. flat?: boolean;
  78529. subdivisions?: number;
  78530. sideOrientation?: number;
  78531. updatable?: boolean;
  78532. }, scene: Scene): Mesh;
  78533. /**
  78534. * Creates a decal mesh.
  78535. * Please consider using the same method from the MeshBuilder class instead.
  78536. * A decal is a mesh usually applied as a model onto the surface of another mesh
  78537. * @param name defines the name of the mesh
  78538. * @param sourceMesh defines the mesh receiving the decal
  78539. * @param position sets the position of the decal in world coordinates
  78540. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  78541. * @param size sets the decal scaling
  78542. * @param angle sets the angle to rotate the decal
  78543. * @returns a new Mesh
  78544. */
  78545. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  78546. /**
  78547. * Prepare internal position array for software CPU skinning
  78548. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  78549. */
  78550. setPositionsForCPUSkinning(): Float32Array;
  78551. /**
  78552. * Prepare internal normal array for software CPU skinning
  78553. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  78554. */
  78555. setNormalsForCPUSkinning(): Float32Array;
  78556. /**
  78557. * Updates the vertex buffer by applying transformation from the bones
  78558. * @param skeleton defines the skeleton to apply to current mesh
  78559. * @returns the current mesh
  78560. */
  78561. applySkeleton(skeleton: Skeleton): Mesh;
  78562. /**
  78563. * 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
  78564. * @param meshes defines the list of meshes to scan
  78565. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  78566. */
  78567. static MinMax(meshes: AbstractMesh[]): {
  78568. min: Vector3;
  78569. max: Vector3;
  78570. };
  78571. /**
  78572. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  78573. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  78574. * @returns a vector3
  78575. */
  78576. static Center(meshesOrMinMaxVector: {
  78577. min: Vector3;
  78578. max: Vector3;
  78579. } | AbstractMesh[]): Vector3;
  78580. /**
  78581. * Merge the array of meshes into a single mesh for performance reasons.
  78582. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  78583. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  78584. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  78585. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  78586. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  78587. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  78588. * @returns a new mesh
  78589. */
  78590. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  78591. /** @hidden */
  78592. addInstance(instance: InstancedMesh): void;
  78593. /** @hidden */
  78594. removeInstance(instance: InstancedMesh): void;
  78595. }
  78596. }
  78597. declare module BABYLON {
  78598. /**
  78599. * Base class for the main features of a material in Babylon.js
  78600. */
  78601. export class Material implements IAnimatable {
  78602. /**
  78603. * Returns the triangle fill mode
  78604. */
  78605. static readonly TriangleFillMode: number;
  78606. /**
  78607. * Returns the wireframe mode
  78608. */
  78609. static readonly WireFrameFillMode: number;
  78610. /**
  78611. * Returns the point fill mode
  78612. */
  78613. static readonly PointFillMode: number;
  78614. /**
  78615. * Returns the point list draw mode
  78616. */
  78617. static readonly PointListDrawMode: number;
  78618. /**
  78619. * Returns the line list draw mode
  78620. */
  78621. static readonly LineListDrawMode: number;
  78622. /**
  78623. * Returns the line loop draw mode
  78624. */
  78625. static readonly LineLoopDrawMode: number;
  78626. /**
  78627. * Returns the line strip draw mode
  78628. */
  78629. static readonly LineStripDrawMode: number;
  78630. /**
  78631. * Returns the triangle strip draw mode
  78632. */
  78633. static readonly TriangleStripDrawMode: number;
  78634. /**
  78635. * Returns the triangle fan draw mode
  78636. */
  78637. static readonly TriangleFanDrawMode: number;
  78638. /**
  78639. * Stores the clock-wise side orientation
  78640. */
  78641. static readonly ClockWiseSideOrientation: number;
  78642. /**
  78643. * Stores the counter clock-wise side orientation
  78644. */
  78645. static readonly CounterClockWiseSideOrientation: number;
  78646. /**
  78647. * The dirty texture flag value
  78648. */
  78649. static readonly TextureDirtyFlag: number;
  78650. /**
  78651. * The dirty light flag value
  78652. */
  78653. static readonly LightDirtyFlag: number;
  78654. /**
  78655. * The dirty fresnel flag value
  78656. */
  78657. static readonly FresnelDirtyFlag: number;
  78658. /**
  78659. * The dirty attribute flag value
  78660. */
  78661. static readonly AttributesDirtyFlag: number;
  78662. /**
  78663. * The dirty misc flag value
  78664. */
  78665. static readonly MiscDirtyFlag: number;
  78666. /**
  78667. * The all dirty flag value
  78668. */
  78669. static readonly AllDirtyFlag: number;
  78670. /**
  78671. * The ID of the material
  78672. */
  78673. id: string;
  78674. /**
  78675. * Gets or sets the unique id of the material
  78676. */
  78677. uniqueId: number;
  78678. /**
  78679. * The name of the material
  78680. */
  78681. name: string;
  78682. /**
  78683. * Gets or sets user defined metadata
  78684. */
  78685. metadata: any;
  78686. /**
  78687. * For internal use only. Please do not use.
  78688. */
  78689. reservedDataStore: any;
  78690. /**
  78691. * Specifies if the ready state should be checked on each call
  78692. */
  78693. checkReadyOnEveryCall: boolean;
  78694. /**
  78695. * Specifies if the ready state should be checked once
  78696. */
  78697. checkReadyOnlyOnce: boolean;
  78698. /**
  78699. * The state of the material
  78700. */
  78701. state: string;
  78702. /**
  78703. * The alpha value of the material
  78704. */
  78705. protected _alpha: number;
  78706. /**
  78707. * Sets the alpha value of the material
  78708. */
  78709. /**
  78710. * Gets the alpha value of the material
  78711. */
  78712. alpha: number;
  78713. /**
  78714. * Specifies if back face culling is enabled
  78715. */
  78716. protected _backFaceCulling: boolean;
  78717. /**
  78718. * Sets the back-face culling state
  78719. */
  78720. /**
  78721. * Gets the back-face culling state
  78722. */
  78723. backFaceCulling: boolean;
  78724. /**
  78725. * Stores the value for side orientation
  78726. */
  78727. sideOrientation: number;
  78728. /**
  78729. * Callback triggered when the material is compiled
  78730. */
  78731. onCompiled: (effect: Effect) => void;
  78732. /**
  78733. * Callback triggered when an error occurs
  78734. */
  78735. onError: (effect: Effect, errors: string) => void;
  78736. /**
  78737. * Callback triggered to get the render target textures
  78738. */
  78739. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  78740. /**
  78741. * Gets a boolean indicating that current material needs to register RTT
  78742. */
  78743. readonly hasRenderTargetTextures: boolean;
  78744. /**
  78745. * Specifies if the material should be serialized
  78746. */
  78747. doNotSerialize: boolean;
  78748. /**
  78749. * @hidden
  78750. */
  78751. _storeEffectOnSubMeshes: boolean;
  78752. /**
  78753. * Stores the animations for the material
  78754. */
  78755. animations: Array<Animation>;
  78756. /**
  78757. * An event triggered when the material is disposed
  78758. */
  78759. onDisposeObservable: Observable<Material>;
  78760. /**
  78761. * An observer which watches for dispose events
  78762. */
  78763. private _onDisposeObserver;
  78764. private _onUnBindObservable;
  78765. /**
  78766. * Called during a dispose event
  78767. */
  78768. onDispose: () => void;
  78769. private _onBindObservable;
  78770. /**
  78771. * An event triggered when the material is bound
  78772. */
  78773. readonly onBindObservable: Observable<AbstractMesh>;
  78774. /**
  78775. * An observer which watches for bind events
  78776. */
  78777. private _onBindObserver;
  78778. /**
  78779. * Called during a bind event
  78780. */
  78781. onBind: (Mesh: AbstractMesh) => void;
  78782. /**
  78783. * An event triggered when the material is unbound
  78784. */
  78785. readonly onUnBindObservable: Observable<Material>;
  78786. /**
  78787. * Stores the value of the alpha mode
  78788. */
  78789. private _alphaMode;
  78790. /**
  78791. * Sets the value of the alpha mode.
  78792. *
  78793. * | Value | Type | Description |
  78794. * | --- | --- | --- |
  78795. * | 0 | ALPHA_DISABLE | |
  78796. * | 1 | ALPHA_ADD | |
  78797. * | 2 | ALPHA_COMBINE | |
  78798. * | 3 | ALPHA_SUBTRACT | |
  78799. * | 4 | ALPHA_MULTIPLY | |
  78800. * | 5 | ALPHA_MAXIMIZED | |
  78801. * | 6 | ALPHA_ONEONE | |
  78802. * | 7 | ALPHA_PREMULTIPLIED | |
  78803. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  78804. * | 9 | ALPHA_INTERPOLATE | |
  78805. * | 10 | ALPHA_SCREENMODE | |
  78806. *
  78807. */
  78808. /**
  78809. * Gets the value of the alpha mode
  78810. */
  78811. alphaMode: number;
  78812. /**
  78813. * Stores the state of the need depth pre-pass value
  78814. */
  78815. private _needDepthPrePass;
  78816. /**
  78817. * Sets the need depth pre-pass value
  78818. */
  78819. /**
  78820. * Gets the depth pre-pass value
  78821. */
  78822. needDepthPrePass: boolean;
  78823. /**
  78824. * Specifies if depth writing should be disabled
  78825. */
  78826. disableDepthWrite: boolean;
  78827. /**
  78828. * Specifies if depth writing should be forced
  78829. */
  78830. forceDepthWrite: boolean;
  78831. /**
  78832. * Specifies if there should be a separate pass for culling
  78833. */
  78834. separateCullingPass: boolean;
  78835. /**
  78836. * Stores the state specifing if fog should be enabled
  78837. */
  78838. private _fogEnabled;
  78839. /**
  78840. * Sets the state for enabling fog
  78841. */
  78842. /**
  78843. * Gets the value of the fog enabled state
  78844. */
  78845. fogEnabled: boolean;
  78846. /**
  78847. * Stores the size of points
  78848. */
  78849. pointSize: number;
  78850. /**
  78851. * Stores the z offset value
  78852. */
  78853. zOffset: number;
  78854. /**
  78855. * Gets a value specifying if wireframe mode is enabled
  78856. */
  78857. /**
  78858. * Sets the state of wireframe mode
  78859. */
  78860. wireframe: boolean;
  78861. /**
  78862. * Gets the value specifying if point clouds are enabled
  78863. */
  78864. /**
  78865. * Sets the state of point cloud mode
  78866. */
  78867. pointsCloud: boolean;
  78868. /**
  78869. * Gets the material fill mode
  78870. */
  78871. /**
  78872. * Sets the material fill mode
  78873. */
  78874. fillMode: number;
  78875. /**
  78876. * @hidden
  78877. * Stores the effects for the material
  78878. */
  78879. _effect: Nullable<Effect>;
  78880. /**
  78881. * @hidden
  78882. * Specifies if the material was previously ready
  78883. */
  78884. _wasPreviouslyReady: boolean;
  78885. /**
  78886. * Specifies if uniform buffers should be used
  78887. */
  78888. private _useUBO;
  78889. /**
  78890. * Stores a reference to the scene
  78891. */
  78892. private _scene;
  78893. /**
  78894. * Stores the fill mode state
  78895. */
  78896. private _fillMode;
  78897. /**
  78898. * Specifies if the depth write state should be cached
  78899. */
  78900. private _cachedDepthWriteState;
  78901. /**
  78902. * Stores the uniform buffer
  78903. */
  78904. protected _uniformBuffer: UniformBuffer;
  78905. /** @hidden */
  78906. _indexInSceneMaterialArray: number;
  78907. /** @hidden */
  78908. meshMap: Nullable<{
  78909. [id: string]: AbstractMesh | undefined;
  78910. }>;
  78911. /**
  78912. * Creates a material instance
  78913. * @param name defines the name of the material
  78914. * @param scene defines the scene to reference
  78915. * @param doNotAdd specifies if the material should be added to the scene
  78916. */
  78917. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  78918. /**
  78919. * Returns a string representation of the current material
  78920. * @param fullDetails defines a boolean indicating which levels of logging is desired
  78921. * @returns a string with material information
  78922. */
  78923. toString(fullDetails?: boolean): string;
  78924. /**
  78925. * Gets the class name of the material
  78926. * @returns a string with the class name of the material
  78927. */
  78928. getClassName(): string;
  78929. /**
  78930. * Specifies if updates for the material been locked
  78931. */
  78932. readonly isFrozen: boolean;
  78933. /**
  78934. * Locks updates for the material
  78935. */
  78936. freeze(): void;
  78937. /**
  78938. * Unlocks updates for the material
  78939. */
  78940. unfreeze(): void;
  78941. /**
  78942. * Specifies if the material is ready to be used
  78943. * @param mesh defines the mesh to check
  78944. * @param useInstances specifies if instances should be used
  78945. * @returns a boolean indicating if the material is ready to be used
  78946. */
  78947. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  78948. /**
  78949. * Specifies that the submesh is ready to be used
  78950. * @param mesh defines the mesh to check
  78951. * @param subMesh defines which submesh to check
  78952. * @param useInstances specifies that instances should be used
  78953. * @returns a boolean indicating that the submesh is ready or not
  78954. */
  78955. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  78956. /**
  78957. * Returns the material effect
  78958. * @returns the effect associated with the material
  78959. */
  78960. getEffect(): Nullable<Effect>;
  78961. /**
  78962. * Returns the current scene
  78963. * @returns a Scene
  78964. */
  78965. getScene(): Scene;
  78966. /**
  78967. * Specifies if the material will require alpha blending
  78968. * @returns a boolean specifying if alpha blending is needed
  78969. */
  78970. needAlphaBlending(): boolean;
  78971. /**
  78972. * Specifies if the mesh will require alpha blending
  78973. * @param mesh defines the mesh to check
  78974. * @returns a boolean specifying if alpha blending is needed for the mesh
  78975. */
  78976. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  78977. /**
  78978. * Specifies if this material should be rendered in alpha test mode
  78979. * @returns a boolean specifying if an alpha test is needed.
  78980. */
  78981. needAlphaTesting(): boolean;
  78982. /**
  78983. * Gets the texture used for the alpha test
  78984. * @returns the texture to use for alpha testing
  78985. */
  78986. getAlphaTestTexture(): Nullable<BaseTexture>;
  78987. /**
  78988. * Marks the material to indicate that it needs to be re-calculated
  78989. */
  78990. markDirty(): void;
  78991. /** @hidden */
  78992. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  78993. /**
  78994. * Binds the material to the mesh
  78995. * @param world defines the world transformation matrix
  78996. * @param mesh defines the mesh to bind the material to
  78997. */
  78998. bind(world: Matrix, mesh?: Mesh): void;
  78999. /**
  79000. * Binds the submesh to the material
  79001. * @param world defines the world transformation matrix
  79002. * @param mesh defines the mesh containing the submesh
  79003. * @param subMesh defines the submesh to bind the material to
  79004. */
  79005. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  79006. /**
  79007. * Binds the world matrix to the material
  79008. * @param world defines the world transformation matrix
  79009. */
  79010. bindOnlyWorldMatrix(world: Matrix): void;
  79011. /**
  79012. * Binds the scene's uniform buffer to the effect.
  79013. * @param effect defines the effect to bind to the scene uniform buffer
  79014. * @param sceneUbo defines the uniform buffer storing scene data
  79015. */
  79016. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  79017. /**
  79018. * Binds the view matrix to the effect
  79019. * @param effect defines the effect to bind the view matrix to
  79020. */
  79021. bindView(effect: Effect): void;
  79022. /**
  79023. * Binds the view projection matrix to the effect
  79024. * @param effect defines the effect to bind the view projection matrix to
  79025. */
  79026. bindViewProjection(effect: Effect): void;
  79027. /**
  79028. * Specifies if material alpha testing should be turned on for the mesh
  79029. * @param mesh defines the mesh to check
  79030. */
  79031. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  79032. /**
  79033. * Processes to execute after binding the material to a mesh
  79034. * @param mesh defines the rendered mesh
  79035. */
  79036. protected _afterBind(mesh?: Mesh): void;
  79037. /**
  79038. * Unbinds the material from the mesh
  79039. */
  79040. unbind(): void;
  79041. /**
  79042. * Gets the active textures from the material
  79043. * @returns an array of textures
  79044. */
  79045. getActiveTextures(): BaseTexture[];
  79046. /**
  79047. * Specifies if the material uses a texture
  79048. * @param texture defines the texture to check against the material
  79049. * @returns a boolean specifying if the material uses the texture
  79050. */
  79051. hasTexture(texture: BaseTexture): boolean;
  79052. /**
  79053. * Makes a duplicate of the material, and gives it a new name
  79054. * @param name defines the new name for the duplicated material
  79055. * @returns the cloned material
  79056. */
  79057. clone(name: string): Nullable<Material>;
  79058. /**
  79059. * Gets the meshes bound to the material
  79060. * @returns an array of meshes bound to the material
  79061. */
  79062. getBindedMeshes(): AbstractMesh[];
  79063. /**
  79064. * Force shader compilation
  79065. * @param mesh defines the mesh associated with this material
  79066. * @param onCompiled defines a function to execute once the material is compiled
  79067. * @param options defines the options to configure the compilation
  79068. */
  79069. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  79070. clipPlane: boolean;
  79071. }>): void;
  79072. /**
  79073. * Force shader compilation
  79074. * @param mesh defines the mesh that will use this material
  79075. * @param options defines additional options for compiling the shaders
  79076. * @returns a promise that resolves when the compilation completes
  79077. */
  79078. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  79079. clipPlane: boolean;
  79080. }>): Promise<void>;
  79081. private static readonly _ImageProcessingDirtyCallBack;
  79082. private static readonly _TextureDirtyCallBack;
  79083. private static readonly _FresnelDirtyCallBack;
  79084. private static readonly _MiscDirtyCallBack;
  79085. private static readonly _LightsDirtyCallBack;
  79086. private static readonly _AttributeDirtyCallBack;
  79087. private static _FresnelAndMiscDirtyCallBack;
  79088. private static _TextureAndMiscDirtyCallBack;
  79089. private static readonly _DirtyCallbackArray;
  79090. private static readonly _RunDirtyCallBacks;
  79091. /**
  79092. * Marks a define in the material to indicate that it needs to be re-computed
  79093. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  79094. */
  79095. markAsDirty(flag: number): void;
  79096. /**
  79097. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  79098. * @param func defines a function which checks material defines against the submeshes
  79099. */
  79100. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  79101. /**
  79102. * Indicates that image processing needs to be re-calculated for all submeshes
  79103. */
  79104. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  79105. /**
  79106. * Indicates that textures need to be re-calculated for all submeshes
  79107. */
  79108. protected _markAllSubMeshesAsTexturesDirty(): void;
  79109. /**
  79110. * Indicates that fresnel needs to be re-calculated for all submeshes
  79111. */
  79112. protected _markAllSubMeshesAsFresnelDirty(): void;
  79113. /**
  79114. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  79115. */
  79116. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  79117. /**
  79118. * Indicates that lights need to be re-calculated for all submeshes
  79119. */
  79120. protected _markAllSubMeshesAsLightsDirty(): void;
  79121. /**
  79122. * Indicates that attributes need to be re-calculated for all submeshes
  79123. */
  79124. protected _markAllSubMeshesAsAttributesDirty(): void;
  79125. /**
  79126. * Indicates that misc needs to be re-calculated for all submeshes
  79127. */
  79128. protected _markAllSubMeshesAsMiscDirty(): void;
  79129. /**
  79130. * Indicates that textures and misc need to be re-calculated for all submeshes
  79131. */
  79132. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  79133. /**
  79134. * Disposes the material
  79135. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79136. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79137. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79138. */
  79139. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79140. /** @hidden */
  79141. private releaseVertexArrayObject;
  79142. /**
  79143. * Serializes this material
  79144. * @returns the serialized material object
  79145. */
  79146. serialize(): any;
  79147. /**
  79148. * Creates a material from parsed material data
  79149. * @param parsedMaterial defines parsed material data
  79150. * @param scene defines the hosting scene
  79151. * @param rootUrl defines the root URL to use to load textures
  79152. * @returns a new material
  79153. */
  79154. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  79155. }
  79156. }
  79157. declare module BABYLON {
  79158. /**
  79159. * Base class for submeshes
  79160. */
  79161. export class BaseSubMesh {
  79162. /** @hidden */
  79163. _materialDefines: Nullable<MaterialDefines>;
  79164. /** @hidden */
  79165. _materialEffect: Nullable<Effect>;
  79166. /**
  79167. * Gets associated effect
  79168. */
  79169. readonly effect: Nullable<Effect>;
  79170. /**
  79171. * Sets associated effect (effect used to render this submesh)
  79172. * @param effect defines the effect to associate with
  79173. * @param defines defines the set of defines used to compile this effect
  79174. */
  79175. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  79176. }
  79177. /**
  79178. * Defines a subdivision inside a mesh
  79179. */
  79180. export class SubMesh extends BaseSubMesh implements ICullable {
  79181. /** the material index to use */
  79182. materialIndex: number;
  79183. /** vertex index start */
  79184. verticesStart: number;
  79185. /** vertices count */
  79186. verticesCount: number;
  79187. /** index start */
  79188. indexStart: number;
  79189. /** indices count */
  79190. indexCount: number;
  79191. /** @hidden */
  79192. _linesIndexCount: number;
  79193. private _mesh;
  79194. private _renderingMesh;
  79195. private _boundingInfo;
  79196. private _linesIndexBuffer;
  79197. /** @hidden */
  79198. _lastColliderWorldVertices: Nullable<Vector3[]>;
  79199. /** @hidden */
  79200. _trianglePlanes: Plane[];
  79201. /** @hidden */
  79202. _lastColliderTransformMatrix: Matrix;
  79203. /** @hidden */
  79204. _renderId: number;
  79205. /** @hidden */
  79206. _alphaIndex: number;
  79207. /** @hidden */
  79208. _distanceToCamera: number;
  79209. /** @hidden */
  79210. _id: number;
  79211. private _currentMaterial;
  79212. /**
  79213. * Add a new submesh to a mesh
  79214. * @param materialIndex defines the material index to use
  79215. * @param verticesStart defines vertex index start
  79216. * @param verticesCount defines vertices count
  79217. * @param indexStart defines index start
  79218. * @param indexCount defines indices count
  79219. * @param mesh defines the parent mesh
  79220. * @param renderingMesh defines an optional rendering mesh
  79221. * @param createBoundingBox defines if bounding box should be created for this submesh
  79222. * @returns the new submesh
  79223. */
  79224. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  79225. /**
  79226. * Creates a new submesh
  79227. * @param materialIndex defines the material index to use
  79228. * @param verticesStart defines vertex index start
  79229. * @param verticesCount defines vertices count
  79230. * @param indexStart defines index start
  79231. * @param indexCount defines indices count
  79232. * @param mesh defines the parent mesh
  79233. * @param renderingMesh defines an optional rendering mesh
  79234. * @param createBoundingBox defines if bounding box should be created for this submesh
  79235. */
  79236. constructor(
  79237. /** the material index to use */
  79238. materialIndex: number,
  79239. /** vertex index start */
  79240. verticesStart: number,
  79241. /** vertices count */
  79242. verticesCount: number,
  79243. /** index start */
  79244. indexStart: number,
  79245. /** indices count */
  79246. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  79247. /**
  79248. * Returns true if this submesh covers the entire parent mesh
  79249. * @ignorenaming
  79250. */
  79251. readonly IsGlobal: boolean;
  79252. /**
  79253. * Returns the submesh BoudingInfo object
  79254. * @returns current bounding info (or mesh's one if the submesh is global)
  79255. */
  79256. getBoundingInfo(): BoundingInfo;
  79257. /**
  79258. * Sets the submesh BoundingInfo
  79259. * @param boundingInfo defines the new bounding info to use
  79260. * @returns the SubMesh
  79261. */
  79262. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  79263. /**
  79264. * Returns the mesh of the current submesh
  79265. * @return the parent mesh
  79266. */
  79267. getMesh(): AbstractMesh;
  79268. /**
  79269. * Returns the rendering mesh of the submesh
  79270. * @returns the rendering mesh (could be different from parent mesh)
  79271. */
  79272. getRenderingMesh(): Mesh;
  79273. /**
  79274. * Returns the submesh material
  79275. * @returns null or the current material
  79276. */
  79277. getMaterial(): Nullable<Material>;
  79278. /**
  79279. * Sets a new updated BoundingInfo object to the submesh
  79280. * @returns the SubMesh
  79281. */
  79282. refreshBoundingInfo(): SubMesh;
  79283. /** @hidden */
  79284. _checkCollision(collider: Collider): boolean;
  79285. /**
  79286. * Updates the submesh BoundingInfo
  79287. * @param world defines the world matrix to use to update the bounding info
  79288. * @returns the submesh
  79289. */
  79290. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  79291. /**
  79292. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  79293. * @param frustumPlanes defines the frustum planes
  79294. * @returns true if the submesh is intersecting with the frustum
  79295. */
  79296. isInFrustum(frustumPlanes: Plane[]): boolean;
  79297. /**
  79298. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  79299. * @param frustumPlanes defines the frustum planes
  79300. * @returns true if the submesh is inside the frustum
  79301. */
  79302. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79303. /**
  79304. * Renders the submesh
  79305. * @param enableAlphaMode defines if alpha needs to be used
  79306. * @returns the submesh
  79307. */
  79308. render(enableAlphaMode: boolean): SubMesh;
  79309. /**
  79310. * @hidden
  79311. */
  79312. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  79313. /**
  79314. * Checks if the submesh intersects with a ray
  79315. * @param ray defines the ray to test
  79316. * @returns true is the passed ray intersects the submesh bounding box
  79317. */
  79318. canIntersects(ray: Ray): boolean;
  79319. /**
  79320. * Intersects current submesh with a ray
  79321. * @param ray defines the ray to test
  79322. * @param positions defines mesh's positions array
  79323. * @param indices defines mesh's indices array
  79324. * @param fastCheck defines if only bounding info should be used
  79325. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  79326. * @returns intersection info or null if no intersection
  79327. */
  79328. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  79329. /** @hidden */
  79330. private _intersectLines;
  79331. /** @hidden */
  79332. private _intersectTriangles;
  79333. /** @hidden */
  79334. _rebuild(): void;
  79335. /**
  79336. * Creates a new submesh from the passed mesh
  79337. * @param newMesh defines the new hosting mesh
  79338. * @param newRenderingMesh defines an optional rendering mesh
  79339. * @returns the new submesh
  79340. */
  79341. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  79342. /**
  79343. * Release associated resources
  79344. */
  79345. dispose(): void;
  79346. /**
  79347. * Gets the class name
  79348. * @returns the string "SubMesh".
  79349. */
  79350. getClassName(): string;
  79351. /**
  79352. * Creates a new submesh from indices data
  79353. * @param materialIndex the index of the main mesh material
  79354. * @param startIndex the index where to start the copy in the mesh indices array
  79355. * @param indexCount the number of indices to copy then from the startIndex
  79356. * @param mesh the main mesh to create the submesh from
  79357. * @param renderingMesh the optional rendering mesh
  79358. * @returns a new submesh
  79359. */
  79360. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  79361. }
  79362. }
  79363. declare module BABYLON {
  79364. /**
  79365. * Class used to store geometry data (vertex buffers + index buffer)
  79366. */
  79367. export class Geometry implements IGetSetVerticesData {
  79368. /**
  79369. * Gets or sets the ID of the geometry
  79370. */
  79371. id: string;
  79372. /**
  79373. * Gets or sets the unique ID of the geometry
  79374. */
  79375. uniqueId: number;
  79376. /**
  79377. * Gets the delay loading state of the geometry (none by default which means not delayed)
  79378. */
  79379. delayLoadState: number;
  79380. /**
  79381. * Gets the file containing the data to load when running in delay load state
  79382. */
  79383. delayLoadingFile: Nullable<string>;
  79384. /**
  79385. * Callback called when the geometry is updated
  79386. */
  79387. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  79388. private _scene;
  79389. private _engine;
  79390. private _meshes;
  79391. private _totalVertices;
  79392. /** @hidden */
  79393. _indices: IndicesArray;
  79394. /** @hidden */
  79395. _vertexBuffers: {
  79396. [key: string]: VertexBuffer;
  79397. };
  79398. private _isDisposed;
  79399. private _extend;
  79400. private _boundingBias;
  79401. /** @hidden */
  79402. _delayInfo: Array<string>;
  79403. private _indexBuffer;
  79404. private _indexBufferIsUpdatable;
  79405. /** @hidden */
  79406. _boundingInfo: Nullable<BoundingInfo>;
  79407. /** @hidden */
  79408. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  79409. /** @hidden */
  79410. _softwareSkinningFrameId: number;
  79411. private _vertexArrayObjects;
  79412. private _updatable;
  79413. /** @hidden */
  79414. _positions: Nullable<Vector3[]>;
  79415. /**
  79416. * 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
  79417. */
  79418. /**
  79419. * 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
  79420. */
  79421. boundingBias: Vector2;
  79422. /**
  79423. * Static function used to attach a new empty geometry to a mesh
  79424. * @param mesh defines the mesh to attach the geometry to
  79425. * @returns the new Geometry
  79426. */
  79427. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  79428. /**
  79429. * Creates a new geometry
  79430. * @param id defines the unique ID
  79431. * @param scene defines the hosting scene
  79432. * @param vertexData defines the VertexData used to get geometry data
  79433. * @param updatable defines if geometry must be updatable (false by default)
  79434. * @param mesh defines the mesh that will be associated with the geometry
  79435. */
  79436. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  79437. /**
  79438. * Gets the current extend of the geometry
  79439. */
  79440. readonly extend: {
  79441. minimum: Vector3;
  79442. maximum: Vector3;
  79443. };
  79444. /**
  79445. * Gets the hosting scene
  79446. * @returns the hosting Scene
  79447. */
  79448. getScene(): Scene;
  79449. /**
  79450. * Gets the hosting engine
  79451. * @returns the hosting Engine
  79452. */
  79453. getEngine(): Engine;
  79454. /**
  79455. * Defines if the geometry is ready to use
  79456. * @returns true if the geometry is ready to be used
  79457. */
  79458. isReady(): boolean;
  79459. /**
  79460. * Gets a value indicating that the geometry should not be serialized
  79461. */
  79462. readonly doNotSerialize: boolean;
  79463. /** @hidden */
  79464. _rebuild(): void;
  79465. /**
  79466. * Affects all geometry data in one call
  79467. * @param vertexData defines the geometry data
  79468. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  79469. */
  79470. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  79471. /**
  79472. * Set specific vertex data
  79473. * @param kind defines the data kind (Position, normal, etc...)
  79474. * @param data defines the vertex data to use
  79475. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79476. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79477. */
  79478. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  79479. /**
  79480. * Removes a specific vertex data
  79481. * @param kind defines the data kind (Position, normal, etc...)
  79482. */
  79483. removeVerticesData(kind: string): void;
  79484. /**
  79485. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  79486. * @param buffer defines the vertex buffer to use
  79487. * @param totalVertices defines the total number of vertices for position kind (could be null)
  79488. */
  79489. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  79490. /**
  79491. * Update a specific vertex buffer
  79492. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  79493. * It will do nothing if the buffer is not updatable
  79494. * @param kind defines the data kind (Position, normal, etc...)
  79495. * @param data defines the data to use
  79496. * @param offset defines the offset in the target buffer where to store the data
  79497. * @param useBytes set to true if the offset is in bytes
  79498. */
  79499. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  79500. /**
  79501. * Update a specific vertex buffer
  79502. * This function will create a new buffer if the current one is not updatable
  79503. * @param kind defines the data kind (Position, normal, etc...)
  79504. * @param data defines the data to use
  79505. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  79506. */
  79507. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  79508. private _updateBoundingInfo;
  79509. /** @hidden */
  79510. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  79511. /**
  79512. * Gets total number of vertices
  79513. * @returns the total number of vertices
  79514. */
  79515. getTotalVertices(): number;
  79516. /**
  79517. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79518. * @param kind defines the data kind (Position, normal, etc...)
  79519. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79520. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79521. * @returns a float array containing vertex data
  79522. */
  79523. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79524. /**
  79525. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  79526. * @param kind defines the data kind (Position, normal, etc...)
  79527. * @returns true if the vertex buffer with the specified kind is updatable
  79528. */
  79529. isVertexBufferUpdatable(kind: string): boolean;
  79530. /**
  79531. * Gets a specific vertex buffer
  79532. * @param kind defines the data kind (Position, normal, etc...)
  79533. * @returns a VertexBuffer
  79534. */
  79535. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79536. /**
  79537. * Returns all vertex buffers
  79538. * @return an object holding all vertex buffers indexed by kind
  79539. */
  79540. getVertexBuffers(): Nullable<{
  79541. [key: string]: VertexBuffer;
  79542. }>;
  79543. /**
  79544. * Gets a boolean indicating if specific vertex buffer is present
  79545. * @param kind defines the data kind (Position, normal, etc...)
  79546. * @returns true if data is present
  79547. */
  79548. isVerticesDataPresent(kind: string): boolean;
  79549. /**
  79550. * Gets a list of all attached data kinds (Position, normal, etc...)
  79551. * @returns a list of string containing all kinds
  79552. */
  79553. getVerticesDataKinds(): string[];
  79554. /**
  79555. * Update index buffer
  79556. * @param indices defines the indices to store in the index buffer
  79557. * @param offset defines the offset in the target buffer where to store the data
  79558. * @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)
  79559. */
  79560. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  79561. /**
  79562. * Creates a new index buffer
  79563. * @param indices defines the indices to store in the index buffer
  79564. * @param totalVertices defines the total number of vertices (could be null)
  79565. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79566. */
  79567. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  79568. /**
  79569. * Return the total number of indices
  79570. * @returns the total number of indices
  79571. */
  79572. getTotalIndices(): number;
  79573. /**
  79574. * Gets the index buffer array
  79575. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79576. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79577. * @returns the index buffer array
  79578. */
  79579. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79580. /**
  79581. * Gets the index buffer
  79582. * @return the index buffer
  79583. */
  79584. getIndexBuffer(): Nullable<WebGLBuffer>;
  79585. /** @hidden */
  79586. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  79587. /**
  79588. * Release the associated resources for a specific mesh
  79589. * @param mesh defines the source mesh
  79590. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  79591. */
  79592. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  79593. /**
  79594. * Apply current geometry to a given mesh
  79595. * @param mesh defines the mesh to apply geometry to
  79596. */
  79597. applyToMesh(mesh: Mesh): void;
  79598. private _updateExtend;
  79599. private _applyToMesh;
  79600. private notifyUpdate;
  79601. /**
  79602. * Load the geometry if it was flagged as delay loaded
  79603. * @param scene defines the hosting scene
  79604. * @param onLoaded defines a callback called when the geometry is loaded
  79605. */
  79606. load(scene: Scene, onLoaded?: () => void): void;
  79607. private _queueLoad;
  79608. /**
  79609. * Invert the geometry to move from a right handed system to a left handed one.
  79610. */
  79611. toLeftHanded(): void;
  79612. /** @hidden */
  79613. _resetPointsArrayCache(): void;
  79614. /** @hidden */
  79615. _generatePointsArray(): boolean;
  79616. /**
  79617. * Gets a value indicating if the geometry is disposed
  79618. * @returns true if the geometry was disposed
  79619. */
  79620. isDisposed(): boolean;
  79621. private _disposeVertexArrayObjects;
  79622. /**
  79623. * Free all associated resources
  79624. */
  79625. dispose(): void;
  79626. /**
  79627. * Clone the current geometry into a new geometry
  79628. * @param id defines the unique ID of the new geometry
  79629. * @returns a new geometry object
  79630. */
  79631. copy(id: string): Geometry;
  79632. /**
  79633. * Serialize the current geometry info (and not the vertices data) into a JSON object
  79634. * @return a JSON representation of the current geometry data (without the vertices data)
  79635. */
  79636. serialize(): any;
  79637. private toNumberArray;
  79638. /**
  79639. * Serialize all vertices data into a JSON oject
  79640. * @returns a JSON representation of the current geometry data
  79641. */
  79642. serializeVerticeData(): any;
  79643. /**
  79644. * Extracts a clone of a mesh geometry
  79645. * @param mesh defines the source mesh
  79646. * @param id defines the unique ID of the new geometry object
  79647. * @returns the new geometry object
  79648. */
  79649. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  79650. /**
  79651. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  79652. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  79653. * Be aware Math.random() could cause collisions, but:
  79654. * "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"
  79655. * @returns a string containing a new GUID
  79656. */
  79657. static RandomId(): string;
  79658. /** @hidden */
  79659. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  79660. private static _CleanMatricesWeights;
  79661. /**
  79662. * Create a new geometry from persisted data (Using .babylon file format)
  79663. * @param parsedVertexData defines the persisted data
  79664. * @param scene defines the hosting scene
  79665. * @param rootUrl defines the root url to use to load assets (like delayed data)
  79666. * @returns the new geometry object
  79667. */
  79668. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  79669. }
  79670. }
  79671. declare module BABYLON {
  79672. /**
  79673. * Define an interface for all classes that will get and set the data on vertices
  79674. */
  79675. export interface IGetSetVerticesData {
  79676. /**
  79677. * Gets a boolean indicating if specific vertex data is present
  79678. * @param kind defines the vertex data kind to use
  79679. * @returns true is data kind is present
  79680. */
  79681. isVerticesDataPresent(kind: string): boolean;
  79682. /**
  79683. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  79684. * @param kind defines the data kind (Position, normal, etc...)
  79685. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  79686. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79687. * @returns a float array containing vertex data
  79688. */
  79689. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79690. /**
  79691. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79692. * @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.
  79693. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79694. * @returns the indices array or an empty array if the mesh has no geometry
  79695. */
  79696. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79697. /**
  79698. * Set specific vertex data
  79699. * @param kind defines the data kind (Position, normal, etc...)
  79700. * @param data defines the vertex data to use
  79701. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  79702. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  79703. */
  79704. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  79705. /**
  79706. * Update a specific associated vertex buffer
  79707. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79708. * - VertexBuffer.PositionKind
  79709. * - VertexBuffer.UVKind
  79710. * - VertexBuffer.UV2Kind
  79711. * - VertexBuffer.UV3Kind
  79712. * - VertexBuffer.UV4Kind
  79713. * - VertexBuffer.UV5Kind
  79714. * - VertexBuffer.UV6Kind
  79715. * - VertexBuffer.ColorKind
  79716. * - VertexBuffer.MatricesIndicesKind
  79717. * - VertexBuffer.MatricesIndicesExtraKind
  79718. * - VertexBuffer.MatricesWeightsKind
  79719. * - VertexBuffer.MatricesWeightsExtraKind
  79720. * @param data defines the data source
  79721. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79722. * @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)
  79723. */
  79724. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  79725. /**
  79726. * Creates a new index buffer
  79727. * @param indices defines the indices to store in the index buffer
  79728. * @param totalVertices defines the total number of vertices (could be null)
  79729. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  79730. */
  79731. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  79732. }
  79733. /**
  79734. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  79735. */
  79736. export class VertexData {
  79737. /**
  79738. * Mesh side orientation : usually the external or front surface
  79739. */
  79740. static readonly FRONTSIDE: number;
  79741. /**
  79742. * Mesh side orientation : usually the internal or back surface
  79743. */
  79744. static readonly BACKSIDE: number;
  79745. /**
  79746. * Mesh side orientation : both internal and external or front and back surfaces
  79747. */
  79748. static readonly DOUBLESIDE: number;
  79749. /**
  79750. * Mesh side orientation : by default, `FRONTSIDE`
  79751. */
  79752. static readonly DEFAULTSIDE: number;
  79753. /**
  79754. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  79755. */
  79756. positions: Nullable<FloatArray>;
  79757. /**
  79758. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  79759. */
  79760. normals: Nullable<FloatArray>;
  79761. /**
  79762. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  79763. */
  79764. tangents: Nullable<FloatArray>;
  79765. /**
  79766. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79767. */
  79768. uvs: Nullable<FloatArray>;
  79769. /**
  79770. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79771. */
  79772. uvs2: Nullable<FloatArray>;
  79773. /**
  79774. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79775. */
  79776. uvs3: Nullable<FloatArray>;
  79777. /**
  79778. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79779. */
  79780. uvs4: Nullable<FloatArray>;
  79781. /**
  79782. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79783. */
  79784. uvs5: Nullable<FloatArray>;
  79785. /**
  79786. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  79787. */
  79788. uvs6: Nullable<FloatArray>;
  79789. /**
  79790. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  79791. */
  79792. colors: Nullable<FloatArray>;
  79793. /**
  79794. * 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).
  79795. */
  79796. matricesIndices: Nullable<FloatArray>;
  79797. /**
  79798. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  79799. */
  79800. matricesWeights: Nullable<FloatArray>;
  79801. /**
  79802. * An array extending the number of possible indices
  79803. */
  79804. matricesIndicesExtra: Nullable<FloatArray>;
  79805. /**
  79806. * An array extending the number of possible weights when the number of indices is extended
  79807. */
  79808. matricesWeightsExtra: Nullable<FloatArray>;
  79809. /**
  79810. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  79811. */
  79812. indices: Nullable<IndicesArray>;
  79813. /**
  79814. * Uses the passed data array to set the set the values for the specified kind of data
  79815. * @param data a linear array of floating numbers
  79816. * @param kind the type of data that is being set, eg positions, colors etc
  79817. */
  79818. set(data: FloatArray, kind: string): void;
  79819. /**
  79820. * Associates the vertexData to the passed Mesh.
  79821. * Sets it as updatable or not (default `false`)
  79822. * @param mesh the mesh the vertexData is applied to
  79823. * @param updatable when used and having the value true allows new data to update the vertexData
  79824. * @returns the VertexData
  79825. */
  79826. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  79827. /**
  79828. * Associates the vertexData to the passed Geometry.
  79829. * Sets it as updatable or not (default `false`)
  79830. * @param geometry the geometry the vertexData is applied to
  79831. * @param updatable when used and having the value true allows new data to update the vertexData
  79832. * @returns VertexData
  79833. */
  79834. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  79835. /**
  79836. * Updates the associated mesh
  79837. * @param mesh the mesh to be updated
  79838. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79839. * @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
  79840. * @returns VertexData
  79841. */
  79842. updateMesh(mesh: Mesh): VertexData;
  79843. /**
  79844. * Updates the associated geometry
  79845. * @param geometry the geometry to be updated
  79846. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  79847. * @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
  79848. * @returns VertexData.
  79849. */
  79850. updateGeometry(geometry: Geometry): VertexData;
  79851. private _applyTo;
  79852. private _update;
  79853. /**
  79854. * Transforms each position and each normal of the vertexData according to the passed Matrix
  79855. * @param matrix the transforming matrix
  79856. * @returns the VertexData
  79857. */
  79858. transform(matrix: Matrix): VertexData;
  79859. /**
  79860. * Merges the passed VertexData into the current one
  79861. * @param other the VertexData to be merged into the current one
  79862. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  79863. * @returns the modified VertexData
  79864. */
  79865. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  79866. private _mergeElement;
  79867. private _validate;
  79868. /**
  79869. * Serializes the VertexData
  79870. * @returns a serialized object
  79871. */
  79872. serialize(): any;
  79873. /**
  79874. * Extracts the vertexData from a mesh
  79875. * @param mesh the mesh from which to extract the VertexData
  79876. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  79877. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79878. * @returns the object VertexData associated to the passed mesh
  79879. */
  79880. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79881. /**
  79882. * Extracts the vertexData from the geometry
  79883. * @param geometry the geometry from which to extract the VertexData
  79884. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  79885. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  79886. * @returns the object VertexData associated to the passed mesh
  79887. */
  79888. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  79889. private static _ExtractFrom;
  79890. /**
  79891. * Creates the VertexData for a Ribbon
  79892. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  79893. * * pathArray array of paths, each of which an array of successive Vector3
  79894. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  79895. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  79896. * * 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
  79897. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79898. * * 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)
  79899. * * 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)
  79900. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  79901. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  79902. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  79903. * @returns the VertexData of the ribbon
  79904. */
  79905. static CreateRibbon(options: {
  79906. pathArray: Vector3[][];
  79907. closeArray?: boolean;
  79908. closePath?: boolean;
  79909. offset?: number;
  79910. sideOrientation?: number;
  79911. frontUVs?: Vector4;
  79912. backUVs?: Vector4;
  79913. invertUV?: boolean;
  79914. uvs?: Vector2[];
  79915. colors?: Color4[];
  79916. }): VertexData;
  79917. /**
  79918. * Creates the VertexData for a box
  79919. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79920. * * size sets the width, height and depth of the box to the value of size, optional default 1
  79921. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  79922. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  79923. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  79924. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  79925. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  79926. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79927. * * 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)
  79928. * * 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)
  79929. * @returns the VertexData of the box
  79930. */
  79931. static CreateBox(options: {
  79932. size?: number;
  79933. width?: number;
  79934. height?: number;
  79935. depth?: number;
  79936. faceUV?: Vector4[];
  79937. faceColors?: Color4[];
  79938. sideOrientation?: number;
  79939. frontUVs?: Vector4;
  79940. backUVs?: Vector4;
  79941. }): VertexData;
  79942. /**
  79943. * Creates the VertexData for an ellipsoid, defaults to a sphere
  79944. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79945. * * segments sets the number of horizontal strips optional, default 32
  79946. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  79947. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  79948. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  79949. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  79950. * * 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
  79951. * * 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
  79952. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79953. * * 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)
  79954. * * 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)
  79955. * @returns the VertexData of the ellipsoid
  79956. */
  79957. static CreateSphere(options: {
  79958. segments?: number;
  79959. diameter?: number;
  79960. diameterX?: number;
  79961. diameterY?: number;
  79962. diameterZ?: number;
  79963. arc?: number;
  79964. slice?: number;
  79965. sideOrientation?: number;
  79966. frontUVs?: Vector4;
  79967. backUVs?: Vector4;
  79968. }): VertexData;
  79969. /**
  79970. * Creates the VertexData for a cylinder, cone or prism
  79971. * @param options an object used to set the following optional parameters for the box, required but can be empty
  79972. * * height sets the height (y direction) of the cylinder, optional, default 2
  79973. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  79974. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  79975. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  79976. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  79977. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  79978. * * 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
  79979. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  79980. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  79981. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  79982. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  79983. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79984. * * 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)
  79985. * * 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)
  79986. * @returns the VertexData of the cylinder, cone or prism
  79987. */
  79988. static CreateCylinder(options: {
  79989. height?: number;
  79990. diameterTop?: number;
  79991. diameterBottom?: number;
  79992. diameter?: number;
  79993. tessellation?: number;
  79994. subdivisions?: number;
  79995. arc?: number;
  79996. faceColors?: Color4[];
  79997. faceUV?: Vector4[];
  79998. hasRings?: boolean;
  79999. enclose?: boolean;
  80000. sideOrientation?: number;
  80001. frontUVs?: Vector4;
  80002. backUVs?: Vector4;
  80003. }): VertexData;
  80004. /**
  80005. * Creates the VertexData for a torus
  80006. * @param options an object used to set the following optional parameters for the box, required but can be empty
  80007. * * diameter the diameter of the torus, optional default 1
  80008. * * thickness the diameter of the tube forming the torus, optional default 0.5
  80009. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  80010. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80011. * * 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)
  80012. * * 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)
  80013. * @returns the VertexData of the torus
  80014. */
  80015. static CreateTorus(options: {
  80016. diameter?: number;
  80017. thickness?: number;
  80018. tessellation?: number;
  80019. sideOrientation?: number;
  80020. frontUVs?: Vector4;
  80021. backUVs?: Vector4;
  80022. }): VertexData;
  80023. /**
  80024. * Creates the VertexData of the LineSystem
  80025. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  80026. * - lines an array of lines, each line being an array of successive Vector3
  80027. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  80028. * @returns the VertexData of the LineSystem
  80029. */
  80030. static CreateLineSystem(options: {
  80031. lines: Vector3[][];
  80032. colors?: Nullable<Color4[][]>;
  80033. }): VertexData;
  80034. /**
  80035. * Create the VertexData for a DashedLines
  80036. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  80037. * - points an array successive Vector3
  80038. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  80039. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  80040. * - dashNb the intended total number of dashes, optional, default 200
  80041. * @returns the VertexData for the DashedLines
  80042. */
  80043. static CreateDashedLines(options: {
  80044. points: Vector3[];
  80045. dashSize?: number;
  80046. gapSize?: number;
  80047. dashNb?: number;
  80048. }): VertexData;
  80049. /**
  80050. * Creates the VertexData for a Ground
  80051. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80052. * - width the width (x direction) of the ground, optional, default 1
  80053. * - height the height (z direction) of the ground, optional, default 1
  80054. * - subdivisions the number of subdivisions per side, optional, default 1
  80055. * @returns the VertexData of the Ground
  80056. */
  80057. static CreateGround(options: {
  80058. width?: number;
  80059. height?: number;
  80060. subdivisions?: number;
  80061. subdivisionsX?: number;
  80062. subdivisionsY?: number;
  80063. }): VertexData;
  80064. /**
  80065. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  80066. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  80067. * * xmin the ground minimum X coordinate, optional, default -1
  80068. * * zmin the ground minimum Z coordinate, optional, default -1
  80069. * * xmax the ground maximum X coordinate, optional, default 1
  80070. * * zmax the ground maximum Z coordinate, optional, default 1
  80071. * * 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}
  80072. * * 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}
  80073. * @returns the VertexData of the TiledGround
  80074. */
  80075. static CreateTiledGround(options: {
  80076. xmin: number;
  80077. zmin: number;
  80078. xmax: number;
  80079. zmax: number;
  80080. subdivisions?: {
  80081. w: number;
  80082. h: number;
  80083. };
  80084. precision?: {
  80085. w: number;
  80086. h: number;
  80087. };
  80088. }): VertexData;
  80089. /**
  80090. * Creates the VertexData of the Ground designed from a heightmap
  80091. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  80092. * * width the width (x direction) of the ground
  80093. * * height the height (z direction) of the ground
  80094. * * subdivisions the number of subdivisions per side
  80095. * * minHeight the minimum altitude on the ground, optional, default 0
  80096. * * maxHeight the maximum altitude on the ground, optional default 1
  80097. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  80098. * * buffer the array holding the image color data
  80099. * * bufferWidth the width of image
  80100. * * bufferHeight the height of image
  80101. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  80102. * @returns the VertexData of the Ground designed from a heightmap
  80103. */
  80104. static CreateGroundFromHeightMap(options: {
  80105. width: number;
  80106. height: number;
  80107. subdivisions: number;
  80108. minHeight: number;
  80109. maxHeight: number;
  80110. colorFilter: Color3;
  80111. buffer: Uint8Array;
  80112. bufferWidth: number;
  80113. bufferHeight: number;
  80114. alphaFilter: number;
  80115. }): VertexData;
  80116. /**
  80117. * Creates the VertexData for a Plane
  80118. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  80119. * * size sets the width and height of the plane to the value of size, optional default 1
  80120. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  80121. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  80122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80123. * * 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)
  80124. * * 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)
  80125. * @returns the VertexData of the box
  80126. */
  80127. static CreatePlane(options: {
  80128. size?: number;
  80129. width?: number;
  80130. height?: number;
  80131. sideOrientation?: number;
  80132. frontUVs?: Vector4;
  80133. backUVs?: Vector4;
  80134. }): VertexData;
  80135. /**
  80136. * Creates the VertexData of the Disc or regular Polygon
  80137. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  80138. * * radius the radius of the disc, optional default 0.5
  80139. * * tessellation the number of polygon sides, optional, default 64
  80140. * * 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
  80141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80142. * * 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)
  80143. * * 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)
  80144. * @returns the VertexData of the box
  80145. */
  80146. static CreateDisc(options: {
  80147. radius?: number;
  80148. tessellation?: number;
  80149. arc?: number;
  80150. sideOrientation?: number;
  80151. frontUVs?: Vector4;
  80152. backUVs?: Vector4;
  80153. }): VertexData;
  80154. /**
  80155. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  80156. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  80157. * @param polygon a mesh built from polygonTriangulation.build()
  80158. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80159. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80160. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80161. * @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)
  80162. * @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)
  80163. * @returns the VertexData of the Polygon
  80164. */
  80165. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  80166. /**
  80167. * Creates the VertexData of the IcoSphere
  80168. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  80169. * * radius the radius of the IcoSphere, optional default 1
  80170. * * radiusX allows stretching in the x direction, optional, default radius
  80171. * * radiusY allows stretching in the y direction, optional, default radius
  80172. * * radiusZ allows stretching in the z direction, optional, default radius
  80173. * * flat when true creates a flat shaded mesh, optional, default true
  80174. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80176. * * 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)
  80177. * * 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)
  80178. * @returns the VertexData of the IcoSphere
  80179. */
  80180. static CreateIcoSphere(options: {
  80181. radius?: number;
  80182. radiusX?: number;
  80183. radiusY?: number;
  80184. radiusZ?: number;
  80185. flat?: boolean;
  80186. subdivisions?: number;
  80187. sideOrientation?: number;
  80188. frontUVs?: Vector4;
  80189. backUVs?: Vector4;
  80190. }): VertexData;
  80191. /**
  80192. * Creates the VertexData for a Polyhedron
  80193. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  80194. * * type provided types are:
  80195. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80196. * * 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)
  80197. * * size the size of the IcoSphere, optional default 1
  80198. * * sizeX allows stretching in the x direction, optional, default size
  80199. * * sizeY allows stretching in the y direction, optional, default size
  80200. * * sizeZ allows stretching in the z direction, optional, default size
  80201. * * 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
  80202. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  80203. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  80204. * * flat when true creates a flat shaded mesh, optional, default true
  80205. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  80206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80207. * * 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)
  80208. * * 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)
  80209. * @returns the VertexData of the Polyhedron
  80210. */
  80211. static CreatePolyhedron(options: {
  80212. type?: number;
  80213. size?: number;
  80214. sizeX?: number;
  80215. sizeY?: number;
  80216. sizeZ?: number;
  80217. custom?: any;
  80218. faceUV?: Vector4[];
  80219. faceColors?: Color4[];
  80220. flat?: boolean;
  80221. sideOrientation?: number;
  80222. frontUVs?: Vector4;
  80223. backUVs?: Vector4;
  80224. }): VertexData;
  80225. /**
  80226. * Creates the VertexData for a TorusKnot
  80227. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  80228. * * radius the radius of the torus knot, optional, default 2
  80229. * * tube the thickness of the tube, optional, default 0.5
  80230. * * radialSegments the number of sides on each tube segments, optional, default 32
  80231. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  80232. * * p the number of windings around the z axis, optional, default 2
  80233. * * q the number of windings around the x axis, optional, default 3
  80234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80235. * * 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)
  80236. * * 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)
  80237. * @returns the VertexData of the Torus Knot
  80238. */
  80239. static CreateTorusKnot(options: {
  80240. radius?: number;
  80241. tube?: number;
  80242. radialSegments?: number;
  80243. tubularSegments?: number;
  80244. p?: number;
  80245. q?: number;
  80246. sideOrientation?: number;
  80247. frontUVs?: Vector4;
  80248. backUVs?: Vector4;
  80249. }): VertexData;
  80250. /**
  80251. * Compute normals for given positions and indices
  80252. * @param positions an array of vertex positions, [...., x, y, z, ......]
  80253. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  80254. * @param normals an array of vertex normals, [...., x, y, z, ......]
  80255. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  80256. * * facetNormals : optional array of facet normals (vector3)
  80257. * * facetPositions : optional array of facet positions (vector3)
  80258. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  80259. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  80260. * * bInfo : optional bounding info, required for facetPartitioning computation
  80261. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  80262. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  80263. * * useRightHandedSystem: optional boolean to for right handed system computation
  80264. * * depthSort : optional boolean to enable the facet depth sort computation
  80265. * * distanceTo : optional Vector3 to compute the facet depth from this location
  80266. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  80267. */
  80268. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  80269. facetNormals?: any;
  80270. facetPositions?: any;
  80271. facetPartitioning?: any;
  80272. ratio?: number;
  80273. bInfo?: any;
  80274. bbSize?: Vector3;
  80275. subDiv?: any;
  80276. useRightHandedSystem?: boolean;
  80277. depthSort?: boolean;
  80278. distanceTo?: Vector3;
  80279. depthSortedFacets?: any;
  80280. }): void;
  80281. /** @hidden */
  80282. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  80283. /**
  80284. * Applies VertexData created from the imported parameters to the geometry
  80285. * @param parsedVertexData the parsed data from an imported file
  80286. * @param geometry the geometry to apply the VertexData to
  80287. */
  80288. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  80289. }
  80290. }
  80291. declare module BABYLON {
  80292. /**
  80293. * Class containing static functions to help procedurally build meshes
  80294. */
  80295. export class DiscBuilder {
  80296. /**
  80297. * Creates a plane polygonal mesh. By default, this is a disc
  80298. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  80299. * * 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
  80300. * * 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
  80301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  80303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80304. * @param name defines the name of the mesh
  80305. * @param options defines the options used to create the mesh
  80306. * @param scene defines the hosting scene
  80307. * @returns the plane polygonal mesh
  80308. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  80309. */
  80310. static CreateDisc(name: string, options: {
  80311. radius?: number;
  80312. tessellation?: number;
  80313. arc?: number;
  80314. updatable?: boolean;
  80315. sideOrientation?: number;
  80316. frontUVs?: Vector4;
  80317. backUVs?: Vector4;
  80318. }, scene?: Nullable<Scene>): Mesh;
  80319. }
  80320. }
  80321. declare module BABYLON {
  80322. /**
  80323. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  80324. *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.
  80325. * The SPS is also a particle system. It provides some methods to manage the particles.
  80326. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  80327. *
  80328. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  80329. */
  80330. export class SolidParticleSystem implements IDisposable {
  80331. /**
  80332. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  80333. * Example : var p = SPS.particles[i];
  80334. */
  80335. particles: SolidParticle[];
  80336. /**
  80337. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  80338. */
  80339. nbParticles: number;
  80340. /**
  80341. * If the particles must ever face the camera (default false). Useful for planar particles.
  80342. */
  80343. billboard: boolean;
  80344. /**
  80345. * Recompute normals when adding a shape
  80346. */
  80347. recomputeNormals: boolean;
  80348. /**
  80349. * This a counter ofr your own usage. It's not set by any SPS functions.
  80350. */
  80351. counter: number;
  80352. /**
  80353. * The SPS name. This name is also given to the underlying mesh.
  80354. */
  80355. name: string;
  80356. /**
  80357. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  80358. */
  80359. mesh: Mesh;
  80360. /**
  80361. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  80362. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  80363. */
  80364. vars: any;
  80365. /**
  80366. * This array is populated when the SPS is set as 'pickable'.
  80367. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  80368. * Each element of this array is an object `{idx: int, faceId: int}`.
  80369. * `idx` is the picked particle index in the `SPS.particles` array
  80370. * `faceId` is the picked face index counted within this particle.
  80371. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  80372. */
  80373. pickedParticles: {
  80374. idx: number;
  80375. faceId: number;
  80376. }[];
  80377. /**
  80378. * This array is populated when `enableDepthSort` is set to true.
  80379. * Each element of this array is an instance of the class DepthSortedParticle.
  80380. */
  80381. depthSortedParticles: DepthSortedParticle[];
  80382. /**
  80383. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  80384. * @hidden
  80385. */
  80386. _bSphereOnly: boolean;
  80387. /**
  80388. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  80389. * @hidden
  80390. */
  80391. _bSphereRadiusFactor: number;
  80392. private _scene;
  80393. private _positions;
  80394. private _indices;
  80395. private _normals;
  80396. private _colors;
  80397. private _uvs;
  80398. private _indices32;
  80399. private _positions32;
  80400. private _normals32;
  80401. private _fixedNormal32;
  80402. private _colors32;
  80403. private _uvs32;
  80404. private _index;
  80405. private _updatable;
  80406. private _pickable;
  80407. private _isVisibilityBoxLocked;
  80408. private _alwaysVisible;
  80409. private _depthSort;
  80410. private _shapeCounter;
  80411. private _copy;
  80412. private _color;
  80413. private _computeParticleColor;
  80414. private _computeParticleTexture;
  80415. private _computeParticleRotation;
  80416. private _computeParticleVertex;
  80417. private _computeBoundingBox;
  80418. private _depthSortParticles;
  80419. private _camera;
  80420. private _mustUnrotateFixedNormals;
  80421. private _particlesIntersect;
  80422. private _needs32Bits;
  80423. /**
  80424. * Creates a SPS (Solid Particle System) object.
  80425. * @param name (String) is the SPS name, this will be the underlying mesh name.
  80426. * @param scene (Scene) is the scene in which the SPS is added.
  80427. * @param options defines the options of the sps e.g.
  80428. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  80429. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  80430. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  80431. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  80432. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  80433. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  80434. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  80435. */
  80436. constructor(name: string, scene: Scene, options?: {
  80437. updatable?: boolean;
  80438. isPickable?: boolean;
  80439. enableDepthSort?: boolean;
  80440. particleIntersection?: boolean;
  80441. boundingSphereOnly?: boolean;
  80442. bSphereRadiusFactor?: number;
  80443. });
  80444. /**
  80445. * Builds the SPS underlying mesh. Returns a standard Mesh.
  80446. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  80447. * @returns the created mesh
  80448. */
  80449. buildMesh(): Mesh;
  80450. /**
  80451. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  80452. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  80453. * Thus the particles generated from `digest()` have their property `position` set yet.
  80454. * @param mesh ( Mesh ) is the mesh to be digested
  80455. * @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
  80456. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  80457. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  80458. * @returns the current SPS
  80459. */
  80460. digest(mesh: Mesh, options?: {
  80461. facetNb?: number;
  80462. number?: number;
  80463. delta?: number;
  80464. }): SolidParticleSystem;
  80465. private _unrotateFixedNormals;
  80466. private _resetCopy;
  80467. private _meshBuilder;
  80468. private _posToShape;
  80469. private _uvsToShapeUV;
  80470. private _addParticle;
  80471. /**
  80472. * Adds some particles to the SPS from the model shape. Returns the shape id.
  80473. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  80474. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  80475. * @param nb (positive integer) the number of particles to be created from this model
  80476. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  80477. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  80478. * @returns the number of shapes in the system
  80479. */
  80480. addShape(mesh: Mesh, nb: number, options?: {
  80481. positionFunction?: any;
  80482. vertexFunction?: any;
  80483. }): number;
  80484. private _rebuildParticle;
  80485. /**
  80486. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  80487. * @returns the SPS.
  80488. */
  80489. rebuildMesh(): SolidParticleSystem;
  80490. /**
  80491. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  80492. * This method calls `updateParticle()` for each particle of the SPS.
  80493. * For an animated SPS, it is usually called within the render loop.
  80494. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  80495. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  80496. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  80497. * @returns the SPS.
  80498. */
  80499. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  80500. /**
  80501. * Disposes the SPS.
  80502. */
  80503. dispose(): void;
  80504. /**
  80505. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  80506. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80507. * @returns the SPS.
  80508. */
  80509. refreshVisibleSize(): SolidParticleSystem;
  80510. /**
  80511. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  80512. * @param size the size (float) of the visibility box
  80513. * note : this doesn't lock the SPS mesh bounding box.
  80514. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80515. */
  80516. setVisibilityBox(size: number): void;
  80517. /**
  80518. * Gets whether the SPS as always visible or not
  80519. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80520. */
  80521. /**
  80522. * Sets the SPS as always visible or not
  80523. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80524. */
  80525. isAlwaysVisible: boolean;
  80526. /**
  80527. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80528. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80529. */
  80530. /**
  80531. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  80532. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  80533. */
  80534. isVisibilityBoxLocked: boolean;
  80535. /**
  80536. * Tells to `setParticles()` to compute the particle rotations or not.
  80537. * Default value : true. The SPS is faster when it's set to false.
  80538. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80539. */
  80540. /**
  80541. * Gets if `setParticles()` computes the particle rotations or not.
  80542. * Default value : true. The SPS is faster when it's set to false.
  80543. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  80544. */
  80545. computeParticleRotation: boolean;
  80546. /**
  80547. * Tells to `setParticles()` to compute the particle colors or not.
  80548. * Default value : true. The SPS is faster when it's set to false.
  80549. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80550. */
  80551. /**
  80552. * Gets if `setParticles()` computes the particle colors or not.
  80553. * Default value : true. The SPS is faster when it's set to false.
  80554. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  80555. */
  80556. computeParticleColor: boolean;
  80557. /**
  80558. * Gets if `setParticles()` computes the particle textures or not.
  80559. * Default value : true. The SPS is faster when it's set to false.
  80560. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  80561. */
  80562. computeParticleTexture: boolean;
  80563. /**
  80564. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  80565. * Default value : false. The SPS is faster when it's set to false.
  80566. * Note : the particle custom vertex positions aren't stored values.
  80567. */
  80568. /**
  80569. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  80570. * Default value : false. The SPS is faster when it's set to false.
  80571. * Note : the particle custom vertex positions aren't stored values.
  80572. */
  80573. computeParticleVertex: boolean;
  80574. /**
  80575. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  80576. */
  80577. /**
  80578. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  80579. */
  80580. computeBoundingBox: boolean;
  80581. /**
  80582. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  80583. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80584. * Default : `true`
  80585. */
  80586. /**
  80587. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  80588. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  80589. * Default : `true`
  80590. */
  80591. depthSortParticles: boolean;
  80592. /**
  80593. * This function does nothing. It may be overwritten to set all the particle first values.
  80594. * The SPS doesn't call this function, you may have to call it by your own.
  80595. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80596. */
  80597. initParticles(): void;
  80598. /**
  80599. * This function does nothing. It may be overwritten to recycle a particle.
  80600. * The SPS doesn't call this function, you may have to call it by your own.
  80601. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80602. * @param particle The particle to recycle
  80603. * @returns the recycled particle
  80604. */
  80605. recycleParticle(particle: SolidParticle): SolidParticle;
  80606. /**
  80607. * Updates a particle : this function should be overwritten by the user.
  80608. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  80609. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  80610. * @example : just set a particle position or velocity and recycle conditions
  80611. * @param particle The particle to update
  80612. * @returns the updated particle
  80613. */
  80614. updateParticle(particle: SolidParticle): SolidParticle;
  80615. /**
  80616. * Updates a vertex of a particle : it can be overwritten by the user.
  80617. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  80618. * @param particle the current particle
  80619. * @param vertex the current index of the current particle
  80620. * @param pt the index of the current vertex in the particle shape
  80621. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  80622. * @example : just set a vertex particle position
  80623. * @returns the updated vertex
  80624. */
  80625. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  80626. /**
  80627. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  80628. * This does nothing and may be overwritten by the user.
  80629. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80630. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80631. * @param update the boolean update value actually passed to setParticles()
  80632. */
  80633. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80634. /**
  80635. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  80636. * This will be passed three parameters.
  80637. * This does nothing and may be overwritten by the user.
  80638. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80639. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  80640. * @param update the boolean update value actually passed to setParticles()
  80641. */
  80642. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  80643. }
  80644. }
  80645. declare module BABYLON {
  80646. /**
  80647. * Represents one particle of a solid particle system.
  80648. */
  80649. export class SolidParticle {
  80650. /**
  80651. * particle global index
  80652. */
  80653. idx: number;
  80654. /**
  80655. * The color of the particle
  80656. */
  80657. color: Nullable<Color4>;
  80658. /**
  80659. * The world space position of the particle.
  80660. */
  80661. position: Vector3;
  80662. /**
  80663. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  80664. */
  80665. rotation: Vector3;
  80666. /**
  80667. * The world space rotation quaternion of the particle.
  80668. */
  80669. rotationQuaternion: Nullable<Quaternion>;
  80670. /**
  80671. * The scaling of the particle.
  80672. */
  80673. scaling: Vector3;
  80674. /**
  80675. * The uvs of the particle.
  80676. */
  80677. uvs: Vector4;
  80678. /**
  80679. * The current speed of the particle.
  80680. */
  80681. velocity: Vector3;
  80682. /**
  80683. * The pivot point in the particle local space.
  80684. */
  80685. pivot: Vector3;
  80686. /**
  80687. * Must the particle be translated from its pivot point in its local space ?
  80688. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  80689. * Default : false
  80690. */
  80691. translateFromPivot: boolean;
  80692. /**
  80693. * Is the particle active or not ?
  80694. */
  80695. alive: boolean;
  80696. /**
  80697. * Is the particle visible or not ?
  80698. */
  80699. isVisible: boolean;
  80700. /**
  80701. * Index of this particle in the global "positions" array (Internal use)
  80702. * @hidden
  80703. */
  80704. _pos: number;
  80705. /**
  80706. * @hidden Index of this particle in the global "indices" array (Internal use)
  80707. */
  80708. _ind: number;
  80709. /**
  80710. * @hidden ModelShape of this particle (Internal use)
  80711. */
  80712. _model: ModelShape;
  80713. /**
  80714. * ModelShape id of this particle
  80715. */
  80716. shapeId: number;
  80717. /**
  80718. * Index of the particle in its shape id (Internal use)
  80719. */
  80720. idxInShape: number;
  80721. /**
  80722. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  80723. */
  80724. _modelBoundingInfo: BoundingInfo;
  80725. /**
  80726. * @hidden Particle BoundingInfo object (Internal use)
  80727. */
  80728. _boundingInfo: BoundingInfo;
  80729. /**
  80730. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  80731. */
  80732. _sps: SolidParticleSystem;
  80733. /**
  80734. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  80735. */
  80736. _stillInvisible: boolean;
  80737. /**
  80738. * @hidden Last computed particle rotation matrix
  80739. */
  80740. _rotationMatrix: number[];
  80741. /**
  80742. * Parent particle Id, if any.
  80743. * Default null.
  80744. */
  80745. parentId: Nullable<number>;
  80746. /**
  80747. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  80748. * The possible values are :
  80749. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80750. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80751. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80752. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80753. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80754. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  80755. * */
  80756. cullingStrategy: number;
  80757. /**
  80758. * @hidden Internal global position in the SPS.
  80759. */
  80760. _globalPosition: Vector3;
  80761. /**
  80762. * Creates a Solid Particle object.
  80763. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  80764. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  80765. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  80766. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  80767. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  80768. * @param shapeId (integer) is the model shape identifier in the SPS.
  80769. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  80770. * @param sps defines the sps it is associated to
  80771. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  80772. */
  80773. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  80774. /**
  80775. * Legacy support, changed scale to scaling
  80776. */
  80777. /**
  80778. * Legacy support, changed scale to scaling
  80779. */
  80780. scale: Vector3;
  80781. /**
  80782. * Legacy support, changed quaternion to rotationQuaternion
  80783. */
  80784. /**
  80785. * Legacy support, changed quaternion to rotationQuaternion
  80786. */
  80787. quaternion: Nullable<Quaternion>;
  80788. /**
  80789. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  80790. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  80791. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  80792. * @returns true if it intersects
  80793. */
  80794. intersectsMesh(target: Mesh | SolidParticle): boolean;
  80795. /**
  80796. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  80797. * A particle is in the frustum if its bounding box intersects the frustum
  80798. * @param frustumPlanes defines the frustum to test
  80799. * @returns true if the particle is in the frustum planes
  80800. */
  80801. isInFrustum(frustumPlanes: Plane[]): boolean;
  80802. /**
  80803. * get the rotation matrix of the particle
  80804. * @hidden
  80805. */
  80806. getRotationMatrix(m: Matrix): void;
  80807. }
  80808. /**
  80809. * Represents the shape of the model used by one particle of a solid particle system.
  80810. * SPS internal tool, don't use it manually.
  80811. */
  80812. export class ModelShape {
  80813. /**
  80814. * The shape id
  80815. * @hidden
  80816. */
  80817. shapeID: number;
  80818. /**
  80819. * flat array of model positions (internal use)
  80820. * @hidden
  80821. */
  80822. _shape: Vector3[];
  80823. /**
  80824. * flat array of model UVs (internal use)
  80825. * @hidden
  80826. */
  80827. _shapeUV: number[];
  80828. /**
  80829. * length of the shape in the model indices array (internal use)
  80830. * @hidden
  80831. */
  80832. _indicesLength: number;
  80833. /**
  80834. * Custom position function (internal use)
  80835. * @hidden
  80836. */
  80837. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  80838. /**
  80839. * Custom vertex function (internal use)
  80840. * @hidden
  80841. */
  80842. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  80843. /**
  80844. * 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.
  80845. * SPS internal tool, don't use it manually.
  80846. * @hidden
  80847. */
  80848. 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>);
  80849. }
  80850. /**
  80851. * Represents a Depth Sorted Particle in the solid particle system.
  80852. */
  80853. export class DepthSortedParticle {
  80854. /**
  80855. * Index of the particle in the "indices" array
  80856. */
  80857. ind: number;
  80858. /**
  80859. * Length of the particle shape in the "indices" array
  80860. */
  80861. indicesLength: number;
  80862. /**
  80863. * Squared distance from the particle to the camera
  80864. */
  80865. sqDistance: number;
  80866. }
  80867. }
  80868. declare module BABYLON {
  80869. /**
  80870. * Class used to store all common mesh properties
  80871. */
  80872. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  80873. /** No occlusion */
  80874. static OCCLUSION_TYPE_NONE: number;
  80875. /** Occlusion set to optimisitic */
  80876. static OCCLUSION_TYPE_OPTIMISTIC: number;
  80877. /** Occlusion set to strict */
  80878. static OCCLUSION_TYPE_STRICT: number;
  80879. /** Use an accurante occlusion algorithm */
  80880. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  80881. /** Use a conservative occlusion algorithm */
  80882. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  80883. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80884. * Test order :
  80885. * Is the bounding sphere outside the frustum ?
  80886. * If not, are the bounding box vertices outside the frustum ?
  80887. * It not, then the cullable object is in the frustum.
  80888. */
  80889. static readonly CULLINGSTRATEGY_STANDARD: number;
  80890. /** Culling strategy : Bounding Sphere Only.
  80891. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80892. * It's also less accurate than the standard because some not visible objects can still be selected.
  80893. * Test : is the bounding sphere outside the frustum ?
  80894. * If not, then the cullable object is in the frustum.
  80895. */
  80896. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80897. /** Culling strategy : Optimistic Inclusion.
  80898. * This in an inclusion test first, then the standard exclusion test.
  80899. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80900. * 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.
  80901. * Anyway, it's as accurate as the standard strategy.
  80902. * Test :
  80903. * Is the cullable object bounding sphere center in the frustum ?
  80904. * If not, apply the default culling strategy.
  80905. */
  80906. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80907. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80908. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80909. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80910. * 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.
  80911. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80912. * Test :
  80913. * Is the cullable object bounding sphere center in the frustum ?
  80914. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80915. */
  80916. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80917. /**
  80918. * No billboard
  80919. */
  80920. static readonly BILLBOARDMODE_NONE: number;
  80921. /** Billboard on X axis */
  80922. static readonly BILLBOARDMODE_X: number;
  80923. /** Billboard on Y axis */
  80924. static readonly BILLBOARDMODE_Y: number;
  80925. /** Billboard on Z axis */
  80926. static readonly BILLBOARDMODE_Z: number;
  80927. /** Billboard on all axes */
  80928. static readonly BILLBOARDMODE_ALL: number;
  80929. private _facetData;
  80930. /**
  80931. * The culling strategy to use to check whether the mesh must be rendered or not.
  80932. * This value can be changed at any time and will be used on the next render mesh selection.
  80933. * The possible values are :
  80934. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  80935. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  80936. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  80937. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  80938. * Please read each static variable documentation to get details about the culling process.
  80939. * */
  80940. cullingStrategy: number;
  80941. /**
  80942. * Gets the number of facets in the mesh
  80943. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80944. */
  80945. readonly facetNb: number;
  80946. /**
  80947. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  80948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80949. */
  80950. partitioningSubdivisions: number;
  80951. /**
  80952. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  80953. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  80954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  80955. */
  80956. partitioningBBoxRatio: number;
  80957. /**
  80958. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  80959. * Works only for updatable meshes.
  80960. * Doesn't work with multi-materials
  80961. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80962. */
  80963. mustDepthSortFacets: boolean;
  80964. /**
  80965. * The location (Vector3) where the facet depth sort must be computed from.
  80966. * By default, the active camera position.
  80967. * Used only when facet depth sort is enabled
  80968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  80969. */
  80970. facetDepthSortFrom: Vector3;
  80971. /**
  80972. * gets a boolean indicating if facetData is enabled
  80973. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  80974. */
  80975. readonly isFacetDataEnabled: boolean;
  80976. /** @hidden */
  80977. _updateNonUniformScalingState(value: boolean): boolean;
  80978. /**
  80979. * An event triggered when this mesh collides with another one
  80980. */
  80981. onCollideObservable: Observable<AbstractMesh>;
  80982. private _onCollideObserver;
  80983. /** Set a function to call when this mesh collides with another one */
  80984. onCollide: () => void;
  80985. /**
  80986. * An event triggered when the collision's position changes
  80987. */
  80988. onCollisionPositionChangeObservable: Observable<Vector3>;
  80989. private _onCollisionPositionChangeObserver;
  80990. /** Set a function to call when the collision's position changes */
  80991. onCollisionPositionChange: () => void;
  80992. /**
  80993. * An event triggered when material is changed
  80994. */
  80995. onMaterialChangedObservable: Observable<AbstractMesh>;
  80996. /**
  80997. * Gets or sets the orientation for POV movement & rotation
  80998. */
  80999. definedFacingForward: boolean;
  81000. /** @hidden */
  81001. _occlusionQuery: Nullable<WebGLQuery>;
  81002. private _visibility;
  81003. /**
  81004. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81005. */
  81006. /**
  81007. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  81008. */
  81009. visibility: number;
  81010. /** Gets or sets the alpha index used to sort transparent meshes
  81011. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81012. */
  81013. alphaIndex: number;
  81014. /**
  81015. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81016. */
  81017. isVisible: boolean;
  81018. /**
  81019. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81020. */
  81021. isPickable: boolean;
  81022. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81023. showSubMeshesBoundingBox: boolean;
  81024. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81025. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81026. */
  81027. isBlocker: boolean;
  81028. /**
  81029. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81030. */
  81031. enablePointerMoveEvents: boolean;
  81032. /**
  81033. * Specifies the rendering group id for this mesh (0 by default)
  81034. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81035. */
  81036. renderingGroupId: number;
  81037. private _material;
  81038. /** Gets or sets current material */
  81039. material: Nullable<Material>;
  81040. private _receiveShadows;
  81041. /**
  81042. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  81043. * @see http://doc.babylonjs.com/babylon101/shadows
  81044. */
  81045. receiveShadows: boolean;
  81046. /** Defines color to use when rendering outline */
  81047. outlineColor: Color3;
  81048. /** Define width to use when rendering outline */
  81049. outlineWidth: number;
  81050. /** Defines color to use when rendering overlay */
  81051. overlayColor: Color3;
  81052. /** Defines alpha to use when rendering overlay */
  81053. overlayAlpha: number;
  81054. private _hasVertexAlpha;
  81055. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  81056. hasVertexAlpha: boolean;
  81057. private _useVertexColors;
  81058. /** 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) */
  81059. useVertexColors: boolean;
  81060. private _computeBonesUsingShaders;
  81061. /**
  81062. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  81063. */
  81064. computeBonesUsingShaders: boolean;
  81065. private _numBoneInfluencers;
  81066. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  81067. numBoneInfluencers: number;
  81068. private _applyFog;
  81069. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  81070. applyFog: boolean;
  81071. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81072. useOctreeForRenderingSelection: boolean;
  81073. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81074. useOctreeForPicking: boolean;
  81075. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81076. useOctreeForCollisions: boolean;
  81077. private _layerMask;
  81078. /**
  81079. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  81080. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  81081. */
  81082. layerMask: number;
  81083. /**
  81084. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81085. */
  81086. alwaysSelectAsActiveMesh: boolean;
  81087. /**
  81088. * Gets or sets the current action manager
  81089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81090. */
  81091. actionManager: Nullable<AbstractActionManager>;
  81092. private _checkCollisions;
  81093. private _collisionMask;
  81094. private _collisionGroup;
  81095. /**
  81096. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81097. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81098. */
  81099. ellipsoid: Vector3;
  81100. /**
  81101. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81102. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81103. */
  81104. ellipsoidOffset: Vector3;
  81105. private _collider;
  81106. private _oldPositionForCollisions;
  81107. private _diffPositionForCollisions;
  81108. /**
  81109. * Gets or sets a collision mask used to mask collisions (default is -1).
  81110. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81111. */
  81112. collisionMask: number;
  81113. /**
  81114. * Gets or sets the current collision group mask (-1 by default).
  81115. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  81116. */
  81117. collisionGroup: number;
  81118. /**
  81119. * Defines edge width used when edgesRenderer is enabled
  81120. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81121. */
  81122. edgesWidth: number;
  81123. /**
  81124. * Defines edge color used when edgesRenderer is enabled
  81125. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81126. */
  81127. edgesColor: Color4;
  81128. /** @hidden */
  81129. _edgesRenderer: Nullable<IEdgesRenderer>;
  81130. /** @hidden */
  81131. _masterMesh: Nullable<AbstractMesh>;
  81132. /** @hidden */
  81133. _boundingInfo: Nullable<BoundingInfo>;
  81134. /** @hidden */
  81135. _renderId: number;
  81136. /**
  81137. * Gets or sets the list of subMeshes
  81138. * @see http://doc.babylonjs.com/how_to/multi_materials
  81139. */
  81140. subMeshes: SubMesh[];
  81141. /** @hidden */
  81142. _intersectionsInProgress: AbstractMesh[];
  81143. /** @hidden */
  81144. _unIndexed: boolean;
  81145. /** @hidden */
  81146. _lightSources: Light[];
  81147. /** @hidden */
  81148. readonly _positions: Nullable<Vector3[]>;
  81149. /** @hidden */
  81150. _waitingActions: any;
  81151. /** @hidden */
  81152. _waitingFreezeWorldMatrix: Nullable<boolean>;
  81153. private _skeleton;
  81154. /** @hidden */
  81155. _bonesTransformMatrices: Nullable<Float32Array>;
  81156. /**
  81157. * Gets or sets a skeleton to apply skining transformations
  81158. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81159. */
  81160. skeleton: Nullable<Skeleton>;
  81161. /**
  81162. * An event triggered when the mesh is rebuilt.
  81163. */
  81164. onRebuildObservable: Observable<AbstractMesh>;
  81165. /**
  81166. * Creates a new AbstractMesh
  81167. * @param name defines the name of the mesh
  81168. * @param scene defines the hosting scene
  81169. */
  81170. constructor(name: string, scene?: Nullable<Scene>);
  81171. /**
  81172. * Returns the string "AbstractMesh"
  81173. * @returns "AbstractMesh"
  81174. */
  81175. getClassName(): string;
  81176. /**
  81177. * Gets a string representation of the current mesh
  81178. * @param fullDetails defines a boolean indicating if full details must be included
  81179. * @returns a string representation of the current mesh
  81180. */
  81181. toString(fullDetails?: boolean): string;
  81182. /** @hidden */
  81183. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81184. /** @hidden */
  81185. _rebuild(): void;
  81186. /** @hidden */
  81187. _resyncLightSources(): void;
  81188. /** @hidden */
  81189. _resyncLighSource(light: Light): void;
  81190. /** @hidden */
  81191. _unBindEffect(): void;
  81192. /** @hidden */
  81193. _removeLightSource(light: Light): void;
  81194. private _markSubMeshesAsDirty;
  81195. /** @hidden */
  81196. _markSubMeshesAsLightDirty(): void;
  81197. /** @hidden */
  81198. _markSubMeshesAsAttributesDirty(): void;
  81199. /** @hidden */
  81200. _markSubMeshesAsMiscDirty(): void;
  81201. /**
  81202. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  81203. */
  81204. scaling: Vector3;
  81205. /**
  81206. * Returns true if the mesh is blocked. Implemented by child classes
  81207. */
  81208. readonly isBlocked: boolean;
  81209. /**
  81210. * Returns the mesh itself by default. Implemented by child classes
  81211. * @param camera defines the camera to use to pick the right LOD level
  81212. * @returns the currentAbstractMesh
  81213. */
  81214. getLOD(camera: Camera): Nullable<AbstractMesh>;
  81215. /**
  81216. * Returns 0 by default. Implemented by child classes
  81217. * @returns an integer
  81218. */
  81219. getTotalVertices(): number;
  81220. /**
  81221. * Returns a positive integer : the total number of indices in this mesh geometry.
  81222. * @returns the numner of indices or zero if the mesh has no geometry.
  81223. */
  81224. getTotalIndices(): number;
  81225. /**
  81226. * Returns null by default. Implemented by child classes
  81227. * @returns null
  81228. */
  81229. getIndices(): Nullable<IndicesArray>;
  81230. /**
  81231. * Returns the array of the requested vertex data kind. Implemented by child classes
  81232. * @param kind defines the vertex data kind to use
  81233. * @returns null
  81234. */
  81235. getVerticesData(kind: string): Nullable<FloatArray>;
  81236. /**
  81237. * Sets the vertex data of the mesh geometry for the requested `kind`.
  81238. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  81239. * Note that a new underlying VertexBuffer object is created each call.
  81240. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  81241. * @param kind defines vertex data kind:
  81242. * * VertexBuffer.PositionKind
  81243. * * VertexBuffer.UVKind
  81244. * * VertexBuffer.UV2Kind
  81245. * * VertexBuffer.UV3Kind
  81246. * * VertexBuffer.UV4Kind
  81247. * * VertexBuffer.UV5Kind
  81248. * * VertexBuffer.UV6Kind
  81249. * * VertexBuffer.ColorKind
  81250. * * VertexBuffer.MatricesIndicesKind
  81251. * * VertexBuffer.MatricesIndicesExtraKind
  81252. * * VertexBuffer.MatricesWeightsKind
  81253. * * VertexBuffer.MatricesWeightsExtraKind
  81254. * @param data defines the data source
  81255. * @param updatable defines if the data must be flagged as updatable (or static)
  81256. * @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
  81257. * @returns the current mesh
  81258. */
  81259. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  81260. /**
  81261. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  81262. * If the mesh has no geometry, it is simply returned as it is.
  81263. * @param kind defines vertex data kind:
  81264. * * VertexBuffer.PositionKind
  81265. * * VertexBuffer.UVKind
  81266. * * VertexBuffer.UV2Kind
  81267. * * VertexBuffer.UV3Kind
  81268. * * VertexBuffer.UV4Kind
  81269. * * VertexBuffer.UV5Kind
  81270. * * VertexBuffer.UV6Kind
  81271. * * VertexBuffer.ColorKind
  81272. * * VertexBuffer.MatricesIndicesKind
  81273. * * VertexBuffer.MatricesIndicesExtraKind
  81274. * * VertexBuffer.MatricesWeightsKind
  81275. * * VertexBuffer.MatricesWeightsExtraKind
  81276. * @param data defines the data source
  81277. * @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
  81278. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  81279. * @returns the current mesh
  81280. */
  81281. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  81282. /**
  81283. * Sets the mesh indices,
  81284. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  81285. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  81286. * @param totalVertices Defines the total number of vertices
  81287. * @returns the current mesh
  81288. */
  81289. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  81290. /**
  81291. * Gets a boolean indicating if specific vertex data is present
  81292. * @param kind defines the vertex data kind to use
  81293. * @returns true is data kind is present
  81294. */
  81295. isVerticesDataPresent(kind: string): boolean;
  81296. /**
  81297. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  81298. * @returns a BoundingInfo
  81299. */
  81300. getBoundingInfo(): BoundingInfo;
  81301. /**
  81302. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81303. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  81304. * @returns the current mesh
  81305. */
  81306. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  81307. /**
  81308. * Overwrite the current bounding info
  81309. * @param boundingInfo defines the new bounding info
  81310. * @returns the current mesh
  81311. */
  81312. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  81313. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  81314. readonly useBones: boolean;
  81315. /** @hidden */
  81316. _preActivate(): void;
  81317. /** @hidden */
  81318. _preActivateForIntermediateRendering(renderId: number): void;
  81319. /** @hidden */
  81320. _activate(renderId: number): void;
  81321. /**
  81322. * Gets the current world matrix
  81323. * @returns a Matrix
  81324. */
  81325. getWorldMatrix(): Matrix;
  81326. /** @hidden */
  81327. _getWorldMatrixDeterminant(): number;
  81328. /**
  81329. * Perform relative position change from the point of view of behind the front of the mesh.
  81330. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81331. * Supports definition of mesh facing forward or backward
  81332. * @param amountRight defines the distance on the right axis
  81333. * @param amountUp defines the distance on the up axis
  81334. * @param amountForward defines the distance on the forward axis
  81335. * @returns the current mesh
  81336. */
  81337. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  81338. /**
  81339. * Calculate relative position change from the point of view of behind the front of the mesh.
  81340. * This is performed taking into account the meshes current rotation, so you do not have to care.
  81341. * Supports definition of mesh facing forward or backward
  81342. * @param amountRight defines the distance on the right axis
  81343. * @param amountUp defines the distance on the up axis
  81344. * @param amountForward defines the distance on the forward axis
  81345. * @returns the new displacement vector
  81346. */
  81347. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  81348. /**
  81349. * Perform relative rotation change from the point of view of behind the front of the mesh.
  81350. * Supports definition of mesh facing forward or backward
  81351. * @param flipBack defines the flip
  81352. * @param twirlClockwise defines the twirl
  81353. * @param tiltRight defines the tilt
  81354. * @returns the current mesh
  81355. */
  81356. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  81357. /**
  81358. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  81359. * Supports definition of mesh facing forward or backward.
  81360. * @param flipBack defines the flip
  81361. * @param twirlClockwise defines the twirl
  81362. * @param tiltRight defines the tilt
  81363. * @returns the new rotation vector
  81364. */
  81365. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  81366. /**
  81367. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  81368. * @param includeDescendants Include bounding info from descendants as well (true by default)
  81369. * @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
  81370. * @returns the new bounding vectors
  81371. */
  81372. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  81373. min: Vector3;
  81374. max: Vector3;
  81375. };
  81376. /**
  81377. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  81378. * This means the mesh underlying bounding box and sphere are recomputed.
  81379. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  81380. * @returns the current mesh
  81381. */
  81382. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  81383. /** @hidden */
  81384. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  81385. /** @hidden */
  81386. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  81387. /** @hidden */
  81388. _updateBoundingInfo(): AbstractMesh;
  81389. /** @hidden */
  81390. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  81391. /** @hidden */
  81392. protected _afterComputeWorldMatrix(): void;
  81393. /**
  81394. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  81395. * A mesh is in the frustum if its bounding box intersects the frustum
  81396. * @param frustumPlanes defines the frustum to test
  81397. * @returns true if the mesh is in the frustum planes
  81398. */
  81399. isInFrustum(frustumPlanes: Plane[]): boolean;
  81400. /**
  81401. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  81402. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  81403. * @param frustumPlanes defines the frustum to test
  81404. * @returns true if the mesh is completely in the frustum planes
  81405. */
  81406. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81407. /**
  81408. * True if the mesh intersects another mesh or a SolidParticle object
  81409. * @param mesh defines a target mesh or SolidParticle to test
  81410. * @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)
  81411. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  81412. * @returns true if there is an intersection
  81413. */
  81414. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  81415. /**
  81416. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  81417. * @param point defines the point to test
  81418. * @returns true if there is an intersection
  81419. */
  81420. intersectsPoint(point: Vector3): boolean;
  81421. /**
  81422. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  81423. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81424. */
  81425. checkCollisions: boolean;
  81426. /**
  81427. * Gets Collider object used to compute collisions (not physics)
  81428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81429. */
  81430. readonly collider: Collider;
  81431. /**
  81432. * Move the mesh using collision engine
  81433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81434. * @param displacement defines the requested displacement vector
  81435. * @returns the current mesh
  81436. */
  81437. moveWithCollisions(displacement: Vector3): AbstractMesh;
  81438. private _onCollisionPositionChange;
  81439. /** @hidden */
  81440. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  81441. /** @hidden */
  81442. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  81443. /** @hidden */
  81444. _checkCollision(collider: Collider): AbstractMesh;
  81445. /** @hidden */
  81446. _generatePointsArray(): boolean;
  81447. /**
  81448. * Checks if the passed Ray intersects with the mesh
  81449. * @param ray defines the ray to use
  81450. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  81451. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81452. * @returns the picking info
  81453. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81454. */
  81455. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  81456. /**
  81457. * Clones the current mesh
  81458. * @param name defines the mesh name
  81459. * @param newParent defines the new mesh parent
  81460. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  81461. * @returns the new mesh
  81462. */
  81463. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  81464. /**
  81465. * Disposes all the submeshes of the current meshnp
  81466. * @returns the current mesh
  81467. */
  81468. releaseSubMeshes(): AbstractMesh;
  81469. /**
  81470. * Releases resources associated with this abstract mesh.
  81471. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81472. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81473. */
  81474. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81475. /**
  81476. * Adds the passed mesh as a child to the current mesh
  81477. * @param mesh defines the child mesh
  81478. * @returns the current mesh
  81479. */
  81480. addChild(mesh: AbstractMesh): AbstractMesh;
  81481. /**
  81482. * Removes the passed mesh from the current mesh children list
  81483. * @param mesh defines the child mesh
  81484. * @returns the current mesh
  81485. */
  81486. removeChild(mesh: AbstractMesh): AbstractMesh;
  81487. /** @hidden */
  81488. private _initFacetData;
  81489. /**
  81490. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  81491. * This method can be called within the render loop.
  81492. * 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
  81493. * @returns the current mesh
  81494. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81495. */
  81496. updateFacetData(): AbstractMesh;
  81497. /**
  81498. * Returns the facetLocalNormals array.
  81499. * The normals are expressed in the mesh local spac
  81500. * @returns an array of Vector3
  81501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81502. */
  81503. getFacetLocalNormals(): Vector3[];
  81504. /**
  81505. * Returns the facetLocalPositions array.
  81506. * The facet positions are expressed in the mesh local space
  81507. * @returns an array of Vector3
  81508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81509. */
  81510. getFacetLocalPositions(): Vector3[];
  81511. /**
  81512. * Returns the facetLocalPartioning array
  81513. * @returns an array of array of numbers
  81514. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81515. */
  81516. getFacetLocalPartitioning(): number[][];
  81517. /**
  81518. * Returns the i-th facet position in the world system.
  81519. * This method allocates a new Vector3 per call
  81520. * @param i defines the facet index
  81521. * @returns a new Vector3
  81522. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81523. */
  81524. getFacetPosition(i: number): Vector3;
  81525. /**
  81526. * Sets the reference Vector3 with the i-th facet position in the world system
  81527. * @param i defines the facet index
  81528. * @param ref defines the target vector
  81529. * @returns the current mesh
  81530. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81531. */
  81532. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  81533. /**
  81534. * Returns the i-th facet normal in the world system.
  81535. * This method allocates a new Vector3 per call
  81536. * @param i defines the facet index
  81537. * @returns a new Vector3
  81538. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81539. */
  81540. getFacetNormal(i: number): Vector3;
  81541. /**
  81542. * Sets the reference Vector3 with the i-th facet normal in the world system
  81543. * @param i defines the facet index
  81544. * @param ref defines the target vector
  81545. * @returns the current mesh
  81546. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81547. */
  81548. getFacetNormalToRef(i: number, ref: Vector3): this;
  81549. /**
  81550. * 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)
  81551. * @param x defines x coordinate
  81552. * @param y defines y coordinate
  81553. * @param z defines z coordinate
  81554. * @returns the array of facet indexes
  81555. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81556. */
  81557. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  81558. /**
  81559. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  81560. * @param projected sets as the (x,y,z) world projection on the facet
  81561. * @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
  81562. * @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
  81563. * @param x defines x coordinate
  81564. * @param y defines y coordinate
  81565. * @param z defines z coordinate
  81566. * @returns the face index if found (or null instead)
  81567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81568. */
  81569. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81570. /**
  81571. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  81572. * @param projected sets as the (x,y,z) local projection on the facet
  81573. * @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
  81574. * @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
  81575. * @param x defines x coordinate
  81576. * @param y defines y coordinate
  81577. * @param z defines z coordinate
  81578. * @returns the face index if found (or null instead)
  81579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81580. */
  81581. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  81582. /**
  81583. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  81584. * @returns the parameters
  81585. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81586. */
  81587. getFacetDataParameters(): any;
  81588. /**
  81589. * Disables the feature FacetData and frees the related memory
  81590. * @returns the current mesh
  81591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  81592. */
  81593. disableFacetData(): AbstractMesh;
  81594. /**
  81595. * Updates the AbstractMesh indices array
  81596. * @param indices defines the data source
  81597. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  81598. * @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)
  81599. * @returns the current mesh
  81600. */
  81601. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  81602. /**
  81603. * Creates new normals data for the mesh
  81604. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  81605. * @returns the current mesh
  81606. */
  81607. createNormals(updatable: boolean): AbstractMesh;
  81608. /**
  81609. * Align the mesh with a normal
  81610. * @param normal defines the normal to use
  81611. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  81612. * @returns the current mesh
  81613. */
  81614. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  81615. /** @hidden */
  81616. _checkOcclusionQuery(): boolean;
  81617. }
  81618. }
  81619. declare module BABYLON {
  81620. /**
  81621. * Interface used to define ActionEvent
  81622. */
  81623. export interface IActionEvent {
  81624. /** The mesh or sprite that triggered the action */
  81625. source: any;
  81626. /** The X mouse cursor position at the time of the event */
  81627. pointerX: number;
  81628. /** The Y mouse cursor position at the time of the event */
  81629. pointerY: number;
  81630. /** The mesh that is currently pointed at (can be null) */
  81631. meshUnderPointer: Nullable<AbstractMesh>;
  81632. /** the original (browser) event that triggered the ActionEvent */
  81633. sourceEvent?: any;
  81634. /** additional data for the event */
  81635. additionalData?: any;
  81636. }
  81637. /**
  81638. * ActionEvent is the event being sent when an action is triggered.
  81639. */
  81640. export class ActionEvent implements IActionEvent {
  81641. /** The mesh or sprite that triggered the action */
  81642. source: any;
  81643. /** The X mouse cursor position at the time of the event */
  81644. pointerX: number;
  81645. /** The Y mouse cursor position at the time of the event */
  81646. pointerY: number;
  81647. /** The mesh that is currently pointed at (can be null) */
  81648. meshUnderPointer: Nullable<AbstractMesh>;
  81649. /** the original (browser) event that triggered the ActionEvent */
  81650. sourceEvent?: any;
  81651. /** additional data for the event */
  81652. additionalData?: any;
  81653. /**
  81654. * Creates a new ActionEvent
  81655. * @param source The mesh or sprite that triggered the action
  81656. * @param pointerX The X mouse cursor position at the time of the event
  81657. * @param pointerY The Y mouse cursor position at the time of the event
  81658. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  81659. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  81660. * @param additionalData additional data for the event
  81661. */
  81662. constructor(
  81663. /** The mesh or sprite that triggered the action */
  81664. source: any,
  81665. /** The X mouse cursor position at the time of the event */
  81666. pointerX: number,
  81667. /** The Y mouse cursor position at the time of the event */
  81668. pointerY: number,
  81669. /** The mesh that is currently pointed at (can be null) */
  81670. meshUnderPointer: Nullable<AbstractMesh>,
  81671. /** the original (browser) event that triggered the ActionEvent */
  81672. sourceEvent?: any,
  81673. /** additional data for the event */
  81674. additionalData?: any);
  81675. /**
  81676. * Helper function to auto-create an ActionEvent from a source mesh.
  81677. * @param source The source mesh that triggered the event
  81678. * @param evt The original (browser) event
  81679. * @param additionalData additional data for the event
  81680. * @returns the new ActionEvent
  81681. */
  81682. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  81683. /**
  81684. * Helper function to auto-create an ActionEvent from a source sprite
  81685. * @param source The source sprite that triggered the event
  81686. * @param scene Scene associated with the sprite
  81687. * @param evt The original (browser) event
  81688. * @param additionalData additional data for the event
  81689. * @returns the new ActionEvent
  81690. */
  81691. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  81692. /**
  81693. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  81694. * @param scene the scene where the event occurred
  81695. * @param evt The original (browser) event
  81696. * @returns the new ActionEvent
  81697. */
  81698. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  81699. /**
  81700. * Helper function to auto-create an ActionEvent from a primitive
  81701. * @param prim defines the target primitive
  81702. * @param pointerPos defines the pointer position
  81703. * @param evt The original (browser) event
  81704. * @param additionalData additional data for the event
  81705. * @returns the new ActionEvent
  81706. */
  81707. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  81708. }
  81709. }
  81710. declare module BABYLON {
  81711. /**
  81712. * Abstract class used to decouple action Manager from scene and meshes.
  81713. * Do not instantiate.
  81714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81715. */
  81716. export abstract class AbstractActionManager implements IDisposable {
  81717. /** Gets the list of active triggers */
  81718. static Triggers: {
  81719. [key: string]: number;
  81720. };
  81721. /** Gets the cursor to use when hovering items */
  81722. hoverCursor: string;
  81723. /** Gets the list of actions */
  81724. actions: IAction[];
  81725. /**
  81726. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  81727. */
  81728. isRecursive: boolean;
  81729. /**
  81730. * Releases all associated resources
  81731. */
  81732. abstract dispose(): void;
  81733. /**
  81734. * Does this action manager has pointer triggers
  81735. */
  81736. abstract readonly hasPointerTriggers: boolean;
  81737. /**
  81738. * Does this action manager has pick triggers
  81739. */
  81740. abstract readonly hasPickTriggers: boolean;
  81741. /**
  81742. * Process a specific trigger
  81743. * @param trigger defines the trigger to process
  81744. * @param evt defines the event details to be processed
  81745. */
  81746. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  81747. /**
  81748. * Does this action manager handles actions of any of the given triggers
  81749. * @param triggers defines the triggers to be tested
  81750. * @return a boolean indicating whether one (or more) of the triggers is handled
  81751. */
  81752. abstract hasSpecificTriggers(triggers: number[]): boolean;
  81753. /**
  81754. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81755. * speed.
  81756. * @param triggerA defines the trigger to be tested
  81757. * @param triggerB defines the trigger to be tested
  81758. * @return a boolean indicating whether one (or more) of the triggers is handled
  81759. */
  81760. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81761. /**
  81762. * Does this action manager handles actions of a given trigger
  81763. * @param trigger defines the trigger to be tested
  81764. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81765. * @return whether the trigger is handled
  81766. */
  81767. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81768. /**
  81769. * Serialize this manager to a JSON object
  81770. * @param name defines the property name to store this manager
  81771. * @returns a JSON representation of this manager
  81772. */
  81773. abstract serialize(name: string): any;
  81774. /**
  81775. * Registers an action to this action manager
  81776. * @param action defines the action to be registered
  81777. * @return the action amended (prepared) after registration
  81778. */
  81779. abstract registerAction(action: IAction): Nullable<IAction>;
  81780. /**
  81781. * Unregisters an action to this action manager
  81782. * @param action defines the action to be unregistered
  81783. * @return a boolean indicating whether the action has been unregistered
  81784. */
  81785. abstract unregisterAction(action: IAction): Boolean;
  81786. /**
  81787. * Does exist one action manager with at least one trigger
  81788. **/
  81789. static readonly HasTriggers: boolean;
  81790. /**
  81791. * Does exist one action manager with at least one pick trigger
  81792. **/
  81793. static readonly HasPickTriggers: boolean;
  81794. /**
  81795. * Does exist one action manager that handles actions of a given trigger
  81796. * @param trigger defines the trigger to be tested
  81797. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  81798. **/
  81799. static HasSpecificTrigger(trigger: number): boolean;
  81800. }
  81801. }
  81802. declare module BABYLON {
  81803. /**
  81804. * Defines how a node can be built from a string name.
  81805. */
  81806. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  81807. /**
  81808. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  81809. */
  81810. export class Node implements IBehaviorAware<Node> {
  81811. /** @hidden */
  81812. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  81813. private static _NodeConstructors;
  81814. /**
  81815. * Add a new node constructor
  81816. * @param type defines the type name of the node to construct
  81817. * @param constructorFunc defines the constructor function
  81818. */
  81819. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  81820. /**
  81821. * Returns a node constructor based on type name
  81822. * @param type defines the type name
  81823. * @param name defines the new node name
  81824. * @param scene defines the hosting scene
  81825. * @param options defines optional options to transmit to constructors
  81826. * @returns the new constructor or null
  81827. */
  81828. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  81829. /**
  81830. * Gets or sets the name of the node
  81831. */
  81832. name: string;
  81833. /**
  81834. * Gets or sets the id of the node
  81835. */
  81836. id: string;
  81837. /**
  81838. * Gets or sets the unique id of the node
  81839. */
  81840. uniqueId: number;
  81841. /**
  81842. * Gets or sets a string used to store user defined state for the node
  81843. */
  81844. state: string;
  81845. /**
  81846. * Gets or sets an object used to store user defined information for the node
  81847. */
  81848. metadata: any;
  81849. /**
  81850. * For internal use only. Please do not use.
  81851. */
  81852. reservedDataStore: any;
  81853. /**
  81854. * Gets or sets a boolean used to define if the node must be serialized
  81855. */
  81856. doNotSerialize: boolean;
  81857. /** @hidden */
  81858. _isDisposed: boolean;
  81859. /**
  81860. * Gets a list of Animations associated with the node
  81861. */
  81862. animations: Animation[];
  81863. protected _ranges: {
  81864. [name: string]: Nullable<AnimationRange>;
  81865. };
  81866. /**
  81867. * Callback raised when the node is ready to be used
  81868. */
  81869. onReady: (node: Node) => void;
  81870. private _isEnabled;
  81871. private _isParentEnabled;
  81872. private _isReady;
  81873. /** @hidden */
  81874. _currentRenderId: number;
  81875. private _parentRenderId;
  81876. protected _childRenderId: number;
  81877. /** @hidden */
  81878. _waitingParentId: Nullable<string>;
  81879. /** @hidden */
  81880. _scene: Scene;
  81881. /** @hidden */
  81882. _cache: any;
  81883. private _parentNode;
  81884. private _children;
  81885. /** @hidden */
  81886. _worldMatrix: Matrix;
  81887. /** @hidden */
  81888. _worldMatrixDeterminant: number;
  81889. /** @hidden */
  81890. private _sceneRootNodesIndex;
  81891. /**
  81892. * Gets a boolean indicating if the node has been disposed
  81893. * @returns true if the node was disposed
  81894. */
  81895. isDisposed(): boolean;
  81896. /**
  81897. * Gets or sets the parent of the node
  81898. */
  81899. parent: Nullable<Node>;
  81900. private addToSceneRootNodes;
  81901. private removeFromSceneRootNodes;
  81902. private _animationPropertiesOverride;
  81903. /**
  81904. * Gets or sets the animation properties override
  81905. */
  81906. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81907. /**
  81908. * Gets a string idenfifying the name of the class
  81909. * @returns "Node" string
  81910. */
  81911. getClassName(): string;
  81912. /** @hidden */
  81913. readonly _isNode: boolean;
  81914. /**
  81915. * An event triggered when the mesh is disposed
  81916. */
  81917. onDisposeObservable: Observable<Node>;
  81918. private _onDisposeObserver;
  81919. /**
  81920. * Sets a callback that will be raised when the node will be disposed
  81921. */
  81922. onDispose: () => void;
  81923. /**
  81924. * Creates a new Node
  81925. * @param name the name and id to be given to this node
  81926. * @param scene the scene this node will be added to
  81927. * @param addToRootNodes the node will be added to scene.rootNodes
  81928. */
  81929. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  81930. /**
  81931. * Gets the scene of the node
  81932. * @returns a scene
  81933. */
  81934. getScene(): Scene;
  81935. /**
  81936. * Gets the engine of the node
  81937. * @returns a Engine
  81938. */
  81939. getEngine(): Engine;
  81940. private _behaviors;
  81941. /**
  81942. * Attach a behavior to the node
  81943. * @see http://doc.babylonjs.com/features/behaviour
  81944. * @param behavior defines the behavior to attach
  81945. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  81946. * @returns the current Node
  81947. */
  81948. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  81949. /**
  81950. * Remove an attached behavior
  81951. * @see http://doc.babylonjs.com/features/behaviour
  81952. * @param behavior defines the behavior to attach
  81953. * @returns the current Node
  81954. */
  81955. removeBehavior(behavior: Behavior<Node>): Node;
  81956. /**
  81957. * Gets the list of attached behaviors
  81958. * @see http://doc.babylonjs.com/features/behaviour
  81959. */
  81960. readonly behaviors: Behavior<Node>[];
  81961. /**
  81962. * Gets an attached behavior by name
  81963. * @param name defines the name of the behavior to look for
  81964. * @see http://doc.babylonjs.com/features/behaviour
  81965. * @returns null if behavior was not found else the requested behavior
  81966. */
  81967. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  81968. /**
  81969. * Returns the latest update of the World matrix
  81970. * @returns a Matrix
  81971. */
  81972. getWorldMatrix(): Matrix;
  81973. /** @hidden */
  81974. _getWorldMatrixDeterminant(): number;
  81975. /**
  81976. * Returns directly the latest state of the mesh World matrix.
  81977. * A Matrix is returned.
  81978. */
  81979. readonly worldMatrixFromCache: Matrix;
  81980. /** @hidden */
  81981. _initCache(): void;
  81982. /** @hidden */
  81983. updateCache(force?: boolean): void;
  81984. /** @hidden */
  81985. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  81986. /** @hidden */
  81987. _updateCache(ignoreParentClass?: boolean): void;
  81988. /** @hidden */
  81989. _isSynchronized(): boolean;
  81990. /** @hidden */
  81991. _markSyncedWithParent(): void;
  81992. /** @hidden */
  81993. isSynchronizedWithParent(): boolean;
  81994. /** @hidden */
  81995. isSynchronized(): boolean;
  81996. /**
  81997. * Is this node ready to be used/rendered
  81998. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  81999. * @return true if the node is ready
  82000. */
  82001. isReady(completeCheck?: boolean): boolean;
  82002. /**
  82003. * Is this node enabled?
  82004. * 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
  82005. * @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
  82006. * @return whether this node (and its parent) is enabled
  82007. */
  82008. isEnabled(checkAncestors?: boolean): boolean;
  82009. /** @hidden */
  82010. protected _syncParentEnabledState(): void;
  82011. /**
  82012. * Set the enabled state of this node
  82013. * @param value defines the new enabled state
  82014. */
  82015. setEnabled(value: boolean): void;
  82016. /**
  82017. * Is this node a descendant of the given node?
  82018. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  82019. * @param ancestor defines the parent node to inspect
  82020. * @returns a boolean indicating if this node is a descendant of the given node
  82021. */
  82022. isDescendantOf(ancestor: Node): boolean;
  82023. /** @hidden */
  82024. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  82025. /**
  82026. * Will return all nodes that have this node as ascendant
  82027. * @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
  82028. * @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
  82029. * @return all children nodes of all types
  82030. */
  82031. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  82032. /**
  82033. * Get all child-meshes of this node
  82034. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  82035. * @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
  82036. * @returns an array of AbstractMesh
  82037. */
  82038. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  82039. /**
  82040. * Get all direct children of this node
  82041. * @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
  82042. * @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)
  82043. * @returns an array of Node
  82044. */
  82045. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  82046. /** @hidden */
  82047. _setReady(state: boolean): void;
  82048. /**
  82049. * Get an animation by name
  82050. * @param name defines the name of the animation to look for
  82051. * @returns null if not found else the requested animation
  82052. */
  82053. getAnimationByName(name: string): Nullable<Animation>;
  82054. /**
  82055. * Creates an animation range for this node
  82056. * @param name defines the name of the range
  82057. * @param from defines the starting key
  82058. * @param to defines the end key
  82059. */
  82060. createAnimationRange(name: string, from: number, to: number): void;
  82061. /**
  82062. * Delete a specific animation range
  82063. * @param name defines the name of the range to delete
  82064. * @param deleteFrames defines if animation frames from the range must be deleted as well
  82065. */
  82066. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82067. /**
  82068. * Get an animation range by name
  82069. * @param name defines the name of the animation range to look for
  82070. * @returns null if not found else the requested animation range
  82071. */
  82072. getAnimationRange(name: string): Nullable<AnimationRange>;
  82073. /**
  82074. * Gets the list of all animation ranges defined on this node
  82075. * @returns an array
  82076. */
  82077. getAnimationRanges(): Nullable<AnimationRange>[];
  82078. /**
  82079. * Will start the animation sequence
  82080. * @param name defines the range frames for animation sequence
  82081. * @param loop defines if the animation should loop (false by default)
  82082. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  82083. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  82084. * @returns the object created for this animation. If range does not exist, it will return null
  82085. */
  82086. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82087. /**
  82088. * Serialize animation ranges into a JSON compatible object
  82089. * @returns serialization object
  82090. */
  82091. serializeAnimationRanges(): any;
  82092. /**
  82093. * Computes the world matrix of the node
  82094. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82095. * @returns the world matrix
  82096. */
  82097. computeWorldMatrix(force?: boolean): Matrix;
  82098. /**
  82099. * Releases resources associated with this node.
  82100. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82101. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82102. */
  82103. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82104. /**
  82105. * Parse animation range data from a serialization object and store them into a given node
  82106. * @param node defines where to store the animation ranges
  82107. * @param parsedNode defines the serialization object to read data from
  82108. * @param scene defines the hosting scene
  82109. */
  82110. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  82111. }
  82112. }
  82113. declare module BABYLON {
  82114. /**
  82115. * Class used to store any kind of animation
  82116. */
  82117. export class Animation {
  82118. /**Name of the animation */
  82119. name: string;
  82120. /**Property to animate */
  82121. targetProperty: string;
  82122. /**The frames per second of the animation */
  82123. framePerSecond: number;
  82124. /**The data type of the animation */
  82125. dataType: number;
  82126. /**The loop mode of the animation */
  82127. loopMode?: number | undefined;
  82128. /**Specifies if blending should be enabled */
  82129. enableBlending?: boolean | undefined;
  82130. /**
  82131. * Use matrix interpolation instead of using direct key value when animating matrices
  82132. */
  82133. static AllowMatricesInterpolation: boolean;
  82134. /**
  82135. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  82136. */
  82137. static AllowMatrixDecomposeForInterpolation: boolean;
  82138. /**
  82139. * Stores the key frames of the animation
  82140. */
  82141. private _keys;
  82142. /**
  82143. * Stores the easing function of the animation
  82144. */
  82145. private _easingFunction;
  82146. /**
  82147. * @hidden Internal use only
  82148. */
  82149. _runtimeAnimations: RuntimeAnimation[];
  82150. /**
  82151. * The set of event that will be linked to this animation
  82152. */
  82153. private _events;
  82154. /**
  82155. * Stores an array of target property paths
  82156. */
  82157. targetPropertyPath: string[];
  82158. /**
  82159. * Stores the blending speed of the animation
  82160. */
  82161. blendingSpeed: number;
  82162. /**
  82163. * Stores the animation ranges for the animation
  82164. */
  82165. private _ranges;
  82166. /**
  82167. * @hidden Internal use
  82168. */
  82169. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  82170. /**
  82171. * Sets up an animation
  82172. * @param property The property to animate
  82173. * @param animationType The animation type to apply
  82174. * @param framePerSecond The frames per second of the animation
  82175. * @param easingFunction The easing function used in the animation
  82176. * @returns The created animation
  82177. */
  82178. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  82179. /**
  82180. * Create and start an animation on a node
  82181. * @param name defines the name of the global animation that will be run on all nodes
  82182. * @param node defines the root node where the animation will take place
  82183. * @param targetProperty defines property to animate
  82184. * @param framePerSecond defines the number of frame per second yo use
  82185. * @param totalFrame defines the number of frames in total
  82186. * @param from defines the initial value
  82187. * @param to defines the final value
  82188. * @param loopMode defines which loop mode you want to use (off by default)
  82189. * @param easingFunction defines the easing function to use (linear by default)
  82190. * @param onAnimationEnd defines the callback to call when animation end
  82191. * @returns the animatable created for this animation
  82192. */
  82193. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82194. /**
  82195. * Create and start an animation on a node and its descendants
  82196. * @param name defines the name of the global animation that will be run on all nodes
  82197. * @param node defines the root node where the animation will take place
  82198. * @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
  82199. * @param targetProperty defines property to animate
  82200. * @param framePerSecond defines the number of frame per second to use
  82201. * @param totalFrame defines the number of frames in total
  82202. * @param from defines the initial value
  82203. * @param to defines the final value
  82204. * @param loopMode defines which loop mode you want to use (off by default)
  82205. * @param easingFunction defines the easing function to use (linear by default)
  82206. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82207. * @returns the list of animatables created for all nodes
  82208. * @example https://www.babylonjs-playground.com/#MH0VLI
  82209. */
  82210. 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[]>;
  82211. /**
  82212. * Creates a new animation, merges it with the existing animations and starts it
  82213. * @param name Name of the animation
  82214. * @param node Node which contains the scene that begins the animations
  82215. * @param targetProperty Specifies which property to animate
  82216. * @param framePerSecond The frames per second of the animation
  82217. * @param totalFrame The total number of frames
  82218. * @param from The frame at the beginning of the animation
  82219. * @param to The frame at the end of the animation
  82220. * @param loopMode Specifies the loop mode of the animation
  82221. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  82222. * @param onAnimationEnd Callback to run once the animation is complete
  82223. * @returns Nullable animation
  82224. */
  82225. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  82226. /**
  82227. * Transition property of an host to the target Value
  82228. * @param property The property to transition
  82229. * @param targetValue The target Value of the property
  82230. * @param host The object where the property to animate belongs
  82231. * @param scene Scene used to run the animation
  82232. * @param frameRate Framerate (in frame/s) to use
  82233. * @param transition The transition type we want to use
  82234. * @param duration The duration of the animation, in milliseconds
  82235. * @param onAnimationEnd Callback trigger at the end of the animation
  82236. * @returns Nullable animation
  82237. */
  82238. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  82239. /**
  82240. * Return the array of runtime animations currently using this animation
  82241. */
  82242. readonly runtimeAnimations: RuntimeAnimation[];
  82243. /**
  82244. * Specifies if any of the runtime animations are currently running
  82245. */
  82246. readonly hasRunningRuntimeAnimations: boolean;
  82247. /**
  82248. * Initializes the animation
  82249. * @param name Name of the animation
  82250. * @param targetProperty Property to animate
  82251. * @param framePerSecond The frames per second of the animation
  82252. * @param dataType The data type of the animation
  82253. * @param loopMode The loop mode of the animation
  82254. * @param enableBlending Specifies if blending should be enabled
  82255. */
  82256. constructor(
  82257. /**Name of the animation */
  82258. name: string,
  82259. /**Property to animate */
  82260. targetProperty: string,
  82261. /**The frames per second of the animation */
  82262. framePerSecond: number,
  82263. /**The data type of the animation */
  82264. dataType: number,
  82265. /**The loop mode of the animation */
  82266. loopMode?: number | undefined,
  82267. /**Specifies if blending should be enabled */
  82268. enableBlending?: boolean | undefined);
  82269. /**
  82270. * Converts the animation to a string
  82271. * @param fullDetails support for multiple levels of logging within scene loading
  82272. * @returns String form of the animation
  82273. */
  82274. toString(fullDetails?: boolean): string;
  82275. /**
  82276. * Add an event to this animation
  82277. * @param event Event to add
  82278. */
  82279. addEvent(event: AnimationEvent): void;
  82280. /**
  82281. * Remove all events found at the given frame
  82282. * @param frame The frame to remove events from
  82283. */
  82284. removeEvents(frame: number): void;
  82285. /**
  82286. * Retrieves all the events from the animation
  82287. * @returns Events from the animation
  82288. */
  82289. getEvents(): AnimationEvent[];
  82290. /**
  82291. * Creates an animation range
  82292. * @param name Name of the animation range
  82293. * @param from Starting frame of the animation range
  82294. * @param to Ending frame of the animation
  82295. */
  82296. createRange(name: string, from: number, to: number): void;
  82297. /**
  82298. * Deletes an animation range by name
  82299. * @param name Name of the animation range to delete
  82300. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  82301. */
  82302. deleteRange(name: string, deleteFrames?: boolean): void;
  82303. /**
  82304. * Gets the animation range by name, or null if not defined
  82305. * @param name Name of the animation range
  82306. * @returns Nullable animation range
  82307. */
  82308. getRange(name: string): Nullable<AnimationRange>;
  82309. /**
  82310. * Gets the key frames from the animation
  82311. * @returns The key frames of the animation
  82312. */
  82313. getKeys(): Array<IAnimationKey>;
  82314. /**
  82315. * Gets the highest frame rate of the animation
  82316. * @returns Highest frame rate of the animation
  82317. */
  82318. getHighestFrame(): number;
  82319. /**
  82320. * Gets the easing function of the animation
  82321. * @returns Easing function of the animation
  82322. */
  82323. getEasingFunction(): IEasingFunction;
  82324. /**
  82325. * Sets the easing function of the animation
  82326. * @param easingFunction A custom mathematical formula for animation
  82327. */
  82328. setEasingFunction(easingFunction: EasingFunction): void;
  82329. /**
  82330. * Interpolates a scalar linearly
  82331. * @param startValue Start value of the animation curve
  82332. * @param endValue End value of the animation curve
  82333. * @param gradient Scalar amount to interpolate
  82334. * @returns Interpolated scalar value
  82335. */
  82336. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  82337. /**
  82338. * Interpolates a scalar cubically
  82339. * @param startValue Start value of the animation curve
  82340. * @param outTangent End tangent of the animation
  82341. * @param endValue End value of the animation curve
  82342. * @param inTangent Start tangent of the animation curve
  82343. * @param gradient Scalar amount to interpolate
  82344. * @returns Interpolated scalar value
  82345. */
  82346. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  82347. /**
  82348. * Interpolates a quaternion using a spherical linear interpolation
  82349. * @param startValue Start value of the animation curve
  82350. * @param endValue End value of the animation curve
  82351. * @param gradient Scalar amount to interpolate
  82352. * @returns Interpolated quaternion value
  82353. */
  82354. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  82355. /**
  82356. * Interpolates a quaternion cubically
  82357. * @param startValue Start value of the animation curve
  82358. * @param outTangent End tangent of the animation curve
  82359. * @param endValue End value of the animation curve
  82360. * @param inTangent Start tangent of the animation curve
  82361. * @param gradient Scalar amount to interpolate
  82362. * @returns Interpolated quaternion value
  82363. */
  82364. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  82365. /**
  82366. * Interpolates a Vector3 linearl
  82367. * @param startValue Start value of the animation curve
  82368. * @param endValue End value of the animation curve
  82369. * @param gradient Scalar amount to interpolate
  82370. * @returns Interpolated scalar value
  82371. */
  82372. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  82373. /**
  82374. * Interpolates a Vector3 cubically
  82375. * @param startValue Start value of the animation curve
  82376. * @param outTangent End tangent of the animation
  82377. * @param endValue End value of the animation curve
  82378. * @param inTangent Start tangent of the animation curve
  82379. * @param gradient Scalar amount to interpolate
  82380. * @returns InterpolatedVector3 value
  82381. */
  82382. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  82383. /**
  82384. * Interpolates a Vector2 linearly
  82385. * @param startValue Start value of the animation curve
  82386. * @param endValue End value of the animation curve
  82387. * @param gradient Scalar amount to interpolate
  82388. * @returns Interpolated Vector2 value
  82389. */
  82390. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  82391. /**
  82392. * Interpolates a Vector2 cubically
  82393. * @param startValue Start value of the animation curve
  82394. * @param outTangent End tangent of the animation
  82395. * @param endValue End value of the animation curve
  82396. * @param inTangent Start tangent of the animation curve
  82397. * @param gradient Scalar amount to interpolate
  82398. * @returns Interpolated Vector2 value
  82399. */
  82400. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  82401. /**
  82402. * Interpolates a size linearly
  82403. * @param startValue Start value of the animation curve
  82404. * @param endValue End value of the animation curve
  82405. * @param gradient Scalar amount to interpolate
  82406. * @returns Interpolated Size value
  82407. */
  82408. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  82409. /**
  82410. * Interpolates a Color3 linearly
  82411. * @param startValue Start value of the animation curve
  82412. * @param endValue End value of the animation curve
  82413. * @param gradient Scalar amount to interpolate
  82414. * @returns Interpolated Color3 value
  82415. */
  82416. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  82417. /**
  82418. * @hidden Internal use only
  82419. */
  82420. _getKeyValue(value: any): any;
  82421. /**
  82422. * @hidden Internal use only
  82423. */
  82424. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  82425. /**
  82426. * Defines the function to use to interpolate matrices
  82427. * @param startValue defines the start matrix
  82428. * @param endValue defines the end matrix
  82429. * @param gradient defines the gradient between both matrices
  82430. * @param result defines an optional target matrix where to store the interpolation
  82431. * @returns the interpolated matrix
  82432. */
  82433. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  82434. /**
  82435. * Makes a copy of the animation
  82436. * @returns Cloned animation
  82437. */
  82438. clone(): Animation;
  82439. /**
  82440. * Sets the key frames of the animation
  82441. * @param values The animation key frames to set
  82442. */
  82443. setKeys(values: Array<IAnimationKey>): void;
  82444. /**
  82445. * Serializes the animation to an object
  82446. * @returns Serialized object
  82447. */
  82448. serialize(): any;
  82449. /**
  82450. * Float animation type
  82451. */
  82452. private static _ANIMATIONTYPE_FLOAT;
  82453. /**
  82454. * Vector3 animation type
  82455. */
  82456. private static _ANIMATIONTYPE_VECTOR3;
  82457. /**
  82458. * Quaternion animation type
  82459. */
  82460. private static _ANIMATIONTYPE_QUATERNION;
  82461. /**
  82462. * Matrix animation type
  82463. */
  82464. private static _ANIMATIONTYPE_MATRIX;
  82465. /**
  82466. * Color3 animation type
  82467. */
  82468. private static _ANIMATIONTYPE_COLOR3;
  82469. /**
  82470. * Vector2 animation type
  82471. */
  82472. private static _ANIMATIONTYPE_VECTOR2;
  82473. /**
  82474. * Size animation type
  82475. */
  82476. private static _ANIMATIONTYPE_SIZE;
  82477. /**
  82478. * Relative Loop Mode
  82479. */
  82480. private static _ANIMATIONLOOPMODE_RELATIVE;
  82481. /**
  82482. * Cycle Loop Mode
  82483. */
  82484. private static _ANIMATIONLOOPMODE_CYCLE;
  82485. /**
  82486. * Constant Loop Mode
  82487. */
  82488. private static _ANIMATIONLOOPMODE_CONSTANT;
  82489. /**
  82490. * Get the float animation type
  82491. */
  82492. static readonly ANIMATIONTYPE_FLOAT: number;
  82493. /**
  82494. * Get the Vector3 animation type
  82495. */
  82496. static readonly ANIMATIONTYPE_VECTOR3: number;
  82497. /**
  82498. * Get the Vector2 animation type
  82499. */
  82500. static readonly ANIMATIONTYPE_VECTOR2: number;
  82501. /**
  82502. * Get the Size animation type
  82503. */
  82504. static readonly ANIMATIONTYPE_SIZE: number;
  82505. /**
  82506. * Get the Quaternion animation type
  82507. */
  82508. static readonly ANIMATIONTYPE_QUATERNION: number;
  82509. /**
  82510. * Get the Matrix animation type
  82511. */
  82512. static readonly ANIMATIONTYPE_MATRIX: number;
  82513. /**
  82514. * Get the Color3 animation type
  82515. */
  82516. static readonly ANIMATIONTYPE_COLOR3: number;
  82517. /**
  82518. * Get the Relative Loop Mode
  82519. */
  82520. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  82521. /**
  82522. * Get the Cycle Loop Mode
  82523. */
  82524. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  82525. /**
  82526. * Get the Constant Loop Mode
  82527. */
  82528. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  82529. /** @hidden */
  82530. static _UniversalLerp(left: any, right: any, amount: number): any;
  82531. /**
  82532. * Parses an animation object and creates an animation
  82533. * @param parsedAnimation Parsed animation object
  82534. * @returns Animation object
  82535. */
  82536. static Parse(parsedAnimation: any): Animation;
  82537. /**
  82538. * Appends the serialized animations from the source animations
  82539. * @param source Source containing the animations
  82540. * @param destination Target to store the animations
  82541. */
  82542. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  82543. }
  82544. }
  82545. declare module BABYLON {
  82546. /**
  82547. * Base class of all the textures in babylon.
  82548. * It groups all the common properties the materials, post process, lights... might need
  82549. * in order to make a correct use of the texture.
  82550. */
  82551. export class BaseTexture implements IAnimatable {
  82552. /**
  82553. * Default anisotropic filtering level for the application.
  82554. * It is set to 4 as a good tradeoff between perf and quality.
  82555. */
  82556. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  82557. /**
  82558. * Gets or sets the unique id of the texture
  82559. */
  82560. uniqueId: number;
  82561. /**
  82562. * Define the name of the texture.
  82563. */
  82564. name: string;
  82565. /**
  82566. * Gets or sets an object used to store user defined information.
  82567. */
  82568. metadata: any;
  82569. /**
  82570. * For internal use only. Please do not use.
  82571. */
  82572. reservedDataStore: any;
  82573. private _hasAlpha;
  82574. /**
  82575. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  82576. */
  82577. hasAlpha: boolean;
  82578. /**
  82579. * Defines if the alpha value should be determined via the rgb values.
  82580. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  82581. */
  82582. getAlphaFromRGB: boolean;
  82583. /**
  82584. * Intensity or strength of the texture.
  82585. * It is commonly used by materials to fine tune the intensity of the texture
  82586. */
  82587. level: number;
  82588. /**
  82589. * Define the UV chanel to use starting from 0 and defaulting to 0.
  82590. * This is part of the texture as textures usually maps to one uv set.
  82591. */
  82592. coordinatesIndex: number;
  82593. private _coordinatesMode;
  82594. /**
  82595. * How a texture is mapped.
  82596. *
  82597. * | Value | Type | Description |
  82598. * | ----- | ----------------------------------- | ----------- |
  82599. * | 0 | EXPLICIT_MODE | |
  82600. * | 1 | SPHERICAL_MODE | |
  82601. * | 2 | PLANAR_MODE | |
  82602. * | 3 | CUBIC_MODE | |
  82603. * | 4 | PROJECTION_MODE | |
  82604. * | 5 | SKYBOX_MODE | |
  82605. * | 6 | INVCUBIC_MODE | |
  82606. * | 7 | EQUIRECTANGULAR_MODE | |
  82607. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  82608. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  82609. */
  82610. coordinatesMode: number;
  82611. /**
  82612. * | Value | Type | Description |
  82613. * | ----- | ------------------ | ----------- |
  82614. * | 0 | CLAMP_ADDRESSMODE | |
  82615. * | 1 | WRAP_ADDRESSMODE | |
  82616. * | 2 | MIRROR_ADDRESSMODE | |
  82617. */
  82618. wrapU: number;
  82619. /**
  82620. * | Value | Type | Description |
  82621. * | ----- | ------------------ | ----------- |
  82622. * | 0 | CLAMP_ADDRESSMODE | |
  82623. * | 1 | WRAP_ADDRESSMODE | |
  82624. * | 2 | MIRROR_ADDRESSMODE | |
  82625. */
  82626. wrapV: number;
  82627. /**
  82628. * | Value | Type | Description |
  82629. * | ----- | ------------------ | ----------- |
  82630. * | 0 | CLAMP_ADDRESSMODE | |
  82631. * | 1 | WRAP_ADDRESSMODE | |
  82632. * | 2 | MIRROR_ADDRESSMODE | |
  82633. */
  82634. wrapR: number;
  82635. /**
  82636. * With compliant hardware and browser (supporting anisotropic filtering)
  82637. * this defines the level of anisotropic filtering in the texture.
  82638. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  82639. */
  82640. anisotropicFilteringLevel: number;
  82641. /**
  82642. * Define if the texture is a cube texture or if false a 2d texture.
  82643. */
  82644. isCube: boolean;
  82645. /**
  82646. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  82647. */
  82648. is3D: boolean;
  82649. /**
  82650. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  82651. * HDR texture are usually stored in linear space.
  82652. * This only impacts the PBR and Background materials
  82653. */
  82654. gammaSpace: boolean;
  82655. /**
  82656. * Gets whether or not the texture contains RGBD data.
  82657. */
  82658. readonly isRGBD: boolean;
  82659. /**
  82660. * Is Z inverted in the texture (useful in a cube texture).
  82661. */
  82662. invertZ: boolean;
  82663. /**
  82664. * Are mip maps generated for this texture or not.
  82665. */
  82666. readonly noMipmap: boolean;
  82667. /**
  82668. * @hidden
  82669. */
  82670. lodLevelInAlpha: boolean;
  82671. /**
  82672. * With prefiltered texture, defined the offset used during the prefiltering steps.
  82673. */
  82674. lodGenerationOffset: number;
  82675. /**
  82676. * With prefiltered texture, defined the scale used during the prefiltering steps.
  82677. */
  82678. lodGenerationScale: number;
  82679. /**
  82680. * Define if the texture is a render target.
  82681. */
  82682. isRenderTarget: boolean;
  82683. /**
  82684. * Define the unique id of the texture in the scene.
  82685. */
  82686. readonly uid: string;
  82687. /**
  82688. * Return a string representation of the texture.
  82689. * @returns the texture as a string
  82690. */
  82691. toString(): string;
  82692. /**
  82693. * Get the class name of the texture.
  82694. * @returns "BaseTexture"
  82695. */
  82696. getClassName(): string;
  82697. /**
  82698. * Define the list of animation attached to the texture.
  82699. */
  82700. animations: Animation[];
  82701. /**
  82702. * An event triggered when the texture is disposed.
  82703. */
  82704. onDisposeObservable: Observable<BaseTexture>;
  82705. private _onDisposeObserver;
  82706. /**
  82707. * Callback triggered when the texture has been disposed.
  82708. * Kept for back compatibility, you can use the onDisposeObservable instead.
  82709. */
  82710. onDispose: () => void;
  82711. /**
  82712. * Define the current state of the loading sequence when in delayed load mode.
  82713. */
  82714. delayLoadState: number;
  82715. private _scene;
  82716. /** @hidden */
  82717. _texture: Nullable<InternalTexture>;
  82718. private _uid;
  82719. /**
  82720. * Define if the texture is preventinga material to render or not.
  82721. * If not and the texture is not ready, the engine will use a default black texture instead.
  82722. */
  82723. readonly isBlocking: boolean;
  82724. /**
  82725. * Instantiates a new BaseTexture.
  82726. * Base class of all the textures in babylon.
  82727. * It groups all the common properties the materials, post process, lights... might need
  82728. * in order to make a correct use of the texture.
  82729. * @param scene Define the scene the texture blongs to
  82730. */
  82731. constructor(scene: Nullable<Scene>);
  82732. /**
  82733. * Get the scene the texture belongs to.
  82734. * @returns the scene or null if undefined
  82735. */
  82736. getScene(): Nullable<Scene>;
  82737. /**
  82738. * Get the texture transform matrix used to offset tile the texture for istance.
  82739. * @returns the transformation matrix
  82740. */
  82741. getTextureMatrix(): Matrix;
  82742. /**
  82743. * Get the texture reflection matrix used to rotate/transform the reflection.
  82744. * @returns the reflection matrix
  82745. */
  82746. getReflectionTextureMatrix(): Matrix;
  82747. /**
  82748. * Get the underlying lower level texture from Babylon.
  82749. * @returns the insternal texture
  82750. */
  82751. getInternalTexture(): Nullable<InternalTexture>;
  82752. /**
  82753. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  82754. * @returns true if ready or not blocking
  82755. */
  82756. isReadyOrNotBlocking(): boolean;
  82757. /**
  82758. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  82759. * @returns true if fully ready
  82760. */
  82761. isReady(): boolean;
  82762. private _cachedSize;
  82763. /**
  82764. * Get the size of the texture.
  82765. * @returns the texture size.
  82766. */
  82767. getSize(): ISize;
  82768. /**
  82769. * Get the base size of the texture.
  82770. * It can be different from the size if the texture has been resized for POT for instance
  82771. * @returns the base size
  82772. */
  82773. getBaseSize(): ISize;
  82774. /**
  82775. * Update the sampling mode of the texture.
  82776. * Default is Trilinear mode.
  82777. *
  82778. * | Value | Type | Description |
  82779. * | ----- | ------------------ | ----------- |
  82780. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  82781. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  82782. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  82783. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  82784. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  82785. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  82786. * | 7 | NEAREST_LINEAR | |
  82787. * | 8 | NEAREST_NEAREST | |
  82788. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  82789. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  82790. * | 11 | LINEAR_LINEAR | |
  82791. * | 12 | LINEAR_NEAREST | |
  82792. *
  82793. * > _mag_: magnification filter (close to the viewer)
  82794. * > _min_: minification filter (far from the viewer)
  82795. * > _mip_: filter used between mip map levels
  82796. *@param samplingMode Define the new sampling mode of the texture
  82797. */
  82798. updateSamplingMode(samplingMode: number): void;
  82799. /**
  82800. * Scales the texture if is `canRescale()`
  82801. * @param ratio the resize factor we want to use to rescale
  82802. */
  82803. scale(ratio: number): void;
  82804. /**
  82805. * Get if the texture can rescale.
  82806. */
  82807. readonly canRescale: boolean;
  82808. /** @hidden */
  82809. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  82810. /** @hidden */
  82811. _rebuild(): void;
  82812. /**
  82813. * Triggers the load sequence in delayed load mode.
  82814. */
  82815. delayLoad(): void;
  82816. /**
  82817. * Clones the texture.
  82818. * @returns the cloned texture
  82819. */
  82820. clone(): Nullable<BaseTexture>;
  82821. /**
  82822. * Get the texture underlying type (INT, FLOAT...)
  82823. */
  82824. readonly textureType: number;
  82825. /**
  82826. * Get the texture underlying format (RGB, RGBA...)
  82827. */
  82828. readonly textureFormat: number;
  82829. /**
  82830. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  82831. * This will returns an RGBA array buffer containing either in values (0-255) or
  82832. * float values (0-1) depending of the underlying buffer type.
  82833. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  82834. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  82835. * @param buffer defines a user defined buffer to fill with data (can be null)
  82836. * @returns The Array buffer containing the pixels data.
  82837. */
  82838. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  82839. /**
  82840. * Release and destroy the underlying lower level texture aka internalTexture.
  82841. */
  82842. releaseInternalTexture(): void;
  82843. /**
  82844. * Get the polynomial representation of the texture data.
  82845. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  82846. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  82847. */
  82848. sphericalPolynomial: Nullable<SphericalPolynomial>;
  82849. /** @hidden */
  82850. readonly _lodTextureHigh: Nullable<BaseTexture>;
  82851. /** @hidden */
  82852. readonly _lodTextureMid: Nullable<BaseTexture>;
  82853. /** @hidden */
  82854. readonly _lodTextureLow: Nullable<BaseTexture>;
  82855. /**
  82856. * Dispose the texture and release its associated resources.
  82857. */
  82858. dispose(): void;
  82859. /**
  82860. * Serialize the texture into a JSON representation that can be parsed later on.
  82861. * @returns the JSON representation of the texture
  82862. */
  82863. serialize(): any;
  82864. /**
  82865. * Helper function to be called back once a list of texture contains only ready textures.
  82866. * @param textures Define the list of textures to wait for
  82867. * @param callback Define the callback triggered once the entire list will be ready
  82868. */
  82869. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  82870. }
  82871. }
  82872. declare module BABYLON {
  82873. /**
  82874. * Uniform buffer objects.
  82875. *
  82876. * Handles blocks of uniform on the GPU.
  82877. *
  82878. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82879. *
  82880. * For more information, please refer to :
  82881. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82882. */
  82883. export class UniformBuffer {
  82884. private _engine;
  82885. private _buffer;
  82886. private _data;
  82887. private _bufferData;
  82888. private _dynamic?;
  82889. private _uniformLocations;
  82890. private _uniformSizes;
  82891. private _uniformLocationPointer;
  82892. private _needSync;
  82893. private _noUBO;
  82894. private _currentEffect;
  82895. private static _MAX_UNIFORM_SIZE;
  82896. private static _tempBuffer;
  82897. /**
  82898. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  82899. * This is dynamic to allow compat with webgl 1 and 2.
  82900. * You will need to pass the name of the uniform as well as the value.
  82901. */
  82902. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  82903. /**
  82904. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  82905. * This is dynamic to allow compat with webgl 1 and 2.
  82906. * You will need to pass the name of the uniform as well as the value.
  82907. */
  82908. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  82909. /**
  82910. * Lambda to Update a single float in a uniform buffer.
  82911. * This is dynamic to allow compat with webgl 1 and 2.
  82912. * You will need to pass the name of the uniform as well as the value.
  82913. */
  82914. updateFloat: (name: string, x: number) => void;
  82915. /**
  82916. * Lambda to Update a vec2 of float in a uniform buffer.
  82917. * This is dynamic to allow compat with webgl 1 and 2.
  82918. * You will need to pass the name of the uniform as well as the value.
  82919. */
  82920. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  82921. /**
  82922. * Lambda to Update a vec3 of float in a uniform buffer.
  82923. * This is dynamic to allow compat with webgl 1 and 2.
  82924. * You will need to pass the name of the uniform as well as the value.
  82925. */
  82926. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  82927. /**
  82928. * Lambda to Update a vec4 of float in a uniform buffer.
  82929. * This is dynamic to allow compat with webgl 1 and 2.
  82930. * You will need to pass the name of the uniform as well as the value.
  82931. */
  82932. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  82933. /**
  82934. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  82935. * This is dynamic to allow compat with webgl 1 and 2.
  82936. * You will need to pass the name of the uniform as well as the value.
  82937. */
  82938. updateMatrix: (name: string, mat: Matrix) => void;
  82939. /**
  82940. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  82941. * This is dynamic to allow compat with webgl 1 and 2.
  82942. * You will need to pass the name of the uniform as well as the value.
  82943. */
  82944. updateVector3: (name: string, vector: Vector3) => void;
  82945. /**
  82946. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  82947. * This is dynamic to allow compat with webgl 1 and 2.
  82948. * You will need to pass the name of the uniform as well as the value.
  82949. */
  82950. updateVector4: (name: string, vector: Vector4) => void;
  82951. /**
  82952. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  82953. * This is dynamic to allow compat with webgl 1 and 2.
  82954. * You will need to pass the name of the uniform as well as the value.
  82955. */
  82956. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  82957. /**
  82958. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  82959. * This is dynamic to allow compat with webgl 1 and 2.
  82960. * You will need to pass the name of the uniform as well as the value.
  82961. */
  82962. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  82963. /**
  82964. * Instantiates a new Uniform buffer objects.
  82965. *
  82966. * Handles blocks of uniform on the GPU.
  82967. *
  82968. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  82969. *
  82970. * For more information, please refer to :
  82971. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  82972. * @param engine Define the engine the buffer is associated with
  82973. * @param data Define the data contained in the buffer
  82974. * @param dynamic Define if the buffer is updatable
  82975. */
  82976. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  82977. /**
  82978. * Indicates if the buffer is using the WebGL2 UBO implementation,
  82979. * or just falling back on setUniformXXX calls.
  82980. */
  82981. readonly useUbo: boolean;
  82982. /**
  82983. * Indicates if the WebGL underlying uniform buffer is in sync
  82984. * with the javascript cache data.
  82985. */
  82986. readonly isSync: boolean;
  82987. /**
  82988. * Indicates if the WebGL underlying uniform buffer is dynamic.
  82989. * Also, a dynamic UniformBuffer will disable cache verification and always
  82990. * update the underlying WebGL uniform buffer to the GPU.
  82991. * @returns if Dynamic, otherwise false
  82992. */
  82993. isDynamic(): boolean;
  82994. /**
  82995. * The data cache on JS side.
  82996. * @returns the underlying data as a float array
  82997. */
  82998. getData(): Float32Array;
  82999. /**
  83000. * The underlying WebGL Uniform buffer.
  83001. * @returns the webgl buffer
  83002. */
  83003. getBuffer(): Nullable<WebGLBuffer>;
  83004. /**
  83005. * std140 layout specifies how to align data within an UBO structure.
  83006. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  83007. * for specs.
  83008. */
  83009. private _fillAlignment;
  83010. /**
  83011. * Adds an uniform in the buffer.
  83012. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  83013. * for the layout to be correct !
  83014. * @param name Name of the uniform, as used in the uniform block in the shader.
  83015. * @param size Data size, or data directly.
  83016. */
  83017. addUniform(name: string, size: number | number[]): void;
  83018. /**
  83019. * Adds a Matrix 4x4 to the uniform buffer.
  83020. * @param name Name of the uniform, as used in the uniform block in the shader.
  83021. * @param mat A 4x4 matrix.
  83022. */
  83023. addMatrix(name: string, mat: Matrix): void;
  83024. /**
  83025. * Adds a vec2 to the uniform buffer.
  83026. * @param name Name of the uniform, as used in the uniform block in the shader.
  83027. * @param x Define the x component value of the vec2
  83028. * @param y Define the y component value of the vec2
  83029. */
  83030. addFloat2(name: string, x: number, y: number): void;
  83031. /**
  83032. * Adds a vec3 to the uniform buffer.
  83033. * @param name Name of the uniform, as used in the uniform block in the shader.
  83034. * @param x Define the x component value of the vec3
  83035. * @param y Define the y component value of the vec3
  83036. * @param z Define the z component value of the vec3
  83037. */
  83038. addFloat3(name: string, x: number, y: number, z: number): void;
  83039. /**
  83040. * Adds a vec3 to the uniform buffer.
  83041. * @param name Name of the uniform, as used in the uniform block in the shader.
  83042. * @param color Define the vec3 from a Color
  83043. */
  83044. addColor3(name: string, color: Color3): void;
  83045. /**
  83046. * Adds a vec4 to the uniform buffer.
  83047. * @param name Name of the uniform, as used in the uniform block in the shader.
  83048. * @param color Define the rgb components from a Color
  83049. * @param alpha Define the a component of the vec4
  83050. */
  83051. addColor4(name: string, color: Color3, alpha: number): void;
  83052. /**
  83053. * Adds a vec3 to the uniform buffer.
  83054. * @param name Name of the uniform, as used in the uniform block in the shader.
  83055. * @param vector Define the vec3 components from a Vector
  83056. */
  83057. addVector3(name: string, vector: Vector3): void;
  83058. /**
  83059. * Adds a Matrix 3x3 to the uniform buffer.
  83060. * @param name Name of the uniform, as used in the uniform block in the shader.
  83061. */
  83062. addMatrix3x3(name: string): void;
  83063. /**
  83064. * Adds a Matrix 2x2 to the uniform buffer.
  83065. * @param name Name of the uniform, as used in the uniform block in the shader.
  83066. */
  83067. addMatrix2x2(name: string): void;
  83068. /**
  83069. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  83070. */
  83071. create(): void;
  83072. /** @hidden */
  83073. _rebuild(): void;
  83074. /**
  83075. * Updates the WebGL Uniform Buffer on the GPU.
  83076. * If the `dynamic` flag is set to true, no cache comparison is done.
  83077. * Otherwise, the buffer will be updated only if the cache differs.
  83078. */
  83079. update(): void;
  83080. /**
  83081. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  83082. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83083. * @param data Define the flattened data
  83084. * @param size Define the size of the data.
  83085. */
  83086. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  83087. private _updateMatrix3x3ForUniform;
  83088. private _updateMatrix3x3ForEffect;
  83089. private _updateMatrix2x2ForEffect;
  83090. private _updateMatrix2x2ForUniform;
  83091. private _updateFloatForEffect;
  83092. private _updateFloatForUniform;
  83093. private _updateFloat2ForEffect;
  83094. private _updateFloat2ForUniform;
  83095. private _updateFloat3ForEffect;
  83096. private _updateFloat3ForUniform;
  83097. private _updateFloat4ForEffect;
  83098. private _updateFloat4ForUniform;
  83099. private _updateMatrixForEffect;
  83100. private _updateMatrixForUniform;
  83101. private _updateVector3ForEffect;
  83102. private _updateVector3ForUniform;
  83103. private _updateVector4ForEffect;
  83104. private _updateVector4ForUniform;
  83105. private _updateColor3ForEffect;
  83106. private _updateColor3ForUniform;
  83107. private _updateColor4ForEffect;
  83108. private _updateColor4ForUniform;
  83109. /**
  83110. * Sets a sampler uniform on the effect.
  83111. * @param name Define the name of the sampler.
  83112. * @param texture Define the texture to set in the sampler
  83113. */
  83114. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  83115. /**
  83116. * Directly updates the value of the uniform in the cache AND on the GPU.
  83117. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  83118. * @param data Define the flattened data
  83119. */
  83120. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  83121. /**
  83122. * Binds this uniform buffer to an effect.
  83123. * @param effect Define the effect to bind the buffer to
  83124. * @param name Name of the uniform block in the shader.
  83125. */
  83126. bindToEffect(effect: Effect, name: string): void;
  83127. /**
  83128. * Disposes the uniform buffer.
  83129. */
  83130. dispose(): void;
  83131. }
  83132. }
  83133. declare module BABYLON {
  83134. /**
  83135. * This represents the required contract to create a new type of texture loader.
  83136. */
  83137. export interface IInternalTextureLoader {
  83138. /**
  83139. * Defines wether the loader supports cascade loading the different faces.
  83140. */
  83141. supportCascades: boolean;
  83142. /**
  83143. * This returns if the loader support the current file information.
  83144. * @param extension defines the file extension of the file being loaded
  83145. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83146. * @param fallback defines the fallback internal texture if any
  83147. * @param isBase64 defines whether the texture is encoded as a base64
  83148. * @param isBuffer defines whether the texture data are stored as a buffer
  83149. * @returns true if the loader can load the specified file
  83150. */
  83151. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  83152. /**
  83153. * Transform the url before loading if required.
  83154. * @param rootUrl the url of the texture
  83155. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83156. * @returns the transformed texture
  83157. */
  83158. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  83159. /**
  83160. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  83161. * @param rootUrl the url of the texture
  83162. * @param textureFormatInUse defines the current compressed format in use iun the engine
  83163. * @returns the fallback texture
  83164. */
  83165. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  83166. /**
  83167. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  83168. * @param data contains the texture data
  83169. * @param texture defines the BabylonJS internal texture
  83170. * @param createPolynomials will be true if polynomials have been requested
  83171. * @param onLoad defines the callback to trigger once the texture is ready
  83172. * @param onError defines the callback to trigger in case of error
  83173. */
  83174. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  83175. /**
  83176. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  83177. * @param data contains the texture data
  83178. * @param texture defines the BabylonJS internal texture
  83179. * @param callback defines the method to call once ready to upload
  83180. */
  83181. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  83182. }
  83183. }
  83184. declare module BABYLON {
  83185. /**
  83186. * Creation options of the multi render target texture.
  83187. */
  83188. export interface IMultiRenderTargetOptions {
  83189. /**
  83190. * Define if the texture needs to create mip maps after render.
  83191. */
  83192. generateMipMaps?: boolean;
  83193. /**
  83194. * Define the types of all the draw buffers we want to create
  83195. */
  83196. types?: number[];
  83197. /**
  83198. * Define the sampling modes of all the draw buffers we want to create
  83199. */
  83200. samplingModes?: number[];
  83201. /**
  83202. * Define if a depth buffer is required
  83203. */
  83204. generateDepthBuffer?: boolean;
  83205. /**
  83206. * Define if a stencil buffer is required
  83207. */
  83208. generateStencilBuffer?: boolean;
  83209. /**
  83210. * Define if a depth texture is required instead of a depth buffer
  83211. */
  83212. generateDepthTexture?: boolean;
  83213. /**
  83214. * Define the number of desired draw buffers
  83215. */
  83216. textureCount?: number;
  83217. /**
  83218. * Define if aspect ratio should be adapted to the texture or stay the scene one
  83219. */
  83220. doNotChangeAspectRatio?: boolean;
  83221. /**
  83222. * Define the default type of the buffers we are creating
  83223. */
  83224. defaultType?: number;
  83225. }
  83226. /**
  83227. * A multi render target, like a render target provides the ability to render to a texture.
  83228. * Unlike the render target, it can render to several draw buffers in one draw.
  83229. * This is specially interesting in deferred rendering or for any effects requiring more than
  83230. * just one color from a single pass.
  83231. */
  83232. export class MultiRenderTarget extends RenderTargetTexture {
  83233. private _internalTextures;
  83234. private _textures;
  83235. private _multiRenderTargetOptions;
  83236. /**
  83237. * Get if draw buffers are currently supported by the used hardware and browser.
  83238. */
  83239. readonly isSupported: boolean;
  83240. /**
  83241. * Get the list of textures generated by the multi render target.
  83242. */
  83243. readonly textures: Texture[];
  83244. /**
  83245. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  83246. */
  83247. readonly depthTexture: Texture;
  83248. /**
  83249. * Set the wrapping mode on U of all the textures we are rendering to.
  83250. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83251. */
  83252. wrapU: number;
  83253. /**
  83254. * Set the wrapping mode on V of all the textures we are rendering to.
  83255. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  83256. */
  83257. wrapV: number;
  83258. /**
  83259. * Instantiate a new multi render target texture.
  83260. * A multi render target, like a render target provides the ability to render to a texture.
  83261. * Unlike the render target, it can render to several draw buffers in one draw.
  83262. * This is specially interesting in deferred rendering or for any effects requiring more than
  83263. * just one color from a single pass.
  83264. * @param name Define the name of the texture
  83265. * @param size Define the size of the buffers to render to
  83266. * @param count Define the number of target we are rendering into
  83267. * @param scene Define the scene the texture belongs to
  83268. * @param options Define the options used to create the multi render target
  83269. */
  83270. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  83271. /** @hidden */
  83272. _rebuild(): void;
  83273. private _createInternalTextures;
  83274. private _createTextures;
  83275. /**
  83276. * Define the number of samples used if MSAA is enabled.
  83277. */
  83278. samples: number;
  83279. /**
  83280. * Resize all the textures in the multi render target.
  83281. * Be carrefull as it will recreate all the data in the new texture.
  83282. * @param size Define the new size
  83283. */
  83284. resize(size: any): void;
  83285. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83286. /**
  83287. * Dispose the render targets and their associated resources
  83288. */
  83289. dispose(): void;
  83290. /**
  83291. * Release all the underlying texture used as draw buffers.
  83292. */
  83293. releaseInternalTextures(): void;
  83294. }
  83295. }
  83296. declare module BABYLON {
  83297. /**
  83298. * Class used to work with sound analyzer using fast fourier transform (FFT)
  83299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83300. */
  83301. export class Analyser {
  83302. /**
  83303. * Gets or sets the smoothing
  83304. * @ignorenaming
  83305. */
  83306. SMOOTHING: number;
  83307. /**
  83308. * Gets or sets the FFT table size
  83309. * @ignorenaming
  83310. */
  83311. FFT_SIZE: number;
  83312. /**
  83313. * Gets or sets the bar graph amplitude
  83314. * @ignorenaming
  83315. */
  83316. BARGRAPHAMPLITUDE: number;
  83317. /**
  83318. * Gets or sets the position of the debug canvas
  83319. * @ignorenaming
  83320. */
  83321. DEBUGCANVASPOS: {
  83322. x: number;
  83323. y: number;
  83324. };
  83325. /**
  83326. * Gets or sets the debug canvas size
  83327. * @ignorenaming
  83328. */
  83329. DEBUGCANVASSIZE: {
  83330. width: number;
  83331. height: number;
  83332. };
  83333. private _byteFreqs;
  83334. private _byteTime;
  83335. private _floatFreqs;
  83336. private _webAudioAnalyser;
  83337. private _debugCanvas;
  83338. private _debugCanvasContext;
  83339. private _scene;
  83340. private _registerFunc;
  83341. private _audioEngine;
  83342. /**
  83343. * Creates a new analyser
  83344. * @param scene defines hosting scene
  83345. */
  83346. constructor(scene: Scene);
  83347. /**
  83348. * Get the number of data values you will have to play with for the visualization
  83349. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  83350. * @returns a number
  83351. */
  83352. getFrequencyBinCount(): number;
  83353. /**
  83354. * Gets the current frequency data as a byte array
  83355. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83356. * @returns a Uint8Array
  83357. */
  83358. getByteFrequencyData(): Uint8Array;
  83359. /**
  83360. * Gets the current waveform as a byte array
  83361. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  83362. * @returns a Uint8Array
  83363. */
  83364. getByteTimeDomainData(): Uint8Array;
  83365. /**
  83366. * Gets the current frequency data as a float array
  83367. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  83368. * @returns a Float32Array
  83369. */
  83370. getFloatFrequencyData(): Float32Array;
  83371. /**
  83372. * Renders the debug canvas
  83373. */
  83374. drawDebugCanvas(): void;
  83375. /**
  83376. * Stops rendering the debug canvas and removes it
  83377. */
  83378. stopDebugCanvas(): void;
  83379. /**
  83380. * Connects two audio nodes
  83381. * @param inputAudioNode defines first node to connect
  83382. * @param outputAudioNode defines second node to connect
  83383. */
  83384. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  83385. /**
  83386. * Releases all associated resources
  83387. */
  83388. dispose(): void;
  83389. }
  83390. }
  83391. declare module BABYLON {
  83392. /**
  83393. * This represents an audio engine and it is responsible
  83394. * to play, synchronize and analyse sounds throughout the application.
  83395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83396. */
  83397. export interface IAudioEngine extends IDisposable {
  83398. /**
  83399. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83400. */
  83401. readonly canUseWebAudio: boolean;
  83402. /**
  83403. * Gets the current AudioContext if available.
  83404. */
  83405. readonly audioContext: Nullable<AudioContext>;
  83406. /**
  83407. * The master gain node defines the global audio volume of your audio engine.
  83408. */
  83409. readonly masterGain: GainNode;
  83410. /**
  83411. * Gets whether or not mp3 are supported by your browser.
  83412. */
  83413. readonly isMP3supported: boolean;
  83414. /**
  83415. * Gets whether or not ogg are supported by your browser.
  83416. */
  83417. readonly isOGGsupported: boolean;
  83418. /**
  83419. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83420. * @ignoreNaming
  83421. */
  83422. WarnedWebAudioUnsupported: boolean;
  83423. /**
  83424. * Defines if the audio engine relies on a custom unlocked button.
  83425. * In this case, the embedded button will not be displayed.
  83426. */
  83427. useCustomUnlockedButton: boolean;
  83428. /**
  83429. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  83430. */
  83431. readonly unlocked: boolean;
  83432. /**
  83433. * Event raised when audio has been unlocked on the browser.
  83434. */
  83435. onAudioUnlockedObservable: Observable<AudioEngine>;
  83436. /**
  83437. * Event raised when audio has been locked on the browser.
  83438. */
  83439. onAudioLockedObservable: Observable<AudioEngine>;
  83440. /**
  83441. * Flags the audio engine in Locked state.
  83442. * This happens due to new browser policies preventing audio to autoplay.
  83443. */
  83444. lock(): void;
  83445. /**
  83446. * Unlocks the audio engine once a user action has been done on the dom.
  83447. * This is helpful to resume play once browser policies have been satisfied.
  83448. */
  83449. unlock(): void;
  83450. }
  83451. /**
  83452. * This represents the default audio engine used in babylon.
  83453. * It is responsible to play, synchronize and analyse sounds throughout the application.
  83454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83455. */
  83456. export class AudioEngine implements IAudioEngine {
  83457. private _audioContext;
  83458. private _audioContextInitialized;
  83459. private _muteButton;
  83460. private _hostElement;
  83461. /**
  83462. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  83463. */
  83464. canUseWebAudio: boolean;
  83465. /**
  83466. * The master gain node defines the global audio volume of your audio engine.
  83467. */
  83468. masterGain: GainNode;
  83469. /**
  83470. * Defines if Babylon should emit a warning if WebAudio is not supported.
  83471. * @ignoreNaming
  83472. */
  83473. WarnedWebAudioUnsupported: boolean;
  83474. /**
  83475. * Gets whether or not mp3 are supported by your browser.
  83476. */
  83477. isMP3supported: boolean;
  83478. /**
  83479. * Gets whether or not ogg are supported by your browser.
  83480. */
  83481. isOGGsupported: boolean;
  83482. /**
  83483. * Gets whether audio has been unlocked on the device.
  83484. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  83485. * a user interaction has happened.
  83486. */
  83487. unlocked: boolean;
  83488. /**
  83489. * Defines if the audio engine relies on a custom unlocked button.
  83490. * In this case, the embedded button will not be displayed.
  83491. */
  83492. useCustomUnlockedButton: boolean;
  83493. /**
  83494. * Event raised when audio has been unlocked on the browser.
  83495. */
  83496. onAudioUnlockedObservable: Observable<AudioEngine>;
  83497. /**
  83498. * Event raised when audio has been locked on the browser.
  83499. */
  83500. onAudioLockedObservable: Observable<AudioEngine>;
  83501. /**
  83502. * Gets the current AudioContext if available.
  83503. */
  83504. readonly audioContext: Nullable<AudioContext>;
  83505. private _connectedAnalyser;
  83506. /**
  83507. * Instantiates a new audio engine.
  83508. *
  83509. * There should be only one per page as some browsers restrict the number
  83510. * of audio contexts you can create.
  83511. * @param hostElement defines the host element where to display the mute icon if necessary
  83512. */
  83513. constructor(hostElement?: Nullable<HTMLElement>);
  83514. /**
  83515. * Flags the audio engine in Locked state.
  83516. * This happens due to new browser policies preventing audio to autoplay.
  83517. */
  83518. lock(): void;
  83519. /**
  83520. * Unlocks the audio engine once a user action has been done on the dom.
  83521. * This is helpful to resume play once browser policies have been satisfied.
  83522. */
  83523. unlock(): void;
  83524. private _resumeAudioContext;
  83525. private _initializeAudioContext;
  83526. private _tryToRun;
  83527. private _triggerRunningState;
  83528. private _triggerSuspendedState;
  83529. private _displayMuteButton;
  83530. private _moveButtonToTopLeft;
  83531. private _onResize;
  83532. private _hideMuteButton;
  83533. /**
  83534. * Destroy and release the resources associated with the audio ccontext.
  83535. */
  83536. dispose(): void;
  83537. /**
  83538. * Gets the global volume sets on the master gain.
  83539. * @returns the global volume if set or -1 otherwise
  83540. */
  83541. getGlobalVolume(): number;
  83542. /**
  83543. * Sets the global volume of your experience (sets on the master gain).
  83544. * @param newVolume Defines the new global volume of the application
  83545. */
  83546. setGlobalVolume(newVolume: number): void;
  83547. /**
  83548. * Connect the audio engine to an audio analyser allowing some amazing
  83549. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  83550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  83551. * @param analyser The analyser to connect to the engine
  83552. */
  83553. connectToAnalyser(analyser: Analyser): void;
  83554. }
  83555. }
  83556. declare module BABYLON {
  83557. /**
  83558. * Interface used to present a loading screen while loading a scene
  83559. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83560. */
  83561. export interface ILoadingScreen {
  83562. /**
  83563. * Function called to display the loading screen
  83564. */
  83565. displayLoadingUI: () => void;
  83566. /**
  83567. * Function called to hide the loading screen
  83568. */
  83569. hideLoadingUI: () => void;
  83570. /**
  83571. * Gets or sets the color to use for the background
  83572. */
  83573. loadingUIBackgroundColor: string;
  83574. /**
  83575. * Gets or sets the text to display while loading
  83576. */
  83577. loadingUIText: string;
  83578. }
  83579. /**
  83580. * Class used for the default loading screen
  83581. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  83582. */
  83583. export class DefaultLoadingScreen implements ILoadingScreen {
  83584. private _renderingCanvas;
  83585. private _loadingText;
  83586. private _loadingDivBackgroundColor;
  83587. private _loadingDiv;
  83588. private _loadingTextDiv;
  83589. /**
  83590. * Creates a new default loading screen
  83591. * @param _renderingCanvas defines the canvas used to render the scene
  83592. * @param _loadingText defines the default text to display
  83593. * @param _loadingDivBackgroundColor defines the default background color
  83594. */
  83595. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  83596. /**
  83597. * Function called to display the loading screen
  83598. */
  83599. displayLoadingUI(): void;
  83600. /**
  83601. * Function called to hide the loading screen
  83602. */
  83603. hideLoadingUI(): void;
  83604. /**
  83605. * Gets or sets the text to display while loading
  83606. */
  83607. loadingUIText: string;
  83608. /**
  83609. * Gets or sets the color to use for the background
  83610. */
  83611. loadingUIBackgroundColor: string;
  83612. private _resizeLoadingUI;
  83613. }
  83614. }
  83615. declare module BABYLON {
  83616. /**
  83617. * Settings for finer control over video usage
  83618. */
  83619. export interface VideoTextureSettings {
  83620. /**
  83621. * Applies `autoplay` to video, if specified
  83622. */
  83623. autoPlay?: boolean;
  83624. /**
  83625. * Applies `loop` to video, if specified
  83626. */
  83627. loop?: boolean;
  83628. /**
  83629. * Automatically updates internal texture from video at every frame in the render loop
  83630. */
  83631. autoUpdateTexture: boolean;
  83632. /**
  83633. * Image src displayed during the video loading or until the user interacts with the video.
  83634. */
  83635. poster?: string;
  83636. }
  83637. /**
  83638. * If you want to display a video in your scene, this is the special texture for that.
  83639. * This special texture works similar to other textures, with the exception of a few parameters.
  83640. * @see https://doc.babylonjs.com/how_to/video_texture
  83641. */
  83642. export class VideoTexture extends Texture {
  83643. /**
  83644. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  83645. */
  83646. readonly autoUpdateTexture: boolean;
  83647. /**
  83648. * The video instance used by the texture internally
  83649. */
  83650. readonly video: HTMLVideoElement;
  83651. private _onUserActionRequestedObservable;
  83652. /**
  83653. * Event triggerd when a dom action is required by the user to play the video.
  83654. * This happens due to recent changes in browser policies preventing video to auto start.
  83655. */
  83656. readonly onUserActionRequestedObservable: Observable<Texture>;
  83657. private _generateMipMaps;
  83658. private _engine;
  83659. private _stillImageCaptured;
  83660. private _displayingPosterTexture;
  83661. private _settings;
  83662. private _createInternalTextureOnEvent;
  83663. /**
  83664. * Creates a video texture.
  83665. * If you want to display a video in your scene, this is the special texture for that.
  83666. * This special texture works similar to other textures, with the exception of a few parameters.
  83667. * @see https://doc.babylonjs.com/how_to/video_texture
  83668. * @param name optional name, will detect from video source, if not defined
  83669. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  83670. * @param scene is obviously the current scene.
  83671. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  83672. * @param invertY is false by default but can be used to invert video on Y axis
  83673. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  83674. * @param settings allows finer control over video usage
  83675. */
  83676. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  83677. private _getName;
  83678. private _getVideo;
  83679. private _createInternalTexture;
  83680. private reset;
  83681. /**
  83682. * @hidden Internal method to initiate `update`.
  83683. */
  83684. _rebuild(): void;
  83685. /**
  83686. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  83687. */
  83688. update(): void;
  83689. /**
  83690. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  83691. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  83692. */
  83693. updateTexture(isVisible: boolean): void;
  83694. protected _updateInternalTexture: () => void;
  83695. /**
  83696. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  83697. * @param url New url.
  83698. */
  83699. updateURL(url: string): void;
  83700. /**
  83701. * Dispose the texture and release its associated resources.
  83702. */
  83703. dispose(): void;
  83704. /**
  83705. * Creates a video texture straight from a stream.
  83706. * @param scene Define the scene the texture should be created in
  83707. * @param stream Define the stream the texture should be created from
  83708. * @returns The created video texture as a promise
  83709. */
  83710. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  83711. /**
  83712. * Creates a video texture straight from your WebCam video feed.
  83713. * @param scene Define the scene the texture should be created in
  83714. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83715. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83716. * @returns The created video texture as a promise
  83717. */
  83718. static CreateFromWebCamAsync(scene: Scene, constraints: {
  83719. minWidth: number;
  83720. maxWidth: number;
  83721. minHeight: number;
  83722. maxHeight: number;
  83723. deviceId: string;
  83724. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  83725. /**
  83726. * Creates a video texture straight from your WebCam video feed.
  83727. * @param scene Define the scene the texture should be created in
  83728. * @param onReady Define a callback to triggered once the texture will be ready
  83729. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  83730. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  83731. */
  83732. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  83733. minWidth: number;
  83734. maxWidth: number;
  83735. minHeight: number;
  83736. maxHeight: number;
  83737. deviceId: string;
  83738. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  83739. }
  83740. }
  83741. declare module BABYLON {
  83742. /**
  83743. * Interface for attribute information associated with buffer instanciation
  83744. */
  83745. export class InstancingAttributeInfo {
  83746. /**
  83747. * Index/offset of the attribute in the vertex shader
  83748. */
  83749. index: number;
  83750. /**
  83751. * size of the attribute, 1, 2, 3 or 4
  83752. */
  83753. attributeSize: number;
  83754. /**
  83755. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  83756. * default is FLOAT
  83757. */
  83758. attribyteType: number;
  83759. /**
  83760. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  83761. */
  83762. normalized: boolean;
  83763. /**
  83764. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  83765. */
  83766. offset: number;
  83767. /**
  83768. * Name of the GLSL attribute, for debugging purpose only
  83769. */
  83770. attributeName: string;
  83771. }
  83772. /**
  83773. * Define options used to create a depth texture
  83774. */
  83775. export class DepthTextureCreationOptions {
  83776. /** Specifies whether or not a stencil should be allocated in the texture */
  83777. generateStencil?: boolean;
  83778. /** Specifies whether or not bilinear filtering is enable on the texture */
  83779. bilinearFiltering?: boolean;
  83780. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  83781. comparisonFunction?: number;
  83782. /** Specifies if the created texture is a cube texture */
  83783. isCube?: boolean;
  83784. }
  83785. /**
  83786. * Class used to describe the capabilities of the engine relatively to the current browser
  83787. */
  83788. export class EngineCapabilities {
  83789. /** Maximum textures units per fragment shader */
  83790. maxTexturesImageUnits: number;
  83791. /** Maximum texture units per vertex shader */
  83792. maxVertexTextureImageUnits: number;
  83793. /** Maximum textures units in the entire pipeline */
  83794. maxCombinedTexturesImageUnits: number;
  83795. /** Maximum texture size */
  83796. maxTextureSize: number;
  83797. /** Maximum cube texture size */
  83798. maxCubemapTextureSize: number;
  83799. /** Maximum render texture size */
  83800. maxRenderTextureSize: number;
  83801. /** Maximum number of vertex attributes */
  83802. maxVertexAttribs: number;
  83803. /** Maximum number of varyings */
  83804. maxVaryingVectors: number;
  83805. /** Maximum number of uniforms per vertex shader */
  83806. maxVertexUniformVectors: number;
  83807. /** Maximum number of uniforms per fragment shader */
  83808. maxFragmentUniformVectors: number;
  83809. /** Defines if standard derivates (dx/dy) are supported */
  83810. standardDerivatives: boolean;
  83811. /** Defines if s3tc texture compression is supported */
  83812. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  83813. /** Defines if pvrtc texture compression is supported */
  83814. pvrtc: any;
  83815. /** Defines if etc1 texture compression is supported */
  83816. etc1: any;
  83817. /** Defines if etc2 texture compression is supported */
  83818. etc2: any;
  83819. /** Defines if astc texture compression is supported */
  83820. astc: any;
  83821. /** Defines if float textures are supported */
  83822. textureFloat: boolean;
  83823. /** Defines if vertex array objects are supported */
  83824. vertexArrayObject: boolean;
  83825. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  83826. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  83827. /** Gets the maximum level of anisotropy supported */
  83828. maxAnisotropy: number;
  83829. /** Defines if instancing is supported */
  83830. instancedArrays: boolean;
  83831. /** Defines if 32 bits indices are supported */
  83832. uintIndices: boolean;
  83833. /** Defines if high precision shaders are supported */
  83834. highPrecisionShaderSupported: boolean;
  83835. /** Defines if depth reading in the fragment shader is supported */
  83836. fragmentDepthSupported: boolean;
  83837. /** Defines if float texture linear filtering is supported*/
  83838. textureFloatLinearFiltering: boolean;
  83839. /** Defines if rendering to float textures is supported */
  83840. textureFloatRender: boolean;
  83841. /** Defines if half float textures are supported*/
  83842. textureHalfFloat: boolean;
  83843. /** Defines if half float texture linear filtering is supported*/
  83844. textureHalfFloatLinearFiltering: boolean;
  83845. /** Defines if rendering to half float textures is supported */
  83846. textureHalfFloatRender: boolean;
  83847. /** Defines if textureLOD shader command is supported */
  83848. textureLOD: boolean;
  83849. /** Defines if draw buffers extension is supported */
  83850. drawBuffersExtension: boolean;
  83851. /** Defines if depth textures are supported */
  83852. depthTextureExtension: boolean;
  83853. /** Defines if float color buffer are supported */
  83854. colorBufferFloat: boolean;
  83855. /** Gets disjoint timer query extension (null if not supported) */
  83856. timerQuery: EXT_disjoint_timer_query;
  83857. /** Defines if timestamp can be used with timer query */
  83858. canUseTimestampForTimerQuery: boolean;
  83859. /** Function used to let the system compiles shaders in background */
  83860. parallelShaderCompile: {
  83861. MAX_SHADER_COMPILER_THREADS_KHR: number;
  83862. maxShaderCompilerThreadsKHR: (thread: number) => void;
  83863. COMPLETION_STATUS_KHR: number;
  83864. };
  83865. }
  83866. /** Interface defining initialization parameters for Engine class */
  83867. export interface EngineOptions extends WebGLContextAttributes {
  83868. /**
  83869. * Defines if the engine should no exceed a specified device ratio
  83870. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  83871. */
  83872. limitDeviceRatio?: number;
  83873. /**
  83874. * Defines if webvr should be enabled automatically
  83875. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83876. */
  83877. autoEnableWebVR?: boolean;
  83878. /**
  83879. * Defines if webgl2 should be turned off even if supported
  83880. * @see http://doc.babylonjs.com/features/webgl2
  83881. */
  83882. disableWebGL2Support?: boolean;
  83883. /**
  83884. * Defines if webaudio should be initialized as well
  83885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  83886. */
  83887. audioEngine?: boolean;
  83888. /**
  83889. * Defines if animations should run using a deterministic lock step
  83890. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83891. */
  83892. deterministicLockstep?: boolean;
  83893. /** Defines the maximum steps to use with deterministic lock step mode */
  83894. lockstepMaxSteps?: number;
  83895. /**
  83896. * Defines that engine should ignore context lost events
  83897. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  83898. */
  83899. doNotHandleContextLost?: boolean;
  83900. /**
  83901. * Defines that engine should ignore modifying touch action attribute and style
  83902. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  83903. */
  83904. doNotHandleTouchAction?: boolean;
  83905. }
  83906. /**
  83907. * Defines the interface used by display changed events
  83908. */
  83909. export interface IDisplayChangedEventArgs {
  83910. /** Gets the vrDisplay object (if any) */
  83911. vrDisplay: Nullable<any>;
  83912. /** Gets a boolean indicating if webVR is supported */
  83913. vrSupported: boolean;
  83914. }
  83915. /**
  83916. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  83917. */
  83918. export class Engine {
  83919. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  83920. static ExceptionList: ({
  83921. key: string;
  83922. capture: string;
  83923. captureConstraint: number;
  83924. targets: string[];
  83925. } | {
  83926. key: string;
  83927. capture: null;
  83928. captureConstraint: null;
  83929. targets: string[];
  83930. })[];
  83931. /** Gets the list of created engines */
  83932. static readonly Instances: Engine[];
  83933. /**
  83934. * Gets the latest created engine
  83935. */
  83936. static readonly LastCreatedEngine: Nullable<Engine>;
  83937. /**
  83938. * Gets the latest created scene
  83939. */
  83940. static readonly LastCreatedScene: Nullable<Scene>;
  83941. /**
  83942. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  83943. * @param flag defines which part of the materials must be marked as dirty
  83944. * @param predicate defines a predicate used to filter which materials should be affected
  83945. */
  83946. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  83947. /**
  83948. * Hidden
  83949. */
  83950. static _TextureLoaders: IInternalTextureLoader[];
  83951. /** Defines that alpha blending is disabled */
  83952. static readonly ALPHA_DISABLE: number;
  83953. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  83954. static readonly ALPHA_ADD: number;
  83955. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  83956. static readonly ALPHA_COMBINE: number;
  83957. /** Defines that alpha blending to DEST - SRC * DEST */
  83958. static readonly ALPHA_SUBTRACT: number;
  83959. /** Defines that alpha blending to SRC * DEST */
  83960. static readonly ALPHA_MULTIPLY: number;
  83961. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  83962. static readonly ALPHA_MAXIMIZED: number;
  83963. /** Defines that alpha blending to SRC + DEST */
  83964. static readonly ALPHA_ONEONE: number;
  83965. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  83966. static readonly ALPHA_PREMULTIPLIED: number;
  83967. /**
  83968. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  83969. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  83970. */
  83971. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  83972. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  83973. static readonly ALPHA_INTERPOLATE: number;
  83974. /**
  83975. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  83976. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  83977. */
  83978. static readonly ALPHA_SCREENMODE: number;
  83979. /** Defines that the ressource is not delayed*/
  83980. static readonly DELAYLOADSTATE_NONE: number;
  83981. /** Defines that the ressource was successfully delay loaded */
  83982. static readonly DELAYLOADSTATE_LOADED: number;
  83983. /** Defines that the ressource is currently delay loading */
  83984. static readonly DELAYLOADSTATE_LOADING: number;
  83985. /** Defines that the ressource is delayed and has not started loading */
  83986. static readonly DELAYLOADSTATE_NOTLOADED: number;
  83987. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  83988. static readonly NEVER: number;
  83989. /** 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 */
  83990. static readonly ALWAYS: number;
  83991. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  83992. static readonly LESS: number;
  83993. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  83994. static readonly EQUAL: number;
  83995. /** 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 */
  83996. static readonly LEQUAL: number;
  83997. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  83998. static readonly GREATER: number;
  83999. /** 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 */
  84000. static readonly GEQUAL: number;
  84001. /** 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 */
  84002. static readonly NOTEQUAL: number;
  84003. /** Passed to stencilOperation to specify that stencil value must be kept */
  84004. static readonly KEEP: number;
  84005. /** Passed to stencilOperation to specify that stencil value must be replaced */
  84006. static readonly REPLACE: number;
  84007. /** Passed to stencilOperation to specify that stencil value must be incremented */
  84008. static readonly INCR: number;
  84009. /** Passed to stencilOperation to specify that stencil value must be decremented */
  84010. static readonly DECR: number;
  84011. /** Passed to stencilOperation to specify that stencil value must be inverted */
  84012. static readonly INVERT: number;
  84013. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  84014. static readonly INCR_WRAP: number;
  84015. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  84016. static readonly DECR_WRAP: number;
  84017. /** Texture is not repeating outside of 0..1 UVs */
  84018. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  84019. /** Texture is repeating outside of 0..1 UVs */
  84020. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  84021. /** Texture is repeating and mirrored */
  84022. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  84023. /** ALPHA */
  84024. static readonly TEXTUREFORMAT_ALPHA: number;
  84025. /** LUMINANCE */
  84026. static readonly TEXTUREFORMAT_LUMINANCE: number;
  84027. /** LUMINANCE_ALPHA */
  84028. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  84029. /** RGB */
  84030. static readonly TEXTUREFORMAT_RGB: number;
  84031. /** RGBA */
  84032. static readonly TEXTUREFORMAT_RGBA: number;
  84033. /** RED */
  84034. static readonly TEXTUREFORMAT_RED: number;
  84035. /** RED (2nd reference) */
  84036. static readonly TEXTUREFORMAT_R: number;
  84037. /** RG */
  84038. static readonly TEXTUREFORMAT_RG: number;
  84039. /** RED_INTEGER */
  84040. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  84041. /** RED_INTEGER (2nd reference) */
  84042. static readonly TEXTUREFORMAT_R_INTEGER: number;
  84043. /** RG_INTEGER */
  84044. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  84045. /** RGB_INTEGER */
  84046. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  84047. /** RGBA_INTEGER */
  84048. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  84049. /** UNSIGNED_BYTE */
  84050. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  84051. /** UNSIGNED_BYTE (2nd reference) */
  84052. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  84053. /** FLOAT */
  84054. static readonly TEXTURETYPE_FLOAT: number;
  84055. /** HALF_FLOAT */
  84056. static readonly TEXTURETYPE_HALF_FLOAT: number;
  84057. /** BYTE */
  84058. static readonly TEXTURETYPE_BYTE: number;
  84059. /** SHORT */
  84060. static readonly TEXTURETYPE_SHORT: number;
  84061. /** UNSIGNED_SHORT */
  84062. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  84063. /** INT */
  84064. static readonly TEXTURETYPE_INT: number;
  84065. /** UNSIGNED_INT */
  84066. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  84067. /** UNSIGNED_SHORT_4_4_4_4 */
  84068. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  84069. /** UNSIGNED_SHORT_5_5_5_1 */
  84070. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  84071. /** UNSIGNED_SHORT_5_6_5 */
  84072. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  84073. /** UNSIGNED_INT_2_10_10_10_REV */
  84074. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  84075. /** UNSIGNED_INT_24_8 */
  84076. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  84077. /** UNSIGNED_INT_10F_11F_11F_REV */
  84078. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  84079. /** UNSIGNED_INT_5_9_9_9_REV */
  84080. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  84081. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  84082. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  84083. /** nearest is mag = nearest and min = nearest and mip = linear */
  84084. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  84085. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84086. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  84087. /** Trilinear is mag = linear and min = linear and mip = linear */
  84088. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  84089. /** nearest is mag = nearest and min = nearest and mip = linear */
  84090. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  84091. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84092. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  84093. /** Trilinear is mag = linear and min = linear and mip = linear */
  84094. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  84095. /** mag = nearest and min = nearest and mip = nearest */
  84096. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  84097. /** mag = nearest and min = linear and mip = nearest */
  84098. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  84099. /** mag = nearest and min = linear and mip = linear */
  84100. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  84101. /** mag = nearest and min = linear and mip = none */
  84102. static readonly TEXTURE_NEAREST_LINEAR: number;
  84103. /** mag = nearest and min = nearest and mip = none */
  84104. static readonly TEXTURE_NEAREST_NEAREST: number;
  84105. /** mag = linear and min = nearest and mip = nearest */
  84106. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  84107. /** mag = linear and min = nearest and mip = linear */
  84108. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  84109. /** mag = linear and min = linear and mip = none */
  84110. static readonly TEXTURE_LINEAR_LINEAR: number;
  84111. /** mag = linear and min = nearest and mip = none */
  84112. static readonly TEXTURE_LINEAR_NEAREST: number;
  84113. /** Explicit coordinates mode */
  84114. static readonly TEXTURE_EXPLICIT_MODE: number;
  84115. /** Spherical coordinates mode */
  84116. static readonly TEXTURE_SPHERICAL_MODE: number;
  84117. /** Planar coordinates mode */
  84118. static readonly TEXTURE_PLANAR_MODE: number;
  84119. /** Cubic coordinates mode */
  84120. static readonly TEXTURE_CUBIC_MODE: number;
  84121. /** Projection coordinates mode */
  84122. static readonly TEXTURE_PROJECTION_MODE: number;
  84123. /** Skybox coordinates mode */
  84124. static readonly TEXTURE_SKYBOX_MODE: number;
  84125. /** Inverse Cubic coordinates mode */
  84126. static readonly TEXTURE_INVCUBIC_MODE: number;
  84127. /** Equirectangular coordinates mode */
  84128. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  84129. /** Equirectangular Fixed coordinates mode */
  84130. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  84131. /** Equirectangular Fixed Mirrored coordinates mode */
  84132. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84133. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  84134. static readonly SCALEMODE_FLOOR: number;
  84135. /** Defines that texture rescaling will look for the nearest power of 2 size */
  84136. static readonly SCALEMODE_NEAREST: number;
  84137. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  84138. static readonly SCALEMODE_CEILING: number;
  84139. /**
  84140. * Returns the current version of the framework
  84141. */
  84142. static readonly Version: string;
  84143. /**
  84144. * Returns a string describing the current engine
  84145. */
  84146. readonly description: string;
  84147. /**
  84148. * Gets or sets the epsilon value used by collision engine
  84149. */
  84150. static CollisionsEpsilon: number;
  84151. /**
  84152. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84153. */
  84154. static ShadersRepository: string;
  84155. /**
  84156. * Method called to create the default loading screen.
  84157. * This can be overriden in your own app.
  84158. * @param canvas The rendering canvas element
  84159. * @returns The loading screen
  84160. */
  84161. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  84162. /**
  84163. * Method called to create the default rescale post process on each engine.
  84164. */
  84165. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  84166. /**
  84167. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  84168. */
  84169. forcePOTTextures: boolean;
  84170. /**
  84171. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  84172. */
  84173. isFullscreen: boolean;
  84174. /**
  84175. * Gets a boolean indicating if the pointer is currently locked
  84176. */
  84177. isPointerLock: boolean;
  84178. /**
  84179. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  84180. */
  84181. cullBackFaces: boolean;
  84182. /**
  84183. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  84184. */
  84185. renderEvenInBackground: boolean;
  84186. /**
  84187. * Gets or sets a boolean indicating that cache can be kept between frames
  84188. */
  84189. preventCacheWipeBetweenFrames: boolean;
  84190. /**
  84191. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  84192. **/
  84193. enableOfflineSupport: boolean;
  84194. /**
  84195. * 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)
  84196. **/
  84197. disableManifestCheck: boolean;
  84198. /**
  84199. * Gets the list of created scenes
  84200. */
  84201. scenes: Scene[];
  84202. /**
  84203. * Event raised when a new scene is created
  84204. */
  84205. onNewSceneAddedObservable: Observable<Scene>;
  84206. /**
  84207. * Gets the list of created postprocesses
  84208. */
  84209. postProcesses: PostProcess[];
  84210. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  84211. validateShaderPrograms: boolean;
  84212. /**
  84213. * Observable event triggered each time the rendering canvas is resized
  84214. */
  84215. onResizeObservable: Observable<Engine>;
  84216. /**
  84217. * Observable event triggered each time the canvas loses focus
  84218. */
  84219. onCanvasBlurObservable: Observable<Engine>;
  84220. /**
  84221. * Observable event triggered each time the canvas gains focus
  84222. */
  84223. onCanvasFocusObservable: Observable<Engine>;
  84224. /**
  84225. * Observable event triggered each time the canvas receives pointerout event
  84226. */
  84227. onCanvasPointerOutObservable: Observable<PointerEvent>;
  84228. /**
  84229. * Observable event triggered before each texture is initialized
  84230. */
  84231. onBeforeTextureInitObservable: Observable<Texture>;
  84232. private _vrDisplay;
  84233. private _vrSupported;
  84234. private _oldSize;
  84235. private _oldHardwareScaleFactor;
  84236. private _vrExclusivePointerMode;
  84237. private _webVRInitPromise;
  84238. /**
  84239. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84240. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84241. */
  84242. readonly isInVRExclusivePointerMode: boolean;
  84243. /**
  84244. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  84245. */
  84246. disableUniformBuffers: boolean;
  84247. /** @hidden */
  84248. _uniformBuffers: UniformBuffer[];
  84249. /**
  84250. * Gets a boolean indicating that the engine supports uniform buffers
  84251. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84252. */
  84253. readonly supportsUniformBuffers: boolean;
  84254. /**
  84255. * Observable raised when the engine begins a new frame
  84256. */
  84257. onBeginFrameObservable: Observable<Engine>;
  84258. /**
  84259. * If set, will be used to request the next animation frame for the render loop
  84260. */
  84261. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  84262. /**
  84263. * Observable raised when the engine ends the current frame
  84264. */
  84265. onEndFrameObservable: Observable<Engine>;
  84266. /**
  84267. * Observable raised when the engine is about to compile a shader
  84268. */
  84269. onBeforeShaderCompilationObservable: Observable<Engine>;
  84270. /**
  84271. * Observable raised when the engine has jsut compiled a shader
  84272. */
  84273. onAfterShaderCompilationObservable: Observable<Engine>;
  84274. /** @hidden */
  84275. _gl: WebGLRenderingContext;
  84276. private _renderingCanvas;
  84277. private _windowIsBackground;
  84278. private _webGLVersion;
  84279. /**
  84280. * Gets a boolean indicating that only power of 2 textures are supported
  84281. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  84282. */
  84283. readonly needPOTTextures: boolean;
  84284. /** @hidden */
  84285. _badOS: boolean;
  84286. /** @hidden */
  84287. _badDesktopOS: boolean;
  84288. /**
  84289. * Gets or sets a value indicating if we want to disable texture binding optimization.
  84290. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  84291. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  84292. */
  84293. disableTextureBindingOptimization: boolean;
  84294. /**
  84295. * Gets the audio engine
  84296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84297. * @ignorenaming
  84298. */
  84299. static audioEngine: IAudioEngine;
  84300. /**
  84301. * Default AudioEngine factory responsible of creating the Audio Engine.
  84302. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  84303. */
  84304. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  84305. /**
  84306. * Default offline support factory responsible of creating a tool used to store data locally.
  84307. * By default, this will create a Database object if the workload has been embedded.
  84308. */
  84309. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  84310. private _onFocus;
  84311. private _onBlur;
  84312. private _onCanvasPointerOut;
  84313. private _onCanvasBlur;
  84314. private _onCanvasFocus;
  84315. private _onFullscreenChange;
  84316. private _onPointerLockChange;
  84317. private _onVRDisplayPointerRestricted;
  84318. private _onVRDisplayPointerUnrestricted;
  84319. private _onVrDisplayConnect;
  84320. private _onVrDisplayDisconnect;
  84321. private _onVrDisplayPresentChange;
  84322. /**
  84323. * Observable signaled when VR display mode changes
  84324. */
  84325. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84326. /**
  84327. * Observable signaled when VR request present is complete
  84328. */
  84329. onVRRequestPresentComplete: Observable<boolean>;
  84330. /**
  84331. * Observable signaled when VR request present starts
  84332. */
  84333. onVRRequestPresentStart: Observable<Engine>;
  84334. private _hardwareScalingLevel;
  84335. /** @hidden */
  84336. protected _caps: EngineCapabilities;
  84337. private _pointerLockRequested;
  84338. private _isStencilEnable;
  84339. private _colorWrite;
  84340. private _loadingScreen;
  84341. /** @hidden */
  84342. _drawCalls: PerfCounter;
  84343. /** @hidden */
  84344. _textureCollisions: PerfCounter;
  84345. private _glVersion;
  84346. private _glRenderer;
  84347. private _glVendor;
  84348. private _videoTextureSupported;
  84349. private _renderingQueueLaunched;
  84350. private _activeRenderLoops;
  84351. private _deterministicLockstep;
  84352. private _lockstepMaxSteps;
  84353. /**
  84354. * Observable signaled when a context lost event is raised
  84355. */
  84356. onContextLostObservable: Observable<Engine>;
  84357. /**
  84358. * Observable signaled when a context restored event is raised
  84359. */
  84360. onContextRestoredObservable: Observable<Engine>;
  84361. private _onContextLost;
  84362. private _onContextRestored;
  84363. private _contextWasLost;
  84364. private _doNotHandleContextLost;
  84365. /**
  84366. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  84367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  84368. */
  84369. doNotHandleContextLost: boolean;
  84370. private _performanceMonitor;
  84371. private _fps;
  84372. private _deltaTime;
  84373. /**
  84374. * Turn this value on if you want to pause FPS computation when in background
  84375. */
  84376. disablePerformanceMonitorInBackground: boolean;
  84377. /**
  84378. * Gets the performance monitor attached to this engine
  84379. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  84380. */
  84381. readonly performanceMonitor: PerformanceMonitor;
  84382. /** @hidden */
  84383. protected _depthCullingState: _DepthCullingState;
  84384. /** @hidden */
  84385. protected _stencilState: _StencilState;
  84386. /** @hidden */
  84387. protected _alphaState: _AlphaState;
  84388. /** @hidden */
  84389. protected _alphaMode: number;
  84390. protected _internalTexturesCache: InternalTexture[];
  84391. /** @hidden */
  84392. protected _activeChannel: number;
  84393. private _currentTextureChannel;
  84394. /** @hidden */
  84395. protected _boundTexturesCache: {
  84396. [key: string]: Nullable<InternalTexture>;
  84397. };
  84398. /** @hidden */
  84399. protected _currentEffect: Nullable<Effect>;
  84400. /** @hidden */
  84401. protected _currentProgram: Nullable<WebGLProgram>;
  84402. private _compiledEffects;
  84403. private _vertexAttribArraysEnabled;
  84404. /** @hidden */
  84405. protected _cachedViewport: Nullable<Viewport>;
  84406. private _cachedVertexArrayObject;
  84407. /** @hidden */
  84408. protected _cachedVertexBuffers: any;
  84409. /** @hidden */
  84410. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  84411. /** @hidden */
  84412. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  84413. /** @hidden */
  84414. protected _currentRenderTarget: Nullable<InternalTexture>;
  84415. private _uintIndicesCurrentlySet;
  84416. private _currentBoundBuffer;
  84417. /** @hidden */
  84418. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  84419. private _currentBufferPointers;
  84420. private _currentInstanceLocations;
  84421. private _currentInstanceBuffers;
  84422. private _textureUnits;
  84423. private _firstBoundInternalTextureTracker;
  84424. private _lastBoundInternalTextureTracker;
  84425. private _workingCanvas;
  84426. private _workingContext;
  84427. private _rescalePostProcess;
  84428. private _dummyFramebuffer;
  84429. private _externalData;
  84430. private _bindedRenderFunction;
  84431. private _vaoRecordInProgress;
  84432. private _mustWipeVertexAttributes;
  84433. private _emptyTexture;
  84434. private _emptyCubeTexture;
  84435. private _emptyTexture3D;
  84436. /** @hidden */
  84437. _frameHandler: number;
  84438. private _nextFreeTextureSlots;
  84439. private _maxSimultaneousTextures;
  84440. private _activeRequests;
  84441. private _texturesSupported;
  84442. private _textureFormatInUse;
  84443. /**
  84444. * Gets the list of texture formats supported
  84445. */
  84446. readonly texturesSupported: Array<string>;
  84447. /**
  84448. * Gets the list of texture formats in use
  84449. */
  84450. readonly textureFormatInUse: Nullable<string>;
  84451. /**
  84452. * Gets the current viewport
  84453. */
  84454. readonly currentViewport: Nullable<Viewport>;
  84455. /**
  84456. * Gets the default empty texture
  84457. */
  84458. readonly emptyTexture: InternalTexture;
  84459. /**
  84460. * Gets the default empty 3D texture
  84461. */
  84462. readonly emptyTexture3D: InternalTexture;
  84463. /**
  84464. * Gets the default empty cube texture
  84465. */
  84466. readonly emptyCubeTexture: InternalTexture;
  84467. /**
  84468. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  84469. */
  84470. readonly premultipliedAlpha: boolean;
  84471. /**
  84472. * Creates a new engine
  84473. * @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
  84474. * @param antialias defines enable antialiasing (default: false)
  84475. * @param options defines further options to be sent to the getContext() function
  84476. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  84477. */
  84478. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  84479. private _disableTouchAction;
  84480. private _rebuildInternalTextures;
  84481. private _rebuildEffects;
  84482. /**
  84483. * Gets a boolean indicating if all created effects are ready
  84484. * @returns true if all effects are ready
  84485. */
  84486. areAllEffectsReady(): boolean;
  84487. private _rebuildBuffers;
  84488. private _initGLContext;
  84489. /**
  84490. * Gets version of the current webGL context
  84491. */
  84492. readonly webGLVersion: number;
  84493. /**
  84494. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  84495. */
  84496. readonly isStencilEnable: boolean;
  84497. private _prepareWorkingCanvas;
  84498. /**
  84499. * Reset the texture cache to empty state
  84500. */
  84501. resetTextureCache(): void;
  84502. /**
  84503. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  84504. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84505. * @returns true if engine is in deterministic lock step mode
  84506. */
  84507. isDeterministicLockStep(): boolean;
  84508. /**
  84509. * Gets the max steps when engine is running in deterministic lock step
  84510. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  84511. * @returns the max steps
  84512. */
  84513. getLockstepMaxSteps(): number;
  84514. /**
  84515. * Gets an object containing information about the current webGL context
  84516. * @returns an object containing the vender, the renderer and the version of the current webGL context
  84517. */
  84518. getGlInfo(): {
  84519. vendor: string;
  84520. renderer: string;
  84521. version: string;
  84522. };
  84523. /**
  84524. * Gets current aspect ratio
  84525. * @param camera defines the camera to use to get the aspect ratio
  84526. * @param useScreen defines if screen size must be used (or the current render target if any)
  84527. * @returns a number defining the aspect ratio
  84528. */
  84529. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  84530. /**
  84531. * Gets current screen aspect ratio
  84532. * @returns a number defining the aspect ratio
  84533. */
  84534. getScreenAspectRatio(): number;
  84535. /**
  84536. * Gets the current render width
  84537. * @param useScreen defines if screen size must be used (or the current render target if any)
  84538. * @returns a number defining the current render width
  84539. */
  84540. getRenderWidth(useScreen?: boolean): number;
  84541. /**
  84542. * Gets the current render height
  84543. * @param useScreen defines if screen size must be used (or the current render target if any)
  84544. * @returns a number defining the current render height
  84545. */
  84546. getRenderHeight(useScreen?: boolean): number;
  84547. /**
  84548. * Gets the HTML canvas attached with the current webGL context
  84549. * @returns a HTML canvas
  84550. */
  84551. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  84552. /**
  84553. * Gets the client rect of the HTML canvas attached with the current webGL context
  84554. * @returns a client rectanglee
  84555. */
  84556. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  84557. /**
  84558. * Defines the hardware scaling level.
  84559. * By default the hardware scaling level is computed from the window device ratio.
  84560. * 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.
  84561. * @param level defines the level to use
  84562. */
  84563. setHardwareScalingLevel(level: number): void;
  84564. /**
  84565. * Gets the current hardware scaling level.
  84566. * By default the hardware scaling level is computed from the window device ratio.
  84567. * 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.
  84568. * @returns a number indicating the current hardware scaling level
  84569. */
  84570. getHardwareScalingLevel(): number;
  84571. /**
  84572. * Gets the list of loaded textures
  84573. * @returns an array containing all loaded textures
  84574. */
  84575. getLoadedTexturesCache(): InternalTexture[];
  84576. /**
  84577. * Gets the object containing all engine capabilities
  84578. * @returns the EngineCapabilities object
  84579. */
  84580. getCaps(): EngineCapabilities;
  84581. /**
  84582. * Gets the current depth function
  84583. * @returns a number defining the depth function
  84584. */
  84585. getDepthFunction(): Nullable<number>;
  84586. /**
  84587. * Sets the current depth function
  84588. * @param depthFunc defines the function to use
  84589. */
  84590. setDepthFunction(depthFunc: number): void;
  84591. /**
  84592. * Sets the current depth function to GREATER
  84593. */
  84594. setDepthFunctionToGreater(): void;
  84595. /**
  84596. * Sets the current depth function to GEQUAL
  84597. */
  84598. setDepthFunctionToGreaterOrEqual(): void;
  84599. /**
  84600. * Sets the current depth function to LESS
  84601. */
  84602. setDepthFunctionToLess(): void;
  84603. /**
  84604. * Sets the current depth function to LEQUAL
  84605. */
  84606. setDepthFunctionToLessOrEqual(): void;
  84607. /**
  84608. * Gets a boolean indicating if stencil buffer is enabled
  84609. * @returns the current stencil buffer state
  84610. */
  84611. getStencilBuffer(): boolean;
  84612. /**
  84613. * Enable or disable the stencil buffer
  84614. * @param enable defines if the stencil buffer must be enabled or disabled
  84615. */
  84616. setStencilBuffer(enable: boolean): void;
  84617. /**
  84618. * Gets the current stencil mask
  84619. * @returns a number defining the new stencil mask to use
  84620. */
  84621. getStencilMask(): number;
  84622. /**
  84623. * Sets the current stencil mask
  84624. * @param mask defines the new stencil mask to use
  84625. */
  84626. setStencilMask(mask: number): void;
  84627. /**
  84628. * Gets the current stencil function
  84629. * @returns a number defining the stencil function to use
  84630. */
  84631. getStencilFunction(): number;
  84632. /**
  84633. * Gets the current stencil reference value
  84634. * @returns a number defining the stencil reference value to use
  84635. */
  84636. getStencilFunctionReference(): number;
  84637. /**
  84638. * Gets the current stencil mask
  84639. * @returns a number defining the stencil mask to use
  84640. */
  84641. getStencilFunctionMask(): number;
  84642. /**
  84643. * Sets the current stencil function
  84644. * @param stencilFunc defines the new stencil function to use
  84645. */
  84646. setStencilFunction(stencilFunc: number): void;
  84647. /**
  84648. * Sets the current stencil reference
  84649. * @param reference defines the new stencil reference to use
  84650. */
  84651. setStencilFunctionReference(reference: number): void;
  84652. /**
  84653. * Sets the current stencil mask
  84654. * @param mask defines the new stencil mask to use
  84655. */
  84656. setStencilFunctionMask(mask: number): void;
  84657. /**
  84658. * Gets the current stencil operation when stencil fails
  84659. * @returns a number defining stencil operation to use when stencil fails
  84660. */
  84661. getStencilOperationFail(): number;
  84662. /**
  84663. * Gets the current stencil operation when depth fails
  84664. * @returns a number defining stencil operation to use when depth fails
  84665. */
  84666. getStencilOperationDepthFail(): number;
  84667. /**
  84668. * Gets the current stencil operation when stencil passes
  84669. * @returns a number defining stencil operation to use when stencil passes
  84670. */
  84671. getStencilOperationPass(): number;
  84672. /**
  84673. * Sets the stencil operation to use when stencil fails
  84674. * @param operation defines the stencil operation to use when stencil fails
  84675. */
  84676. setStencilOperationFail(operation: number): void;
  84677. /**
  84678. * Sets the stencil operation to use when depth fails
  84679. * @param operation defines the stencil operation to use when depth fails
  84680. */
  84681. setStencilOperationDepthFail(operation: number): void;
  84682. /**
  84683. * Sets the stencil operation to use when stencil passes
  84684. * @param operation defines the stencil operation to use when stencil passes
  84685. */
  84686. setStencilOperationPass(operation: number): void;
  84687. /**
  84688. * Sets a boolean indicating if the dithering state is enabled or disabled
  84689. * @param value defines the dithering state
  84690. */
  84691. setDitheringState(value: boolean): void;
  84692. /**
  84693. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  84694. * @param value defines the rasterizer state
  84695. */
  84696. setRasterizerState(value: boolean): void;
  84697. /**
  84698. * stop executing a render loop function and remove it from the execution array
  84699. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  84700. */
  84701. stopRenderLoop(renderFunction?: () => void): void;
  84702. /** @hidden */
  84703. _renderLoop(): void;
  84704. /**
  84705. * Register and execute a render loop. The engine can have more than one render function
  84706. * @param renderFunction defines the function to continuously execute
  84707. */
  84708. runRenderLoop(renderFunction: () => void): void;
  84709. /**
  84710. * Toggle full screen mode
  84711. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84712. */
  84713. switchFullscreen(requestPointerLock: boolean): void;
  84714. /**
  84715. * Enters full screen mode
  84716. * @param requestPointerLock defines if a pointer lock should be requested from the user
  84717. */
  84718. enterFullscreen(requestPointerLock: boolean): void;
  84719. /**
  84720. * Exits full screen mode
  84721. */
  84722. exitFullscreen(): void;
  84723. /**
  84724. * Clear the current render buffer or the current render target (if any is set up)
  84725. * @param color defines the color to use
  84726. * @param backBuffer defines if the back buffer must be cleared
  84727. * @param depth defines if the depth buffer must be cleared
  84728. * @param stencil defines if the stencil buffer must be cleared
  84729. */
  84730. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  84731. /**
  84732. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  84733. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84734. * @param y defines the y-coordinate of the corner of the clear rectangle
  84735. * @param width defines the width of the clear rectangle
  84736. * @param height defines the height of the clear rectangle
  84737. * @param clearColor defines the clear color
  84738. */
  84739. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  84740. /**
  84741. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  84742. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  84743. * @param y defines the y-coordinate of the corner of the clear rectangle
  84744. * @param width defines the width of the clear rectangle
  84745. * @param height defines the height of the clear rectangle
  84746. */
  84747. enableScissor(x: number, y: number, width: number, height: number): void;
  84748. /**
  84749. * Disable previously set scissor test rectangle
  84750. */
  84751. disableScissor(): void;
  84752. private _viewportCached;
  84753. /** @hidden */
  84754. _viewport(x: number, y: number, width: number, height: number): void;
  84755. /**
  84756. * Set the WebGL's viewport
  84757. * @param viewport defines the viewport element to be used
  84758. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  84759. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  84760. */
  84761. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  84762. /**
  84763. * Directly set the WebGL Viewport
  84764. * @param x defines the x coordinate of the viewport (in screen space)
  84765. * @param y defines the y coordinate of the viewport (in screen space)
  84766. * @param width defines the width of the viewport (in screen space)
  84767. * @param height defines the height of the viewport (in screen space)
  84768. * @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
  84769. */
  84770. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  84771. /**
  84772. * Begin a new frame
  84773. */
  84774. beginFrame(): void;
  84775. /**
  84776. * Enf the current frame
  84777. */
  84778. endFrame(): void;
  84779. /**
  84780. * Resize the view according to the canvas' size
  84781. */
  84782. resize(): void;
  84783. /**
  84784. * Force a specific size of the canvas
  84785. * @param width defines the new canvas' width
  84786. * @param height defines the new canvas' height
  84787. */
  84788. setSize(width: number, height: number): void;
  84789. /**
  84790. * Gets a boolean indicating if a webVR device was detected
  84791. * @returns true if a webVR device was detected
  84792. */
  84793. isVRDevicePresent(): boolean;
  84794. /**
  84795. * Gets the current webVR device
  84796. * @returns the current webVR device (or null)
  84797. */
  84798. getVRDevice(): any;
  84799. /**
  84800. * Initializes a webVR display and starts listening to display change events
  84801. * The onVRDisplayChangedObservable will be notified upon these changes
  84802. * @returns The onVRDisplayChangedObservable
  84803. */
  84804. initWebVR(): Observable<IDisplayChangedEventArgs>;
  84805. /**
  84806. * Initializes a webVR display and starts listening to display change events
  84807. * The onVRDisplayChangedObservable will be notified upon these changes
  84808. * @returns A promise containing a VRDisplay and if vr is supported
  84809. */
  84810. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84811. /**
  84812. * Call this function to switch to webVR mode
  84813. * Will do nothing if webVR is not supported or if there is no webVR device
  84814. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84815. */
  84816. enableVR(): void;
  84817. /**
  84818. * Call this function to leave webVR mode
  84819. * Will do nothing if webVR is not supported or if there is no webVR device
  84820. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84821. */
  84822. disableVR(): void;
  84823. private _onVRFullScreenTriggered;
  84824. private _getVRDisplaysAsync;
  84825. /**
  84826. * Binds the frame buffer to the specified texture.
  84827. * @param texture The texture to render to or null for the default canvas
  84828. * @param faceIndex The face of the texture to render to in case of cube texture
  84829. * @param requiredWidth The width of the target to render to
  84830. * @param requiredHeight The height of the target to render to
  84831. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  84832. * @param depthStencilTexture The depth stencil texture to use to render
  84833. * @param lodLevel defines le lod level to bind to the frame buffer
  84834. */
  84835. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  84836. private bindUnboundFramebuffer;
  84837. /**
  84838. * Unbind the current render target texture from the webGL context
  84839. * @param texture defines the render target texture to unbind
  84840. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84841. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84842. */
  84843. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84844. /**
  84845. * Unbind a list of render target textures from the webGL context
  84846. * This is used only when drawBuffer extension or webGL2 are active
  84847. * @param textures defines the render target textures to unbind
  84848. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  84849. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  84850. */
  84851. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  84852. /**
  84853. * Force the mipmap generation for the given render target texture
  84854. * @param texture defines the render target texture to use
  84855. */
  84856. generateMipMapsForCubemap(texture: InternalTexture): void;
  84857. /**
  84858. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  84859. */
  84860. flushFramebuffer(): void;
  84861. /**
  84862. * Unbind the current render target and bind the default framebuffer
  84863. */
  84864. restoreDefaultFramebuffer(): void;
  84865. /**
  84866. * Create an uniform buffer
  84867. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84868. * @param elements defines the content of the uniform buffer
  84869. * @returns the webGL uniform buffer
  84870. */
  84871. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  84872. /**
  84873. * Create a dynamic uniform buffer
  84874. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84875. * @param elements defines the content of the uniform buffer
  84876. * @returns the webGL uniform buffer
  84877. */
  84878. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  84879. /**
  84880. * Update an existing uniform buffer
  84881. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84882. * @param uniformBuffer defines the target uniform buffer
  84883. * @param elements defines the content to update
  84884. * @param offset defines the offset in the uniform buffer where update should start
  84885. * @param count defines the size of the data to update
  84886. */
  84887. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84888. private _resetVertexBufferBinding;
  84889. /**
  84890. * Creates a vertex buffer
  84891. * @param data the data for the vertex buffer
  84892. * @returns the new WebGL static buffer
  84893. */
  84894. createVertexBuffer(data: DataArray): WebGLBuffer;
  84895. /**
  84896. * Creates a dynamic vertex buffer
  84897. * @param data the data for the dynamic vertex buffer
  84898. * @returns the new WebGL dynamic buffer
  84899. */
  84900. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  84901. /**
  84902. * Update a dynamic index buffer
  84903. * @param indexBuffer defines the target index buffer
  84904. * @param indices defines the data to update
  84905. * @param offset defines the offset in the target index buffer where update should start
  84906. */
  84907. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  84908. /**
  84909. * Updates a dynamic vertex buffer.
  84910. * @param vertexBuffer the vertex buffer to update
  84911. * @param data the data used to update the vertex buffer
  84912. * @param byteOffset the byte offset of the data
  84913. * @param byteLength the byte length of the data
  84914. */
  84915. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  84916. private _resetIndexBufferBinding;
  84917. /**
  84918. * Creates a new index buffer
  84919. * @param indices defines the content of the index buffer
  84920. * @param updatable defines if the index buffer must be updatable
  84921. * @returns a new webGL buffer
  84922. */
  84923. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  84924. /**
  84925. * Bind a webGL buffer to the webGL context
  84926. * @param buffer defines the buffer to bind
  84927. */
  84928. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  84929. /**
  84930. * Bind an uniform buffer to the current webGL context
  84931. * @param buffer defines the buffer to bind
  84932. */
  84933. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  84934. /**
  84935. * Bind a buffer to the current webGL context at a given location
  84936. * @param buffer defines the buffer to bind
  84937. * @param location defines the index where to bind the buffer
  84938. */
  84939. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  84940. /**
  84941. * Bind a specific block at a given index in a specific shader program
  84942. * @param shaderProgram defines the shader program
  84943. * @param blockName defines the block name
  84944. * @param index defines the index where to bind the block
  84945. */
  84946. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  84947. private bindIndexBuffer;
  84948. private bindBuffer;
  84949. /**
  84950. * update the bound buffer with the given data
  84951. * @param data defines the data to update
  84952. */
  84953. updateArrayBuffer(data: Float32Array): void;
  84954. private _vertexAttribPointer;
  84955. private _bindIndexBufferWithCache;
  84956. private _bindVertexBuffersAttributes;
  84957. /**
  84958. * Records a vertex array object
  84959. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84960. * @param vertexBuffers defines the list of vertex buffers to store
  84961. * @param indexBuffer defines the index buffer to store
  84962. * @param effect defines the effect to store
  84963. * @returns the new vertex array object
  84964. */
  84965. recordVertexArrayObject(vertexBuffers: {
  84966. [key: string]: VertexBuffer;
  84967. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  84968. /**
  84969. * Bind a specific vertex array object
  84970. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  84971. * @param vertexArrayObject defines the vertex array object to bind
  84972. * @param indexBuffer defines the index buffer to bind
  84973. */
  84974. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  84975. /**
  84976. * Bind webGl buffers directly to the webGL context
  84977. * @param vertexBuffer defines the vertex buffer to bind
  84978. * @param indexBuffer defines the index buffer to bind
  84979. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  84980. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  84981. * @param effect defines the effect associated with the vertex buffer
  84982. */
  84983. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  84984. private _unbindVertexArrayObject;
  84985. /**
  84986. * Bind a list of vertex buffers to the webGL context
  84987. * @param vertexBuffers defines the list of vertex buffers to bind
  84988. * @param indexBuffer defines the index buffer to bind
  84989. * @param effect defines the effect associated with the vertex buffers
  84990. */
  84991. bindBuffers(vertexBuffers: {
  84992. [key: string]: Nullable<VertexBuffer>;
  84993. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  84994. /**
  84995. * Unbind all instance attributes
  84996. */
  84997. unbindInstanceAttributes(): void;
  84998. /**
  84999. * Release and free the memory of a vertex array object
  85000. * @param vao defines the vertex array object to delete
  85001. */
  85002. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  85003. /** @hidden */
  85004. _releaseBuffer(buffer: WebGLBuffer): boolean;
  85005. /**
  85006. * Creates a webGL buffer to use with instanciation
  85007. * @param capacity defines the size of the buffer
  85008. * @returns the webGL buffer
  85009. */
  85010. createInstancesBuffer(capacity: number): WebGLBuffer;
  85011. /**
  85012. * Delete a webGL buffer used with instanciation
  85013. * @param buffer defines the webGL buffer to delete
  85014. */
  85015. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  85016. /**
  85017. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  85018. * @param instancesBuffer defines the webGL buffer to update and bind
  85019. * @param data defines the data to store in the buffer
  85020. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  85021. */
  85022. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  85023. /**
  85024. * Apply all cached states (depth, culling, stencil and alpha)
  85025. */
  85026. applyStates(): void;
  85027. /**
  85028. * Send a draw order
  85029. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85030. * @param indexStart defines the starting index
  85031. * @param indexCount defines the number of index to draw
  85032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85033. */
  85034. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  85035. /**
  85036. * Draw a list of points
  85037. * @param verticesStart defines the index of first vertex to draw
  85038. * @param verticesCount defines the count of vertices to draw
  85039. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85040. */
  85041. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85042. /**
  85043. * Draw a list of unindexed primitives
  85044. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  85045. * @param verticesStart defines the index of first vertex to draw
  85046. * @param verticesCount defines the count of vertices to draw
  85047. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85048. */
  85049. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85050. /**
  85051. * Draw a list of indexed primitives
  85052. * @param fillMode defines the primitive to use
  85053. * @param indexStart defines the starting index
  85054. * @param indexCount defines the number of index to draw
  85055. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85056. */
  85057. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  85058. /**
  85059. * Draw a list of unindexed primitives
  85060. * @param fillMode defines the primitive to use
  85061. * @param verticesStart defines the index of first vertex to draw
  85062. * @param verticesCount defines the count of vertices to draw
  85063. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  85064. */
  85065. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  85066. private _drawMode;
  85067. /** @hidden */
  85068. _releaseEffect(effect: Effect): void;
  85069. /** @hidden */
  85070. _deleteProgram(program: WebGLProgram): void;
  85071. /**
  85072. * Create a new effect (used to store vertex/fragment shaders)
  85073. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  85074. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  85075. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  85076. * @param samplers defines an array of string used to represent textures
  85077. * @param defines defines the string containing the defines to use to compile the shaders
  85078. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  85079. * @param onCompiled defines a function to call when the effect creation is successful
  85080. * @param onError defines a function to call when the effect creation has failed
  85081. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  85082. * @returns the new Effect
  85083. */
  85084. 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;
  85085. private _compileShader;
  85086. private _compileRawShader;
  85087. /**
  85088. * Directly creates a webGL program
  85089. * @param vertexCode defines the vertex shader code to use
  85090. * @param fragmentCode defines the fragment shader code to use
  85091. * @param context defines the webGL context to use (if not set, the current one will be used)
  85092. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85093. * @returns the new webGL program
  85094. */
  85095. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85096. /**
  85097. * Creates a webGL program
  85098. * @param vertexCode defines the vertex shader code to use
  85099. * @param fragmentCode defines the fragment shader code to use
  85100. * @param defines defines the string containing the defines to use to compile the shaders
  85101. * @param context defines the webGL context to use (if not set, the current one will be used)
  85102. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  85103. * @returns the new webGL program
  85104. */
  85105. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  85106. private _createShaderProgram;
  85107. private _finalizeProgram;
  85108. /** @hidden */
  85109. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  85110. /** @hidden */
  85111. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  85112. /**
  85113. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  85114. * @param shaderProgram defines the webGL program to use
  85115. * @param uniformsNames defines the list of uniform names
  85116. * @returns an array of webGL uniform locations
  85117. */
  85118. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  85119. /**
  85120. * Gets the lsit of active attributes for a given webGL program
  85121. * @param shaderProgram defines the webGL program to use
  85122. * @param attributesNames defines the list of attribute names to get
  85123. * @returns an array of indices indicating the offset of each attribute
  85124. */
  85125. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  85126. /**
  85127. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  85128. * @param effect defines the effect to activate
  85129. */
  85130. enableEffect(effect: Nullable<Effect>): void;
  85131. /**
  85132. * Set the value of an uniform to an array of int32
  85133. * @param uniform defines the webGL uniform location where to store the value
  85134. * @param array defines the array of int32 to store
  85135. */
  85136. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85137. /**
  85138. * Set the value of an uniform to an array of int32 (stored as vec2)
  85139. * @param uniform defines the webGL uniform location where to store the value
  85140. * @param array defines the array of int32 to store
  85141. */
  85142. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85143. /**
  85144. * Set the value of an uniform to an array of int32 (stored as vec3)
  85145. * @param uniform defines the webGL uniform location where to store the value
  85146. * @param array defines the array of int32 to store
  85147. */
  85148. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85149. /**
  85150. * Set the value of an uniform to an array of int32 (stored as vec4)
  85151. * @param uniform defines the webGL uniform location where to store the value
  85152. * @param array defines the array of int32 to store
  85153. */
  85154. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  85155. /**
  85156. * Set the value of an uniform to an array of float32
  85157. * @param uniform defines the webGL uniform location where to store the value
  85158. * @param array defines the array of float32 to store
  85159. */
  85160. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85161. /**
  85162. * Set the value of an uniform to an array of float32 (stored as vec2)
  85163. * @param uniform defines the webGL uniform location where to store the value
  85164. * @param array defines the array of float32 to store
  85165. */
  85166. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85167. /**
  85168. * Set the value of an uniform to an array of float32 (stored as vec3)
  85169. * @param uniform defines the webGL uniform location where to store the value
  85170. * @param array defines the array of float32 to store
  85171. */
  85172. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85173. /**
  85174. * Set the value of an uniform to an array of float32 (stored as vec4)
  85175. * @param uniform defines the webGL uniform location where to store the value
  85176. * @param array defines the array of float32 to store
  85177. */
  85178. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  85179. /**
  85180. * Set the value of an uniform to an array of number
  85181. * @param uniform defines the webGL uniform location where to store the value
  85182. * @param array defines the array of number to store
  85183. */
  85184. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85185. /**
  85186. * Set the value of an uniform to an array of number (stored as vec2)
  85187. * @param uniform defines the webGL uniform location where to store the value
  85188. * @param array defines the array of number to store
  85189. */
  85190. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85191. /**
  85192. * Set the value of an uniform to an array of number (stored as vec3)
  85193. * @param uniform defines the webGL uniform location where to store the value
  85194. * @param array defines the array of number to store
  85195. */
  85196. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85197. /**
  85198. * Set the value of an uniform to an array of number (stored as vec4)
  85199. * @param uniform defines the webGL uniform location where to store the value
  85200. * @param array defines the array of number to store
  85201. */
  85202. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  85203. /**
  85204. * Set the value of an uniform to an array of float32 (stored as matrices)
  85205. * @param uniform defines the webGL uniform location where to store the value
  85206. * @param matrices defines the array of float32 to store
  85207. */
  85208. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  85209. /**
  85210. * Set the value of an uniform to a matrix
  85211. * @param uniform defines the webGL uniform location where to store the value
  85212. * @param matrix defines the matrix to store
  85213. */
  85214. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  85215. /**
  85216. * Set the value of an uniform to a matrix (3x3)
  85217. * @param uniform defines the webGL uniform location where to store the value
  85218. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  85219. */
  85220. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85221. /**
  85222. * Set the value of an uniform to a matrix (2x2)
  85223. * @param uniform defines the webGL uniform location where to store the value
  85224. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  85225. */
  85226. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  85227. /**
  85228. * Set the value of an uniform to a number (int)
  85229. * @param uniform defines the webGL uniform location where to store the value
  85230. * @param value defines the int number to store
  85231. */
  85232. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85233. /**
  85234. * Set the value of an uniform to a number (float)
  85235. * @param uniform defines the webGL uniform location where to store the value
  85236. * @param value defines the float number to store
  85237. */
  85238. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  85239. /**
  85240. * Set the value of an uniform to a vec2
  85241. * @param uniform defines the webGL uniform location where to store the value
  85242. * @param x defines the 1st component of the value
  85243. * @param y defines the 2nd component of the value
  85244. */
  85245. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  85246. /**
  85247. * Set the value of an uniform to a vec3
  85248. * @param uniform defines the webGL uniform location where to store the value
  85249. * @param x defines the 1st component of the value
  85250. * @param y defines the 2nd component of the value
  85251. * @param z defines the 3rd component of the value
  85252. */
  85253. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  85254. /**
  85255. * Set the value of an uniform to a boolean
  85256. * @param uniform defines the webGL uniform location where to store the value
  85257. * @param bool defines the boolean to store
  85258. */
  85259. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  85260. /**
  85261. * Set the value of an uniform to a vec4
  85262. * @param uniform defines the webGL uniform location where to store the value
  85263. * @param x defines the 1st component of the value
  85264. * @param y defines the 2nd component of the value
  85265. * @param z defines the 3rd component of the value
  85266. * @param w defines the 4th component of the value
  85267. */
  85268. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  85269. /**
  85270. * Set the value of an uniform to a Color3
  85271. * @param uniform defines the webGL uniform location where to store the value
  85272. * @param color3 defines the color to store
  85273. */
  85274. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  85275. /**
  85276. * Set the value of an uniform to a Color3 and an alpha value
  85277. * @param uniform defines the webGL uniform location where to store the value
  85278. * @param color3 defines the color to store
  85279. * @param alpha defines the alpha component to store
  85280. */
  85281. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  85282. /**
  85283. * Sets a Color4 on a uniform variable
  85284. * @param uniform defines the uniform location
  85285. * @param color4 defines the value to be set
  85286. */
  85287. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  85288. /**
  85289. * Set various states to the webGL context
  85290. * @param culling defines backface culling state
  85291. * @param zOffset defines the value to apply to zOffset (0 by default)
  85292. * @param force defines if states must be applied even if cache is up to date
  85293. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  85294. */
  85295. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  85296. /**
  85297. * Set the z offset to apply to current rendering
  85298. * @param value defines the offset to apply
  85299. */
  85300. setZOffset(value: number): void;
  85301. /**
  85302. * Gets the current value of the zOffset
  85303. * @returns the current zOffset state
  85304. */
  85305. getZOffset(): number;
  85306. /**
  85307. * Enable or disable depth buffering
  85308. * @param enable defines the state to set
  85309. */
  85310. setDepthBuffer(enable: boolean): void;
  85311. /**
  85312. * Gets a boolean indicating if depth writing is enabled
  85313. * @returns the current depth writing state
  85314. */
  85315. getDepthWrite(): boolean;
  85316. /**
  85317. * Enable or disable depth writing
  85318. * @param enable defines the state to set
  85319. */
  85320. setDepthWrite(enable: boolean): void;
  85321. /**
  85322. * Enable or disable color writing
  85323. * @param enable defines the state to set
  85324. */
  85325. setColorWrite(enable: boolean): void;
  85326. /**
  85327. * Gets a boolean indicating if color writing is enabled
  85328. * @returns the current color writing state
  85329. */
  85330. getColorWrite(): boolean;
  85331. /**
  85332. * Sets alpha constants used by some alpha blending modes
  85333. * @param r defines the red component
  85334. * @param g defines the green component
  85335. * @param b defines the blue component
  85336. * @param a defines the alpha component
  85337. */
  85338. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  85339. /**
  85340. * Sets the current alpha mode
  85341. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  85342. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  85343. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85344. */
  85345. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  85346. /**
  85347. * Gets the current alpha mode
  85348. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  85349. * @returns the current alpha mode
  85350. */
  85351. getAlphaMode(): number;
  85352. /**
  85353. * Clears the list of texture accessible through engine.
  85354. * This can help preventing texture load conflict due to name collision.
  85355. */
  85356. clearInternalTexturesCache(): void;
  85357. /**
  85358. * Force the entire cache to be cleared
  85359. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  85360. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  85361. */
  85362. wipeCaches(bruteForce?: boolean): void;
  85363. /**
  85364. * Set the compressed texture format to use, based on the formats you have, and the formats
  85365. * supported by the hardware / browser.
  85366. *
  85367. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  85368. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  85369. * to API arguments needed to compressed textures. This puts the burden on the container
  85370. * generator to house the arcane code for determining these for current & future formats.
  85371. *
  85372. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  85373. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  85374. *
  85375. * Note: The result of this call is not taken into account when a texture is base64.
  85376. *
  85377. * @param formatsAvailable defines the list of those format families you have created
  85378. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  85379. *
  85380. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  85381. * @returns The extension selected.
  85382. */
  85383. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  85384. private _getSamplingParameters;
  85385. private _partialLoadImg;
  85386. private _cascadeLoadImgs;
  85387. /** @hidden */
  85388. _createTexture(): WebGLTexture;
  85389. /**
  85390. * Usually called from Texture.ts.
  85391. * Passed information to create a WebGLTexture
  85392. * @param urlArg defines a value which contains one of the following:
  85393. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  85394. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  85395. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  85396. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  85397. * @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)
  85398. * @param scene needed for loading to the correct scene
  85399. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  85400. * @param onLoad optional callback to be called upon successful completion
  85401. * @param onError optional callback to be called upon failure
  85402. * @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
  85403. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  85404. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  85405. * @param forcedExtension defines the extension to use to pick the right loader
  85406. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  85407. * @returns a InternalTexture for assignment back into BABYLON.Texture
  85408. */
  85409. 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;
  85410. private _rescaleTexture;
  85411. /**
  85412. * Update a raw texture
  85413. * @param texture defines the texture to update
  85414. * @param data defines the data to store in the texture
  85415. * @param format defines the format of the data
  85416. * @param invertY defines if data must be stored with Y axis inverted
  85417. * @param compression defines the compression used (null by default)
  85418. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85419. */
  85420. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  85421. /**
  85422. * Creates a raw texture
  85423. * @param data defines the data to store in the texture
  85424. * @param width defines the width of the texture
  85425. * @param height defines the height of the texture
  85426. * @param format defines the format of the data
  85427. * @param generateMipMaps defines if the engine should generate the mip levels
  85428. * @param invertY defines if data must be stored with Y axis inverted
  85429. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85430. * @param compression defines the compression used (null by default)
  85431. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85432. * @returns the raw texture inside an InternalTexture
  85433. */
  85434. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  85435. private _unpackFlipYCached;
  85436. /**
  85437. * In case you are sharing the context with other applications, it might
  85438. * be interested to not cache the unpack flip y state to ensure a consistent
  85439. * value would be set.
  85440. */
  85441. enableUnpackFlipYCached: boolean;
  85442. /** @hidden */
  85443. _unpackFlipY(value: boolean): void;
  85444. /** @hidden */
  85445. _getUnpackAlignement(): number;
  85446. /**
  85447. * Creates a dynamic texture
  85448. * @param width defines the width of the texture
  85449. * @param height defines the height of the texture
  85450. * @param generateMipMaps defines if the engine should generate the mip levels
  85451. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85452. * @returns the dynamic texture inside an InternalTexture
  85453. */
  85454. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85455. /**
  85456. * Update the sampling mode of a given texture
  85457. * @param samplingMode defines the required sampling mode
  85458. * @param texture defines the texture to update
  85459. */
  85460. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  85461. /**
  85462. * Update the content of a dynamic texture
  85463. * @param texture defines the texture to update
  85464. * @param canvas defines the canvas containing the source
  85465. * @param invertY defines if data must be stored with Y axis inverted
  85466. * @param premulAlpha defines if alpha is stored as premultiplied
  85467. * @param format defines the format of the data
  85468. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85469. */
  85470. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85471. /**
  85472. * Update a video texture
  85473. * @param texture defines the texture to update
  85474. * @param video defines the video element to use
  85475. * @param invertY defines if data must be stored with Y axis inverted
  85476. */
  85477. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  85478. /**
  85479. * Updates a depth texture Comparison Mode and Function.
  85480. * If the comparison Function is equal to 0, the mode will be set to none.
  85481. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  85482. * @param texture The texture to set the comparison function for
  85483. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  85484. */
  85485. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  85486. private _setupDepthStencilTexture;
  85487. /**
  85488. * Creates a depth stencil texture.
  85489. * This is only available in WebGL 2 or with the depth texture extension available.
  85490. * @param size The size of face edge in the texture.
  85491. * @param options The options defining the texture.
  85492. * @returns The texture
  85493. */
  85494. createDepthStencilTexture(size: number | {
  85495. width: number;
  85496. height: number;
  85497. }, options: DepthTextureCreationOptions): InternalTexture;
  85498. /**
  85499. * Creates a depth stencil texture.
  85500. * This is only available in WebGL 2 or with the depth texture extension available.
  85501. * @param size The size of face edge in the texture.
  85502. * @param options The options defining the texture.
  85503. * @returns The texture
  85504. */
  85505. private _createDepthStencilTexture;
  85506. /**
  85507. * Creates a depth stencil cube texture.
  85508. * This is only available in WebGL 2.
  85509. * @param size The size of face edge in the cube texture.
  85510. * @param options The options defining the cube texture.
  85511. * @returns The cube texture
  85512. */
  85513. private _createDepthStencilCubeTexture;
  85514. /**
  85515. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  85516. * @param renderTarget The render target to set the frame buffer for
  85517. */
  85518. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  85519. /**
  85520. * Creates a new render target texture
  85521. * @param size defines the size of the texture
  85522. * @param options defines the options used to create the texture
  85523. * @returns a new render target texture stored in an InternalTexture
  85524. */
  85525. createRenderTargetTexture(size: number | {
  85526. width: number;
  85527. height: number;
  85528. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  85529. /**
  85530. * Create a multi render target texture
  85531. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  85532. * @param size defines the size of the texture
  85533. * @param options defines the creation options
  85534. * @returns the cube texture as an InternalTexture
  85535. */
  85536. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  85537. private _setupFramebufferDepthAttachments;
  85538. /**
  85539. * Updates the sample count of a render target texture
  85540. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85541. * @param texture defines the texture to update
  85542. * @param samples defines the sample count to set
  85543. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85544. */
  85545. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  85546. /**
  85547. * Update the sample count for a given multiple render target texture
  85548. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  85549. * @param textures defines the textures to update
  85550. * @param samples defines the sample count to set
  85551. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  85552. */
  85553. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  85554. /** @hidden */
  85555. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85556. /** @hidden */
  85557. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85558. /** @hidden */
  85559. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  85560. /** @hidden */
  85561. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  85562. /**
  85563. * Creates a new render target cube texture
  85564. * @param size defines the size of the texture
  85565. * @param options defines the options used to create the texture
  85566. * @returns a new render target cube texture stored in an InternalTexture
  85567. */
  85568. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85569. /**
  85570. * Creates a cube texture
  85571. * @param rootUrl defines the url where the files to load is located
  85572. * @param scene defines the current scene
  85573. * @param files defines the list of files to load (1 per face)
  85574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85575. * @param onLoad defines an optional callback raised when the texture is loaded
  85576. * @param onError defines an optional callback raised if there is an issue to load the texture
  85577. * @param format defines the format of the data
  85578. * @param forcedExtension defines the extension to use to pick the right loader
  85579. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85580. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85581. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85582. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85583. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  85584. * @returns the cube texture as an InternalTexture
  85585. */
  85586. 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;
  85587. /**
  85588. * @hidden
  85589. */
  85590. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85591. /**
  85592. * Update a raw cube texture
  85593. * @param texture defines the texture to udpdate
  85594. * @param data defines the data to store
  85595. * @param format defines the data format
  85596. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  85597. * @param invertY defines if data must be stored with Y axis inverted
  85598. * @param compression defines the compression used (null by default)
  85599. * @param level defines which level of the texture to update
  85600. */
  85601. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  85602. /**
  85603. * Creates a new raw cube texture
  85604. * @param data defines the array of data to use to create each face
  85605. * @param size defines the size of the textures
  85606. * @param format defines the format of the data
  85607. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85608. * @param generateMipMaps defines if the engine should generate the mip levels
  85609. * @param invertY defines if data must be stored with Y axis inverted
  85610. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85611. * @param compression defines the compression used (null by default)
  85612. * @returns the cube texture as an InternalTexture
  85613. */
  85614. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  85615. /**
  85616. * Creates a new raw cube texture from a specified url
  85617. * @param url defines the url where the data is located
  85618. * @param scene defines the current scene
  85619. * @param size defines the size of the textures
  85620. * @param format defines the format of the data
  85621. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  85622. * @param noMipmap defines if the engine should avoid generating the mip levels
  85623. * @param callback defines a callback used to extract texture data from loaded data
  85624. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  85625. * @param onLoad defines a callback called when texture is loaded
  85626. * @param onError defines a callback called if there is an error
  85627. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85628. * @param invertY defines if data must be stored with Y axis inverted
  85629. * @returns the cube texture as an InternalTexture
  85630. */
  85631. 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;
  85632. /**
  85633. * Update a raw 3D texture
  85634. * @param texture defines the texture to update
  85635. * @param data defines the data to store
  85636. * @param format defines the data format
  85637. * @param invertY defines if data must be stored with Y axis inverted
  85638. * @param compression defines the used compression (can be null)
  85639. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  85640. */
  85641. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  85642. /**
  85643. * Creates a new raw 3D texture
  85644. * @param data defines the data used to create the texture
  85645. * @param width defines the width of the texture
  85646. * @param height defines the height of the texture
  85647. * @param depth defines the depth of the texture
  85648. * @param format defines the format of the texture
  85649. * @param generateMipMaps defines if the engine must generate mip levels
  85650. * @param invertY defines if data must be stored with Y axis inverted
  85651. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  85652. * @param compression defines the compressed used (can be null)
  85653. * @param textureType defines the compressed used (can be null)
  85654. * @returns a new raw 3D texture (stored in an InternalTexture)
  85655. */
  85656. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  85657. private _prepareWebGLTextureContinuation;
  85658. private _prepareWebGLTexture;
  85659. private _convertRGBtoRGBATextureData;
  85660. /** @hidden */
  85661. _releaseFramebufferObjects(texture: InternalTexture): void;
  85662. /** @hidden */
  85663. _releaseTexture(texture: InternalTexture): void;
  85664. private setProgram;
  85665. private _boundUniforms;
  85666. /**
  85667. * Binds an effect to the webGL context
  85668. * @param effect defines the effect to bind
  85669. */
  85670. bindSamplers(effect: Effect): void;
  85671. private _moveBoundTextureOnTop;
  85672. private _getCorrectTextureChannel;
  85673. private _linkTrackers;
  85674. private _removeDesignatedSlot;
  85675. private _activateCurrentTexture;
  85676. /** @hidden */
  85677. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  85678. /** @hidden */
  85679. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  85680. /**
  85681. * Sets a texture to the webGL context from a postprocess
  85682. * @param channel defines the channel to use
  85683. * @param postProcess defines the source postprocess
  85684. */
  85685. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  85686. /**
  85687. * Binds the output of the passed in post process to the texture channel specified
  85688. * @param channel The channel the texture should be bound to
  85689. * @param postProcess The post process which's output should be bound
  85690. */
  85691. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  85692. /**
  85693. * Unbind all textures from the webGL context
  85694. */
  85695. unbindAllTextures(): void;
  85696. /**
  85697. * Sets a texture to the according uniform.
  85698. * @param channel The texture channel
  85699. * @param uniform The uniform to set
  85700. * @param texture The texture to apply
  85701. */
  85702. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  85703. /**
  85704. * Sets a depth stencil texture from a render target to the according uniform.
  85705. * @param channel The texture channel
  85706. * @param uniform The uniform to set
  85707. * @param texture The render target texture containing the depth stencil texture to apply
  85708. */
  85709. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  85710. private _bindSamplerUniformToChannel;
  85711. private _getTextureWrapMode;
  85712. private _setTexture;
  85713. /**
  85714. * Sets an array of texture to the webGL context
  85715. * @param channel defines the channel where the texture array must be set
  85716. * @param uniform defines the associated uniform location
  85717. * @param textures defines the array of textures to bind
  85718. */
  85719. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  85720. /** @hidden */
  85721. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  85722. private _setTextureParameterFloat;
  85723. private _setTextureParameterInteger;
  85724. /**
  85725. * Reads pixels from the current frame buffer. Please note that this function can be slow
  85726. * @param x defines the x coordinate of the rectangle where pixels must be read
  85727. * @param y defines the y coordinate of the rectangle where pixels must be read
  85728. * @param width defines the width of the rectangle where pixels must be read
  85729. * @param height defines the height of the rectangle where pixels must be read
  85730. * @returns a Uint8Array containing RGBA colors
  85731. */
  85732. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  85733. /**
  85734. * Add an externaly attached data from its key.
  85735. * This method call will fail and return false, if such key already exists.
  85736. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  85737. * @param key the unique key that identifies the data
  85738. * @param data the data object to associate to the key for this Engine instance
  85739. * @return true if no such key were already present and the data was added successfully, false otherwise
  85740. */
  85741. addExternalData<T>(key: string, data: T): boolean;
  85742. /**
  85743. * Get an externaly attached data from its key
  85744. * @param key the unique key that identifies the data
  85745. * @return the associated data, if present (can be null), or undefined if not present
  85746. */
  85747. getExternalData<T>(key: string): T;
  85748. /**
  85749. * Get an externaly attached data from its key, create it using a factory if it's not already present
  85750. * @param key the unique key that identifies the data
  85751. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  85752. * @return the associated data, can be null if the factory returned null.
  85753. */
  85754. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  85755. /**
  85756. * Remove an externaly attached data from the Engine instance
  85757. * @param key the unique key that identifies the data
  85758. * @return true if the data was successfully removed, false if it doesn't exist
  85759. */
  85760. removeExternalData(key: string): boolean;
  85761. /**
  85762. * Unbind all vertex attributes from the webGL context
  85763. */
  85764. unbindAllAttributes(): void;
  85765. /**
  85766. * 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
  85767. */
  85768. releaseEffects(): void;
  85769. /**
  85770. * Dispose and release all associated resources
  85771. */
  85772. dispose(): void;
  85773. /**
  85774. * Display the loading screen
  85775. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85776. */
  85777. displayLoadingUI(): void;
  85778. /**
  85779. * Hide the loading screen
  85780. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85781. */
  85782. hideLoadingUI(): void;
  85783. /**
  85784. * Gets the current loading screen object
  85785. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85786. */
  85787. /**
  85788. * Sets the current loading screen object
  85789. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85790. */
  85791. loadingScreen: ILoadingScreen;
  85792. /**
  85793. * Sets the current loading screen text
  85794. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85795. */
  85796. loadingUIText: string;
  85797. /**
  85798. * Sets the current loading screen background color
  85799. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85800. */
  85801. loadingUIBackgroundColor: string;
  85802. /**
  85803. * Attach a new callback raised when context lost event is fired
  85804. * @param callback defines the callback to call
  85805. */
  85806. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85807. /**
  85808. * Attach a new callback raised when context restored event is fired
  85809. * @param callback defines the callback to call
  85810. */
  85811. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  85812. /**
  85813. * Gets the source code of the vertex shader associated with a specific webGL program
  85814. * @param program defines the program to use
  85815. * @returns a string containing the source code of the vertex shader associated with the program
  85816. */
  85817. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  85818. /**
  85819. * Gets the source code of the fragment shader associated with a specific webGL program
  85820. * @param program defines the program to use
  85821. * @returns a string containing the source code of the fragment shader associated with the program
  85822. */
  85823. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  85824. /**
  85825. * Get the current error code of the webGL context
  85826. * @returns the error code
  85827. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  85828. */
  85829. getError(): number;
  85830. /**
  85831. * Gets the current framerate
  85832. * @returns a number representing the framerate
  85833. */
  85834. getFps(): number;
  85835. /**
  85836. * Gets the time spent between current and previous frame
  85837. * @returns a number representing the delta time in ms
  85838. */
  85839. getDeltaTime(): number;
  85840. private _measureFps;
  85841. /** @hidden */
  85842. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  85843. private _canRenderToFloatFramebuffer;
  85844. private _canRenderToHalfFloatFramebuffer;
  85845. private _canRenderToFramebuffer;
  85846. /** @hidden */
  85847. _getWebGLTextureType(type: number): number;
  85848. private _getInternalFormat;
  85849. /** @hidden */
  85850. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  85851. /** @hidden */
  85852. _getRGBAMultiSampleBufferFormat(type: number): number;
  85853. /** @hidden */
  85854. _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;
  85855. /** @hidden */
  85856. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  85857. private _partialLoadFile;
  85858. private _cascadeLoadFiles;
  85859. /**
  85860. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  85861. * @returns true if the engine can be created
  85862. * @ignorenaming
  85863. */
  85864. static isSupported(): boolean;
  85865. }
  85866. }
  85867. declare module BABYLON {
  85868. /**
  85869. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  85870. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  85871. */
  85872. export class EffectFallbacks {
  85873. private _defines;
  85874. private _currentRank;
  85875. private _maxRank;
  85876. private _mesh;
  85877. /**
  85878. * Removes the fallback from the bound mesh.
  85879. */
  85880. unBindMesh(): void;
  85881. /**
  85882. * Adds a fallback on the specified property.
  85883. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85884. * @param define The name of the define in the shader
  85885. */
  85886. addFallback(rank: number, define: string): void;
  85887. /**
  85888. * Sets the mesh to use CPU skinning when needing to fallback.
  85889. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  85890. * @param mesh The mesh to use the fallbacks.
  85891. */
  85892. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  85893. /**
  85894. * Checks to see if more fallbacks are still availible.
  85895. */
  85896. readonly isMoreFallbacks: boolean;
  85897. /**
  85898. * Removes the defines that shoould be removed when falling back.
  85899. * @param currentDefines defines the current define statements for the shader.
  85900. * @param effect defines the current effect we try to compile
  85901. * @returns The resulting defines with defines of the current rank removed.
  85902. */
  85903. reduce(currentDefines: string, effect: Effect): string;
  85904. }
  85905. /**
  85906. * Options to be used when creating an effect.
  85907. */
  85908. export class EffectCreationOptions {
  85909. /**
  85910. * Atrributes that will be used in the shader.
  85911. */
  85912. attributes: string[];
  85913. /**
  85914. * Uniform varible names that will be set in the shader.
  85915. */
  85916. uniformsNames: string[];
  85917. /**
  85918. * Uniform buffer varible names that will be set in the shader.
  85919. */
  85920. uniformBuffersNames: string[];
  85921. /**
  85922. * Sampler texture variable names that will be set in the shader.
  85923. */
  85924. samplers: string[];
  85925. /**
  85926. * Define statements that will be set in the shader.
  85927. */
  85928. defines: any;
  85929. /**
  85930. * Possible fallbacks for this effect to improve performance when needed.
  85931. */
  85932. fallbacks: Nullable<EffectFallbacks>;
  85933. /**
  85934. * Callback that will be called when the shader is compiled.
  85935. */
  85936. onCompiled: Nullable<(effect: Effect) => void>;
  85937. /**
  85938. * Callback that will be called if an error occurs during shader compilation.
  85939. */
  85940. onError: Nullable<(effect: Effect, errors: string) => void>;
  85941. /**
  85942. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  85943. */
  85944. indexParameters: any;
  85945. /**
  85946. * Max number of lights that can be used in the shader.
  85947. */
  85948. maxSimultaneousLights: number;
  85949. /**
  85950. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  85951. */
  85952. transformFeedbackVaryings: Nullable<string[]>;
  85953. }
  85954. /**
  85955. * Effect containing vertex and fragment shader that can be executed on an object.
  85956. */
  85957. export class Effect {
  85958. /**
  85959. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85960. */
  85961. static ShadersRepository: string;
  85962. /**
  85963. * Name of the effect.
  85964. */
  85965. name: any;
  85966. /**
  85967. * String container all the define statements that should be set on the shader.
  85968. */
  85969. defines: string;
  85970. /**
  85971. * Callback that will be called when the shader is compiled.
  85972. */
  85973. onCompiled: Nullable<(effect: Effect) => void>;
  85974. /**
  85975. * Callback that will be called if an error occurs during shader compilation.
  85976. */
  85977. onError: Nullable<(effect: Effect, errors: string) => void>;
  85978. /**
  85979. * Callback that will be called when effect is bound.
  85980. */
  85981. onBind: Nullable<(effect: Effect) => void>;
  85982. /**
  85983. * Unique ID of the effect.
  85984. */
  85985. uniqueId: number;
  85986. /**
  85987. * Observable that will be called when the shader is compiled.
  85988. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  85989. */
  85990. onCompileObservable: Observable<Effect>;
  85991. /**
  85992. * Observable that will be called if an error occurs during shader compilation.
  85993. */
  85994. onErrorObservable: Observable<Effect>;
  85995. /** @hidden */
  85996. _onBindObservable: Nullable<Observable<Effect>>;
  85997. /**
  85998. * Observable that will be called when effect is bound.
  85999. */
  86000. readonly onBindObservable: Observable<Effect>;
  86001. /** @hidden */
  86002. _bonesComputationForcedToCPU: boolean;
  86003. private static _uniqueIdSeed;
  86004. private _engine;
  86005. private _uniformBuffersNames;
  86006. private _uniformsNames;
  86007. private _samplers;
  86008. private _isReady;
  86009. private _compilationError;
  86010. private _attributesNames;
  86011. private _attributes;
  86012. private _uniforms;
  86013. /**
  86014. * Key for the effect.
  86015. * @hidden
  86016. */
  86017. _key: string;
  86018. private _indexParameters;
  86019. private _fallbacks;
  86020. private _vertexSourceCode;
  86021. private _fragmentSourceCode;
  86022. private _vertexSourceCodeOverride;
  86023. private _fragmentSourceCodeOverride;
  86024. private _transformFeedbackVaryings;
  86025. /**
  86026. * Compiled shader to webGL program.
  86027. * @hidden
  86028. */
  86029. _program: WebGLProgram;
  86030. private _valueCache;
  86031. private static _baseCache;
  86032. /**
  86033. * Instantiates an effect.
  86034. * An effect can be used to create/manage/execute vertex and fragment shaders.
  86035. * @param baseName Name of the effect.
  86036. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  86037. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  86038. * @param samplers List of sampler variables that will be passed to the shader.
  86039. * @param engine Engine to be used to render the effect
  86040. * @param defines Define statements to be added to the shader.
  86041. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  86042. * @param onCompiled Callback that will be called when the shader is compiled.
  86043. * @param onError Callback that will be called if an error occurs during shader compilation.
  86044. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  86045. */
  86046. 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);
  86047. /**
  86048. * Unique key for this effect
  86049. */
  86050. readonly key: string;
  86051. /**
  86052. * If the effect has been compiled and prepared.
  86053. * @returns if the effect is compiled and prepared.
  86054. */
  86055. isReady(): boolean;
  86056. /**
  86057. * The engine the effect was initialized with.
  86058. * @returns the engine.
  86059. */
  86060. getEngine(): Engine;
  86061. /**
  86062. * The compiled webGL program for the effect
  86063. * @returns the webGL program.
  86064. */
  86065. getProgram(): WebGLProgram;
  86066. /**
  86067. * The set of names of attribute variables for the shader.
  86068. * @returns An array of attribute names.
  86069. */
  86070. getAttributesNames(): string[];
  86071. /**
  86072. * Returns the attribute at the given index.
  86073. * @param index The index of the attribute.
  86074. * @returns The location of the attribute.
  86075. */
  86076. getAttributeLocation(index: number): number;
  86077. /**
  86078. * Returns the attribute based on the name of the variable.
  86079. * @param name of the attribute to look up.
  86080. * @returns the attribute location.
  86081. */
  86082. getAttributeLocationByName(name: string): number;
  86083. /**
  86084. * The number of attributes.
  86085. * @returns the numnber of attributes.
  86086. */
  86087. getAttributesCount(): number;
  86088. /**
  86089. * Gets the index of a uniform variable.
  86090. * @param uniformName of the uniform to look up.
  86091. * @returns the index.
  86092. */
  86093. getUniformIndex(uniformName: string): number;
  86094. /**
  86095. * Returns the attribute based on the name of the variable.
  86096. * @param uniformName of the uniform to look up.
  86097. * @returns the location of the uniform.
  86098. */
  86099. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  86100. /**
  86101. * Returns an array of sampler variable names
  86102. * @returns The array of sampler variable neames.
  86103. */
  86104. getSamplers(): string[];
  86105. /**
  86106. * The error from the last compilation.
  86107. * @returns the error string.
  86108. */
  86109. getCompilationError(): string;
  86110. /**
  86111. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  86112. * @param func The callback to be used.
  86113. */
  86114. executeWhenCompiled(func: (effect: Effect) => void): void;
  86115. private _checkIsReady;
  86116. /** @hidden */
  86117. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  86118. /** @hidden */
  86119. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  86120. /** @hidden */
  86121. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  86122. private _processShaderConversion;
  86123. private _processIncludes;
  86124. private _processPrecision;
  86125. /**
  86126. * Recompiles the webGL program
  86127. * @param vertexSourceCode The source code for the vertex shader.
  86128. * @param fragmentSourceCode The source code for the fragment shader.
  86129. * @param onCompiled Callback called when completed.
  86130. * @param onError Callback called on error.
  86131. * @hidden
  86132. */
  86133. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  86134. /**
  86135. * Gets the uniform locations of the the specified variable names
  86136. * @param names THe names of the variables to lookup.
  86137. * @returns Array of locations in the same order as variable names.
  86138. */
  86139. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  86140. /**
  86141. * Prepares the effect
  86142. * @hidden
  86143. */
  86144. _prepareEffect(): void;
  86145. /**
  86146. * Checks if the effect is supported. (Must be called after compilation)
  86147. */
  86148. readonly isSupported: boolean;
  86149. /**
  86150. * Binds a texture to the engine to be used as output of the shader.
  86151. * @param channel Name of the output variable.
  86152. * @param texture Texture to bind.
  86153. * @hidden
  86154. */
  86155. _bindTexture(channel: string, texture: InternalTexture): void;
  86156. /**
  86157. * Sets a texture on the engine to be used in the shader.
  86158. * @param channel Name of the sampler variable.
  86159. * @param texture Texture to set.
  86160. */
  86161. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  86162. /**
  86163. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  86164. * @param channel Name of the sampler variable.
  86165. * @param texture Texture to set.
  86166. */
  86167. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  86168. /**
  86169. * Sets an array of textures on the engine to be used in the shader.
  86170. * @param channel Name of the variable.
  86171. * @param textures Textures to set.
  86172. */
  86173. setTextureArray(channel: string, textures: BaseTexture[]): void;
  86174. /**
  86175. * 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)
  86176. * @param channel Name of the sampler variable.
  86177. * @param postProcess Post process to get the input texture from.
  86178. */
  86179. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  86180. /**
  86181. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  86182. * 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)
  86183. * @param channel Name of the sampler variable.
  86184. * @param postProcess Post process to get the output texture from.
  86185. */
  86186. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  86187. /** @hidden */
  86188. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  86189. /** @hidden */
  86190. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  86191. /** @hidden */
  86192. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  86193. /** @hidden */
  86194. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  86195. /**
  86196. * Binds a buffer to a uniform.
  86197. * @param buffer Buffer to bind.
  86198. * @param name Name of the uniform variable to bind to.
  86199. */
  86200. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  86201. /**
  86202. * Binds block to a uniform.
  86203. * @param blockName Name of the block to bind.
  86204. * @param index Index to bind.
  86205. */
  86206. bindUniformBlock(blockName: string, index: number): void;
  86207. /**
  86208. * Sets an interger value on a uniform variable.
  86209. * @param uniformName Name of the variable.
  86210. * @param value Value to be set.
  86211. * @returns this effect.
  86212. */
  86213. setInt(uniformName: string, value: number): Effect;
  86214. /**
  86215. * Sets an int array on a uniform variable.
  86216. * @param uniformName Name of the variable.
  86217. * @param array array to be set.
  86218. * @returns this effect.
  86219. */
  86220. setIntArray(uniformName: string, array: Int32Array): Effect;
  86221. /**
  86222. * 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)
  86223. * @param uniformName Name of the variable.
  86224. * @param array array to be set.
  86225. * @returns this effect.
  86226. */
  86227. setIntArray2(uniformName: string, array: Int32Array): Effect;
  86228. /**
  86229. * 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)
  86230. * @param uniformName Name of the variable.
  86231. * @param array array to be set.
  86232. * @returns this effect.
  86233. */
  86234. setIntArray3(uniformName: string, array: Int32Array): Effect;
  86235. /**
  86236. * 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)
  86237. * @param uniformName Name of the variable.
  86238. * @param array array to be set.
  86239. * @returns this effect.
  86240. */
  86241. setIntArray4(uniformName: string, array: Int32Array): Effect;
  86242. /**
  86243. * Sets an float array on a uniform variable.
  86244. * @param uniformName Name of the variable.
  86245. * @param array array to be set.
  86246. * @returns this effect.
  86247. */
  86248. setFloatArray(uniformName: string, array: Float32Array): Effect;
  86249. /**
  86250. * 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)
  86251. * @param uniformName Name of the variable.
  86252. * @param array array to be set.
  86253. * @returns this effect.
  86254. */
  86255. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  86256. /**
  86257. * 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)
  86258. * @param uniformName Name of the variable.
  86259. * @param array array to be set.
  86260. * @returns this effect.
  86261. */
  86262. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  86263. /**
  86264. * 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)
  86265. * @param uniformName Name of the variable.
  86266. * @param array array to be set.
  86267. * @returns this effect.
  86268. */
  86269. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  86270. /**
  86271. * Sets an array on a uniform variable.
  86272. * @param uniformName Name of the variable.
  86273. * @param array array to be set.
  86274. * @returns this effect.
  86275. */
  86276. setArray(uniformName: string, array: number[]): Effect;
  86277. /**
  86278. * 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)
  86279. * @param uniformName Name of the variable.
  86280. * @param array array to be set.
  86281. * @returns this effect.
  86282. */
  86283. setArray2(uniformName: string, array: number[]): Effect;
  86284. /**
  86285. * 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)
  86286. * @param uniformName Name of the variable.
  86287. * @param array array to be set.
  86288. * @returns this effect.
  86289. */
  86290. setArray3(uniformName: string, array: number[]): Effect;
  86291. /**
  86292. * 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)
  86293. * @param uniformName Name of the variable.
  86294. * @param array array to be set.
  86295. * @returns this effect.
  86296. */
  86297. setArray4(uniformName: string, array: number[]): Effect;
  86298. /**
  86299. * Sets matrices on a uniform variable.
  86300. * @param uniformName Name of the variable.
  86301. * @param matrices matrices to be set.
  86302. * @returns this effect.
  86303. */
  86304. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  86305. /**
  86306. * Sets matrix on a uniform variable.
  86307. * @param uniformName Name of the variable.
  86308. * @param matrix matrix to be set.
  86309. * @returns this effect.
  86310. */
  86311. setMatrix(uniformName: string, matrix: Matrix): Effect;
  86312. /**
  86313. * 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)
  86314. * @param uniformName Name of the variable.
  86315. * @param matrix matrix to be set.
  86316. * @returns this effect.
  86317. */
  86318. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  86319. /**
  86320. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  86321. * @param uniformName Name of the variable.
  86322. * @param matrix matrix to be set.
  86323. * @returns this effect.
  86324. */
  86325. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  86326. /**
  86327. * Sets a float on a uniform variable.
  86328. * @param uniformName Name of the variable.
  86329. * @param value value to be set.
  86330. * @returns this effect.
  86331. */
  86332. setFloat(uniformName: string, value: number): Effect;
  86333. /**
  86334. * Sets a boolean on a uniform variable.
  86335. * @param uniformName Name of the variable.
  86336. * @param bool value to be set.
  86337. * @returns this effect.
  86338. */
  86339. setBool(uniformName: string, bool: boolean): Effect;
  86340. /**
  86341. * Sets a Vector2 on a uniform variable.
  86342. * @param uniformName Name of the variable.
  86343. * @param vector2 vector2 to be set.
  86344. * @returns this effect.
  86345. */
  86346. setVector2(uniformName: string, vector2: Vector2): Effect;
  86347. /**
  86348. * Sets a float2 on a uniform variable.
  86349. * @param uniformName Name of the variable.
  86350. * @param x First float in float2.
  86351. * @param y Second float in float2.
  86352. * @returns this effect.
  86353. */
  86354. setFloat2(uniformName: string, x: number, y: number): Effect;
  86355. /**
  86356. * Sets a Vector3 on a uniform variable.
  86357. * @param uniformName Name of the variable.
  86358. * @param vector3 Value to be set.
  86359. * @returns this effect.
  86360. */
  86361. setVector3(uniformName: string, vector3: Vector3): Effect;
  86362. /**
  86363. * Sets a float3 on a uniform variable.
  86364. * @param uniformName Name of the variable.
  86365. * @param x First float in float3.
  86366. * @param y Second float in float3.
  86367. * @param z Third float in float3.
  86368. * @returns this effect.
  86369. */
  86370. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  86371. /**
  86372. * Sets a Vector4 on a uniform variable.
  86373. * @param uniformName Name of the variable.
  86374. * @param vector4 Value to be set.
  86375. * @returns this effect.
  86376. */
  86377. setVector4(uniformName: string, vector4: Vector4): Effect;
  86378. /**
  86379. * Sets a float4 on a uniform variable.
  86380. * @param uniformName Name of the variable.
  86381. * @param x First float in float4.
  86382. * @param y Second float in float4.
  86383. * @param z Third float in float4.
  86384. * @param w Fourth float in float4.
  86385. * @returns this effect.
  86386. */
  86387. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  86388. /**
  86389. * Sets a Color3 on a uniform variable.
  86390. * @param uniformName Name of the variable.
  86391. * @param color3 Value to be set.
  86392. * @returns this effect.
  86393. */
  86394. setColor3(uniformName: string, color3: Color3): Effect;
  86395. /**
  86396. * Sets a Color4 on a uniform variable.
  86397. * @param uniformName Name of the variable.
  86398. * @param color3 Value to be set.
  86399. * @param alpha Alpha value to be set.
  86400. * @returns this effect.
  86401. */
  86402. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  86403. /**
  86404. * Sets a Color4 on a uniform variable
  86405. * @param uniformName defines the name of the variable
  86406. * @param color4 defines the value to be set
  86407. * @returns this effect.
  86408. */
  86409. setDirectColor4(uniformName: string, color4: Color4): Effect;
  86410. /**
  86411. * This function will add a new shader to the shader store
  86412. * @param name the name of the shader
  86413. * @param pixelShader optional pixel shader content
  86414. * @param vertexShader optional vertex shader content
  86415. */
  86416. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  86417. /**
  86418. * Store of each shader (The can be looked up using effect.key)
  86419. */
  86420. static ShadersStore: {
  86421. [key: string]: string;
  86422. };
  86423. /**
  86424. * Store of each included file for a shader (The can be looked up using effect.key)
  86425. */
  86426. static IncludesShadersStore: {
  86427. [key: string]: string;
  86428. };
  86429. /**
  86430. * Resets the cache of effects.
  86431. */
  86432. static ResetCache(): void;
  86433. }
  86434. }
  86435. declare module BABYLON {
  86436. /**
  86437. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86438. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86439. * 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;
  86440. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86441. */
  86442. export class ColorCurves {
  86443. private _dirty;
  86444. private _tempColor;
  86445. private _globalCurve;
  86446. private _highlightsCurve;
  86447. private _midtonesCurve;
  86448. private _shadowsCurve;
  86449. private _positiveCurve;
  86450. private _negativeCurve;
  86451. private _globalHue;
  86452. private _globalDensity;
  86453. private _globalSaturation;
  86454. private _globalExposure;
  86455. /**
  86456. * Gets the global Hue value.
  86457. * 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).
  86458. */
  86459. /**
  86460. * Sets the global Hue value.
  86461. * 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).
  86462. */
  86463. globalHue: number;
  86464. /**
  86465. * Gets the global Density value.
  86466. * 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.
  86467. * Values less than zero provide a filter of opposite hue.
  86468. */
  86469. /**
  86470. * Sets the global Density value.
  86471. * 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.
  86472. * Values less than zero provide a filter of opposite hue.
  86473. */
  86474. globalDensity: number;
  86475. /**
  86476. * Gets the global Saturation value.
  86477. * 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.
  86478. */
  86479. /**
  86480. * Sets the global Saturation value.
  86481. * 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.
  86482. */
  86483. globalSaturation: number;
  86484. /**
  86485. * Gets the global Exposure value.
  86486. * 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.
  86487. */
  86488. /**
  86489. * Sets the global Exposure value.
  86490. * 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.
  86491. */
  86492. globalExposure: number;
  86493. private _highlightsHue;
  86494. private _highlightsDensity;
  86495. private _highlightsSaturation;
  86496. private _highlightsExposure;
  86497. /**
  86498. * Gets the highlights Hue value.
  86499. * 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).
  86500. */
  86501. /**
  86502. * Sets the highlights Hue value.
  86503. * 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).
  86504. */
  86505. highlightsHue: number;
  86506. /**
  86507. * Gets the highlights Density value.
  86508. * 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.
  86509. * Values less than zero provide a filter of opposite hue.
  86510. */
  86511. /**
  86512. * Sets the highlights Density value.
  86513. * 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.
  86514. * Values less than zero provide a filter of opposite hue.
  86515. */
  86516. highlightsDensity: number;
  86517. /**
  86518. * Gets the highlights Saturation value.
  86519. * 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.
  86520. */
  86521. /**
  86522. * Sets the highlights Saturation value.
  86523. * 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.
  86524. */
  86525. highlightsSaturation: number;
  86526. /**
  86527. * Gets the highlights Exposure value.
  86528. * 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.
  86529. */
  86530. /**
  86531. * Sets the highlights Exposure value.
  86532. * 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.
  86533. */
  86534. highlightsExposure: number;
  86535. private _midtonesHue;
  86536. private _midtonesDensity;
  86537. private _midtonesSaturation;
  86538. private _midtonesExposure;
  86539. /**
  86540. * Gets the midtones Hue value.
  86541. * 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).
  86542. */
  86543. /**
  86544. * Sets the midtones Hue value.
  86545. * 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).
  86546. */
  86547. midtonesHue: number;
  86548. /**
  86549. * Gets the midtones Density value.
  86550. * 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.
  86551. * Values less than zero provide a filter of opposite hue.
  86552. */
  86553. /**
  86554. * Sets the midtones Density value.
  86555. * 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.
  86556. * Values less than zero provide a filter of opposite hue.
  86557. */
  86558. midtonesDensity: number;
  86559. /**
  86560. * Gets the midtones Saturation value.
  86561. * 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.
  86562. */
  86563. /**
  86564. * Sets the midtones Saturation value.
  86565. * 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.
  86566. */
  86567. midtonesSaturation: number;
  86568. /**
  86569. * Gets the midtones Exposure value.
  86570. * 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.
  86571. */
  86572. /**
  86573. * Sets the midtones Exposure value.
  86574. * 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.
  86575. */
  86576. midtonesExposure: number;
  86577. private _shadowsHue;
  86578. private _shadowsDensity;
  86579. private _shadowsSaturation;
  86580. private _shadowsExposure;
  86581. /**
  86582. * Gets the shadows Hue value.
  86583. * 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).
  86584. */
  86585. /**
  86586. * Sets the shadows Hue value.
  86587. * 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).
  86588. */
  86589. shadowsHue: number;
  86590. /**
  86591. * Gets the shadows Density value.
  86592. * 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.
  86593. * Values less than zero provide a filter of opposite hue.
  86594. */
  86595. /**
  86596. * Sets the shadows Density value.
  86597. * 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.
  86598. * Values less than zero provide a filter of opposite hue.
  86599. */
  86600. shadowsDensity: number;
  86601. /**
  86602. * Gets the shadows Saturation value.
  86603. * 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.
  86604. */
  86605. /**
  86606. * Sets the shadows Saturation value.
  86607. * 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.
  86608. */
  86609. shadowsSaturation: number;
  86610. /**
  86611. * Gets the shadows Exposure value.
  86612. * 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.
  86613. */
  86614. /**
  86615. * Sets the shadows Exposure value.
  86616. * 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.
  86617. */
  86618. shadowsExposure: number;
  86619. /**
  86620. * Returns the class name
  86621. * @returns The class name
  86622. */
  86623. getClassName(): string;
  86624. /**
  86625. * Binds the color curves to the shader.
  86626. * @param colorCurves The color curve to bind
  86627. * @param effect The effect to bind to
  86628. * @param positiveUniform The positive uniform shader parameter
  86629. * @param neutralUniform The neutral uniform shader parameter
  86630. * @param negativeUniform The negative uniform shader parameter
  86631. */
  86632. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86633. /**
  86634. * Prepare the list of uniforms associated with the ColorCurves effects.
  86635. * @param uniformsList The list of uniforms used in the effect
  86636. */
  86637. static PrepareUniforms(uniformsList: string[]): void;
  86638. /**
  86639. * Returns color grading data based on a hue, density, saturation and exposure value.
  86640. * @param filterHue The hue of the color filter.
  86641. * @param filterDensity The density of the color filter.
  86642. * @param saturation The saturation.
  86643. * @param exposure The exposure.
  86644. * @param result The result data container.
  86645. */
  86646. private getColorGradingDataToRef;
  86647. /**
  86648. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86649. * @param value The input slider value in range [-100,100].
  86650. * @returns Adjusted value.
  86651. */
  86652. private static applyColorGradingSliderNonlinear;
  86653. /**
  86654. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86655. * @param hue The hue (H) input.
  86656. * @param saturation The saturation (S) input.
  86657. * @param brightness The brightness (B) input.
  86658. * @result An RGBA color represented as Vector4.
  86659. */
  86660. private static fromHSBToRef;
  86661. /**
  86662. * Returns a value clamped between min and max
  86663. * @param value The value to clamp
  86664. * @param min The minimum of value
  86665. * @param max The maximum of value
  86666. * @returns The clamped value.
  86667. */
  86668. private static clamp;
  86669. /**
  86670. * Clones the current color curve instance.
  86671. * @return The cloned curves
  86672. */
  86673. clone(): ColorCurves;
  86674. /**
  86675. * Serializes the current color curve instance to a json representation.
  86676. * @return a JSON representation
  86677. */
  86678. serialize(): any;
  86679. /**
  86680. * Parses the color curve from a json representation.
  86681. * @param source the JSON source to parse
  86682. * @return The parsed curves
  86683. */
  86684. static Parse(source: any): ColorCurves;
  86685. }
  86686. }
  86687. declare module BABYLON {
  86688. /**
  86689. * Interface to follow in your material defines to integrate easily the
  86690. * Image proccessing functions.
  86691. * @hidden
  86692. */
  86693. export interface IImageProcessingConfigurationDefines {
  86694. IMAGEPROCESSING: boolean;
  86695. VIGNETTE: boolean;
  86696. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86697. VIGNETTEBLENDMODEOPAQUE: boolean;
  86698. TONEMAPPING: boolean;
  86699. TONEMAPPING_ACES: boolean;
  86700. CONTRAST: boolean;
  86701. EXPOSURE: boolean;
  86702. COLORCURVES: boolean;
  86703. COLORGRADING: boolean;
  86704. COLORGRADING3D: boolean;
  86705. SAMPLER3DGREENDEPTH: boolean;
  86706. SAMPLER3DBGRMAP: boolean;
  86707. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86708. }
  86709. /**
  86710. * @hidden
  86711. */
  86712. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86713. IMAGEPROCESSING: boolean;
  86714. VIGNETTE: boolean;
  86715. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86716. VIGNETTEBLENDMODEOPAQUE: boolean;
  86717. TONEMAPPING: boolean;
  86718. TONEMAPPING_ACES: boolean;
  86719. CONTRAST: boolean;
  86720. COLORCURVES: boolean;
  86721. COLORGRADING: boolean;
  86722. COLORGRADING3D: boolean;
  86723. SAMPLER3DGREENDEPTH: boolean;
  86724. SAMPLER3DBGRMAP: boolean;
  86725. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86726. EXPOSURE: boolean;
  86727. constructor();
  86728. }
  86729. /**
  86730. * This groups together the common properties used for image processing either in direct forward pass
  86731. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86732. * or not.
  86733. */
  86734. export class ImageProcessingConfiguration {
  86735. /**
  86736. * Default tone mapping applied in BabylonJS.
  86737. */
  86738. static readonly TONEMAPPING_STANDARD: number;
  86739. /**
  86740. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86741. * to other engines rendering to increase portability.
  86742. */
  86743. static readonly TONEMAPPING_ACES: number;
  86744. /**
  86745. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86746. */
  86747. colorCurves: Nullable<ColorCurves>;
  86748. private _colorCurvesEnabled;
  86749. /**
  86750. * Gets wether the color curves effect is enabled.
  86751. */
  86752. /**
  86753. * Sets wether the color curves effect is enabled.
  86754. */
  86755. colorCurvesEnabled: boolean;
  86756. private _colorGradingTexture;
  86757. /**
  86758. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86759. */
  86760. /**
  86761. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86762. */
  86763. colorGradingTexture: Nullable<BaseTexture>;
  86764. private _colorGradingEnabled;
  86765. /**
  86766. * Gets wether the color grading effect is enabled.
  86767. */
  86768. /**
  86769. * Sets wether the color grading effect is enabled.
  86770. */
  86771. colorGradingEnabled: boolean;
  86772. private _colorGradingWithGreenDepth;
  86773. /**
  86774. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86775. */
  86776. /**
  86777. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86778. */
  86779. colorGradingWithGreenDepth: boolean;
  86780. private _colorGradingBGR;
  86781. /**
  86782. * Gets wether the color grading texture contains BGR values.
  86783. */
  86784. /**
  86785. * Sets wether the color grading texture contains BGR values.
  86786. */
  86787. colorGradingBGR: boolean;
  86788. /** @hidden */
  86789. _exposure: number;
  86790. /**
  86791. * Gets the Exposure used in the effect.
  86792. */
  86793. /**
  86794. * Sets the Exposure used in the effect.
  86795. */
  86796. exposure: number;
  86797. private _toneMappingEnabled;
  86798. /**
  86799. * Gets wether the tone mapping effect is enabled.
  86800. */
  86801. /**
  86802. * Sets wether the tone mapping effect is enabled.
  86803. */
  86804. toneMappingEnabled: boolean;
  86805. private _toneMappingType;
  86806. /**
  86807. * Gets the type of tone mapping effect.
  86808. */
  86809. /**
  86810. * Sets the type of tone mapping effect used in BabylonJS.
  86811. */
  86812. toneMappingType: number;
  86813. protected _contrast: number;
  86814. /**
  86815. * Gets the contrast used in the effect.
  86816. */
  86817. /**
  86818. * Sets the contrast used in the effect.
  86819. */
  86820. contrast: number;
  86821. /**
  86822. * Vignette stretch size.
  86823. */
  86824. vignetteStretch: number;
  86825. /**
  86826. * Vignette centre X Offset.
  86827. */
  86828. vignetteCentreX: number;
  86829. /**
  86830. * Vignette centre Y Offset.
  86831. */
  86832. vignetteCentreY: number;
  86833. /**
  86834. * Vignette weight or intensity of the vignette effect.
  86835. */
  86836. vignetteWeight: number;
  86837. /**
  86838. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86839. * if vignetteEnabled is set to true.
  86840. */
  86841. vignetteColor: Color4;
  86842. /**
  86843. * Camera field of view used by the Vignette effect.
  86844. */
  86845. vignetteCameraFov: number;
  86846. private _vignetteBlendMode;
  86847. /**
  86848. * Gets the vignette blend mode allowing different kind of effect.
  86849. */
  86850. /**
  86851. * Sets the vignette blend mode allowing different kind of effect.
  86852. */
  86853. vignetteBlendMode: number;
  86854. private _vignetteEnabled;
  86855. /**
  86856. * Gets wether the vignette effect is enabled.
  86857. */
  86858. /**
  86859. * Sets wether the vignette effect is enabled.
  86860. */
  86861. vignetteEnabled: boolean;
  86862. private _applyByPostProcess;
  86863. /**
  86864. * Gets wether the image processing is applied through a post process or not.
  86865. */
  86866. /**
  86867. * Sets wether the image processing is applied through a post process or not.
  86868. */
  86869. applyByPostProcess: boolean;
  86870. private _isEnabled;
  86871. /**
  86872. * Gets wether the image processing is enabled or not.
  86873. */
  86874. /**
  86875. * Sets wether the image processing is enabled or not.
  86876. */
  86877. isEnabled: boolean;
  86878. /**
  86879. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86880. */
  86881. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86882. /**
  86883. * Method called each time the image processing information changes requires to recompile the effect.
  86884. */
  86885. protected _updateParameters(): void;
  86886. /**
  86887. * Gets the current class name.
  86888. * @return "ImageProcessingConfiguration"
  86889. */
  86890. getClassName(): string;
  86891. /**
  86892. * Prepare the list of uniforms associated with the Image Processing effects.
  86893. * @param uniforms The list of uniforms used in the effect
  86894. * @param defines the list of defines currently in use
  86895. */
  86896. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86897. /**
  86898. * Prepare the list of samplers associated with the Image Processing effects.
  86899. * @param samplersList The list of uniforms used in the effect
  86900. * @param defines the list of defines currently in use
  86901. */
  86902. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86903. /**
  86904. * Prepare the list of defines associated to the shader.
  86905. * @param defines the list of defines to complete
  86906. * @param forPostProcess Define if we are currently in post process mode or not
  86907. */
  86908. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86909. /**
  86910. * Returns true if all the image processing information are ready.
  86911. * @returns True if ready, otherwise, false
  86912. */
  86913. isReady(): boolean;
  86914. /**
  86915. * Binds the image processing to the shader.
  86916. * @param effect The effect to bind to
  86917. * @param aspectRatio Define the current aspect ratio of the effect
  86918. */
  86919. bind(effect: Effect, aspectRatio?: number): void;
  86920. /**
  86921. * Clones the current image processing instance.
  86922. * @return The cloned image processing
  86923. */
  86924. clone(): ImageProcessingConfiguration;
  86925. /**
  86926. * Serializes the current image processing instance to a json representation.
  86927. * @return a JSON representation
  86928. */
  86929. serialize(): any;
  86930. /**
  86931. * Parses the image processing from a json representation.
  86932. * @param source the JSON source to parse
  86933. * @return The parsed image processing
  86934. */
  86935. static Parse(source: any): ImageProcessingConfiguration;
  86936. private static _VIGNETTEMODE_MULTIPLY;
  86937. private static _VIGNETTEMODE_OPAQUE;
  86938. /**
  86939. * Used to apply the vignette as a mix with the pixel color.
  86940. */
  86941. static readonly VIGNETTEMODE_MULTIPLY: number;
  86942. /**
  86943. * Used to apply the vignette as a replacement of the pixel color.
  86944. */
  86945. static readonly VIGNETTEMODE_OPAQUE: number;
  86946. }
  86947. }
  86948. declare module BABYLON {
  86949. /**
  86950. * This represents all the required information to add a fresnel effect on a material:
  86951. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  86952. */
  86953. export class FresnelParameters {
  86954. private _isEnabled;
  86955. /**
  86956. * Define if the fresnel effect is enable or not.
  86957. */
  86958. isEnabled: boolean;
  86959. /**
  86960. * Define the color used on edges (grazing angle)
  86961. */
  86962. leftColor: Color3;
  86963. /**
  86964. * Define the color used on center
  86965. */
  86966. rightColor: Color3;
  86967. /**
  86968. * Define bias applied to computed fresnel term
  86969. */
  86970. bias: number;
  86971. /**
  86972. * Defined the power exponent applied to fresnel term
  86973. */
  86974. power: number;
  86975. /**
  86976. * Clones the current fresnel and its valuues
  86977. * @returns a clone fresnel configuration
  86978. */
  86979. clone(): FresnelParameters;
  86980. /**
  86981. * Serializes the current fresnel parameters to a JSON representation.
  86982. * @return the JSON serialization
  86983. */
  86984. serialize(): any;
  86985. /**
  86986. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  86987. * @param parsedFresnelParameters Define the JSON representation
  86988. * @returns the parsed parameters
  86989. */
  86990. static Parse(parsedFresnelParameters: any): FresnelParameters;
  86991. }
  86992. }
  86993. declare module BABYLON {
  86994. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  86995. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86996. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86997. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86998. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  86999. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87000. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87001. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87002. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87003. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87004. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87005. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87006. /**
  87007. * Decorator used to define property that can be serialized as reference to a camera
  87008. * @param sourceName defines the name of the property to decorate
  87009. */
  87010. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  87011. /**
  87012. * Class used to help serialization objects
  87013. */
  87014. export class SerializationHelper {
  87015. /** hidden */
  87016. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  87017. /** hidden */
  87018. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  87019. /** hidden */
  87020. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  87021. /** hidden */
  87022. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  87023. /**
  87024. * Appends the serialized animations from the source animations
  87025. * @param source Source containing the animations
  87026. * @param destination Target to store the animations
  87027. */
  87028. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  87029. /**
  87030. * Static function used to serialized a specific entity
  87031. * @param entity defines the entity to serialize
  87032. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  87033. * @returns a JSON compatible object representing the serialization of the entity
  87034. */
  87035. static Serialize<T>(entity: T, serializationObject?: any): any;
  87036. /**
  87037. * Creates a new entity from a serialization data object
  87038. * @param creationFunction defines a function used to instanciated the new entity
  87039. * @param source defines the source serialization data
  87040. * @param scene defines the hosting scene
  87041. * @param rootUrl defines the root url for resources
  87042. * @returns a new entity
  87043. */
  87044. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  87045. /**
  87046. * Clones an object
  87047. * @param creationFunction defines the function used to instanciate the new object
  87048. * @param source defines the source object
  87049. * @returns the cloned object
  87050. */
  87051. static Clone<T>(creationFunction: () => T, source: T): T;
  87052. /**
  87053. * Instanciates a new object based on a source one (some data will be shared between both object)
  87054. * @param creationFunction defines the function used to instanciate the new object
  87055. * @param source defines the source object
  87056. * @returns the new object
  87057. */
  87058. static Instanciate<T>(creationFunction: () => T, source: T): T;
  87059. }
  87060. }
  87061. declare module BABYLON {
  87062. /**
  87063. * This is the base class of all the camera used in the application.
  87064. * @see http://doc.babylonjs.com/features/cameras
  87065. */
  87066. export class Camera extends Node {
  87067. /** @hidden */
  87068. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  87069. /**
  87070. * This is the default projection mode used by the cameras.
  87071. * It helps recreating a feeling of perspective and better appreciate depth.
  87072. * This is the best way to simulate real life cameras.
  87073. */
  87074. static readonly PERSPECTIVE_CAMERA: number;
  87075. /**
  87076. * This helps creating camera with an orthographic mode.
  87077. * 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.
  87078. */
  87079. static readonly ORTHOGRAPHIC_CAMERA: number;
  87080. /**
  87081. * This is the default FOV mode for perspective cameras.
  87082. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  87083. */
  87084. static readonly FOVMODE_VERTICAL_FIXED: number;
  87085. /**
  87086. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  87087. */
  87088. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  87089. /**
  87090. * This specifies ther is no need for a camera rig.
  87091. * Basically only one eye is rendered corresponding to the camera.
  87092. */
  87093. static readonly RIG_MODE_NONE: number;
  87094. /**
  87095. * Simulates a camera Rig with one blue eye and one red eye.
  87096. * This can be use with 3d blue and red glasses.
  87097. */
  87098. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  87099. /**
  87100. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  87101. */
  87102. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  87103. /**
  87104. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  87105. */
  87106. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  87107. /**
  87108. * Defines that both eyes of the camera will be rendered over under each other.
  87109. */
  87110. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  87111. /**
  87112. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  87113. */
  87114. static readonly RIG_MODE_VR: number;
  87115. /**
  87116. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  87117. */
  87118. static readonly RIG_MODE_WEBVR: number;
  87119. /**
  87120. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  87121. */
  87122. static readonly RIG_MODE_CUSTOM: number;
  87123. /**
  87124. * Defines if by default attaching controls should prevent the default javascript event to continue.
  87125. */
  87126. static ForceAttachControlToAlwaysPreventDefault: boolean;
  87127. /**
  87128. * @hidden
  87129. * Might be removed once multiview will be a thing
  87130. */
  87131. static UseAlternateWebVRRendering: boolean;
  87132. /**
  87133. * Define the input manager associated with the camera.
  87134. */
  87135. inputs: CameraInputsManager<Camera>;
  87136. /** @hidden */
  87137. _position: Vector3;
  87138. /**
  87139. * Define the current local position of the camera in the scene
  87140. */
  87141. position: Vector3;
  87142. /**
  87143. * The vector the camera should consider as up.
  87144. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  87145. */
  87146. upVector: Vector3;
  87147. /**
  87148. * Define the current limit on the left side for an orthographic camera
  87149. * In scene unit
  87150. */
  87151. orthoLeft: Nullable<number>;
  87152. /**
  87153. * Define the current limit on the right side for an orthographic camera
  87154. * In scene unit
  87155. */
  87156. orthoRight: Nullable<number>;
  87157. /**
  87158. * Define the current limit on the bottom side for an orthographic camera
  87159. * In scene unit
  87160. */
  87161. orthoBottom: Nullable<number>;
  87162. /**
  87163. * Define the current limit on the top side for an orthographic camera
  87164. * In scene unit
  87165. */
  87166. orthoTop: Nullable<number>;
  87167. /**
  87168. * Field Of View is set in Radians. (default is 0.8)
  87169. */
  87170. fov: number;
  87171. /**
  87172. * Define the minimum distance the camera can see from.
  87173. * This is important to note that the depth buffer are not infinite and the closer it starts
  87174. * the more your scene might encounter depth fighting issue.
  87175. */
  87176. minZ: number;
  87177. /**
  87178. * Define the maximum distance the camera can see to.
  87179. * This is important to note that the depth buffer are not infinite and the further it end
  87180. * the more your scene might encounter depth fighting issue.
  87181. */
  87182. maxZ: number;
  87183. /**
  87184. * Define the default inertia of the camera.
  87185. * This helps giving a smooth feeling to the camera movement.
  87186. */
  87187. inertia: number;
  87188. /**
  87189. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  87190. */
  87191. mode: number;
  87192. /**
  87193. * Define wether the camera is intermediate.
  87194. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  87195. */
  87196. isIntermediate: boolean;
  87197. /**
  87198. * Define the viewport of the camera.
  87199. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  87200. */
  87201. viewport: Viewport;
  87202. /**
  87203. * Restricts the camera to viewing objects with the same layerMask.
  87204. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  87205. */
  87206. layerMask: number;
  87207. /**
  87208. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  87209. */
  87210. fovMode: number;
  87211. /**
  87212. * Rig mode of the camera.
  87213. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  87214. * This is normally controlled byt the camera themselves as internal use.
  87215. */
  87216. cameraRigMode: number;
  87217. /**
  87218. * Defines the distance between both "eyes" in case of a RIG
  87219. */
  87220. interaxialDistance: number;
  87221. /**
  87222. * Defines if stereoscopic rendering is done side by side or over under.
  87223. */
  87224. isStereoscopicSideBySide: boolean;
  87225. /**
  87226. * 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
  87227. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  87228. * else in the scene.
  87229. */
  87230. customRenderTargets: RenderTargetTexture[];
  87231. /**
  87232. * When set, the camera will render to this render target instead of the default canvas
  87233. */
  87234. outputRenderTarget: Nullable<RenderTargetTexture>;
  87235. /**
  87236. * Observable triggered when the camera view matrix has changed.
  87237. */
  87238. onViewMatrixChangedObservable: Observable<Camera>;
  87239. /**
  87240. * Observable triggered when the camera Projection matrix has changed.
  87241. */
  87242. onProjectionMatrixChangedObservable: Observable<Camera>;
  87243. /**
  87244. * Observable triggered when the inputs have been processed.
  87245. */
  87246. onAfterCheckInputsObservable: Observable<Camera>;
  87247. /**
  87248. * Observable triggered when reset has been called and applied to the camera.
  87249. */
  87250. onRestoreStateObservable: Observable<Camera>;
  87251. /** @hidden */
  87252. _cameraRigParams: any;
  87253. /** @hidden */
  87254. _rigCameras: Camera[];
  87255. /** @hidden */
  87256. _rigPostProcess: Nullable<PostProcess>;
  87257. protected _webvrViewMatrix: Matrix;
  87258. /** @hidden */
  87259. _skipRendering: boolean;
  87260. /** @hidden */
  87261. _alternateCamera: Camera;
  87262. /** @hidden */
  87263. _projectionMatrix: Matrix;
  87264. /** @hidden */
  87265. _postProcesses: Nullable<PostProcess>[];
  87266. /** @hidden */
  87267. _activeMeshes: SmartArray<AbstractMesh>;
  87268. protected _globalPosition: Vector3;
  87269. /** hidden */
  87270. _computedViewMatrix: Matrix;
  87271. private _doNotComputeProjectionMatrix;
  87272. private _transformMatrix;
  87273. private _frustumPlanes;
  87274. private _refreshFrustumPlanes;
  87275. private _storedFov;
  87276. private _stateStored;
  87277. /**
  87278. * Instantiates a new camera object.
  87279. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  87280. * @see http://doc.babylonjs.com/features/cameras
  87281. * @param name Defines the name of the camera in the scene
  87282. * @param position Defines the position of the camera
  87283. * @param scene Defines the scene the camera belongs too
  87284. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  87285. */
  87286. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  87287. /**
  87288. * Store current camera state (fov, position, etc..)
  87289. * @returns the camera
  87290. */
  87291. storeState(): Camera;
  87292. /**
  87293. * Restores the camera state values if it has been stored. You must call storeState() first
  87294. */
  87295. protected _restoreStateValues(): boolean;
  87296. /**
  87297. * Restored camera state. You must call storeState() first.
  87298. * @returns true if restored and false otherwise
  87299. */
  87300. restoreState(): boolean;
  87301. /**
  87302. * Gets the class name of the camera.
  87303. * @returns the class name
  87304. */
  87305. getClassName(): string;
  87306. /** @hidden */
  87307. readonly _isCamera: boolean;
  87308. /**
  87309. * Gets a string representation of the camera useful for debug purpose.
  87310. * @param fullDetails Defines that a more verboe level of logging is required
  87311. * @returns the string representation
  87312. */
  87313. toString(fullDetails?: boolean): string;
  87314. /**
  87315. * Gets the current world space position of the camera.
  87316. */
  87317. readonly globalPosition: Vector3;
  87318. /**
  87319. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  87320. * @returns the active meshe list
  87321. */
  87322. getActiveMeshes(): SmartArray<AbstractMesh>;
  87323. /**
  87324. * Check wether a mesh is part of the current active mesh list of the camera
  87325. * @param mesh Defines the mesh to check
  87326. * @returns true if active, false otherwise
  87327. */
  87328. isActiveMesh(mesh: Mesh): boolean;
  87329. /**
  87330. * Is this camera ready to be used/rendered
  87331. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  87332. * @return true if the camera is ready
  87333. */
  87334. isReady(completeCheck?: boolean): boolean;
  87335. /** @hidden */
  87336. _initCache(): void;
  87337. /** @hidden */
  87338. _updateCache(ignoreParentClass?: boolean): void;
  87339. /** @hidden */
  87340. _isSynchronized(): boolean;
  87341. /** @hidden */
  87342. _isSynchronizedViewMatrix(): boolean;
  87343. /** @hidden */
  87344. _isSynchronizedProjectionMatrix(): boolean;
  87345. /**
  87346. * Attach the input controls to a specific dom element to get the input from.
  87347. * @param element Defines the element the controls should be listened from
  87348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87349. */
  87350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87351. /**
  87352. * Detach the current controls from the specified dom element.
  87353. * @param element Defines the element to stop listening the inputs from
  87354. */
  87355. detachControl(element: HTMLElement): void;
  87356. /**
  87357. * Update the camera state according to the different inputs gathered during the frame.
  87358. */
  87359. update(): void;
  87360. /** @hidden */
  87361. _checkInputs(): void;
  87362. /** @hidden */
  87363. readonly rigCameras: Camera[];
  87364. /**
  87365. * Gets the post process used by the rig cameras
  87366. */
  87367. readonly rigPostProcess: Nullable<PostProcess>;
  87368. /**
  87369. * Internal, gets the first post proces.
  87370. * @returns the first post process to be run on this camera.
  87371. */
  87372. _getFirstPostProcess(): Nullable<PostProcess>;
  87373. private _cascadePostProcessesToRigCams;
  87374. /**
  87375. * Attach a post process to the camera.
  87376. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87377. * @param postProcess The post process to attach to the camera
  87378. * @param insertAt The position of the post process in case several of them are in use in the scene
  87379. * @returns the position the post process has been inserted at
  87380. */
  87381. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  87382. /**
  87383. * Detach a post process to the camera.
  87384. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  87385. * @param postProcess The post process to detach from the camera
  87386. */
  87387. detachPostProcess(postProcess: PostProcess): void;
  87388. /**
  87389. * Gets the current world matrix of the camera
  87390. */
  87391. getWorldMatrix(): Matrix;
  87392. /** @hidden */
  87393. _getViewMatrix(): Matrix;
  87394. /**
  87395. * Gets the current view matrix of the camera.
  87396. * @param force forces the camera to recompute the matrix without looking at the cached state
  87397. * @returns the view matrix
  87398. */
  87399. getViewMatrix(force?: boolean): Matrix;
  87400. /**
  87401. * Freeze the projection matrix.
  87402. * It will prevent the cache check of the camera projection compute and can speed up perf
  87403. * if no parameter of the camera are meant to change
  87404. * @param projection Defines manually a projection if necessary
  87405. */
  87406. freezeProjectionMatrix(projection?: Matrix): void;
  87407. /**
  87408. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  87409. */
  87410. unfreezeProjectionMatrix(): void;
  87411. /**
  87412. * Gets the current projection matrix of the camera.
  87413. * @param force forces the camera to recompute the matrix without looking at the cached state
  87414. * @returns the projection matrix
  87415. */
  87416. getProjectionMatrix(force?: boolean): Matrix;
  87417. /**
  87418. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  87419. * @returns a Matrix
  87420. */
  87421. getTransformationMatrix(): Matrix;
  87422. private _updateFrustumPlanes;
  87423. /**
  87424. * Checks if a cullable object (mesh...) is in the camera frustum
  87425. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  87426. * @param target The object to check
  87427. * @returns true if the object is in frustum otherwise false
  87428. */
  87429. isInFrustum(target: ICullable): boolean;
  87430. /**
  87431. * Checks if a cullable object (mesh...) is in the camera frustum
  87432. * Unlike isInFrustum this cheks the full bounding box
  87433. * @param target The object to check
  87434. * @returns true if the object is in frustum otherwise false
  87435. */
  87436. isCompletelyInFrustum(target: ICullable): boolean;
  87437. /**
  87438. * Gets a ray in the forward direction from the camera.
  87439. * @param length Defines the length of the ray to create
  87440. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  87441. * @param origin Defines the start point of the ray which defaults to the camera position
  87442. * @returns the forward ray
  87443. */
  87444. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  87445. /**
  87446. * Releases resources associated with this node.
  87447. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87448. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87449. */
  87450. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87451. /** @hidden */
  87452. _isLeftCamera: boolean;
  87453. /**
  87454. * Gets the left camera of a rig setup in case of Rigged Camera
  87455. */
  87456. readonly isLeftCamera: boolean;
  87457. /** @hidden */
  87458. _isRightCamera: boolean;
  87459. /**
  87460. * Gets the right camera of a rig setup in case of Rigged Camera
  87461. */
  87462. readonly isRightCamera: boolean;
  87463. /**
  87464. * Gets the left camera of a rig setup in case of Rigged Camera
  87465. */
  87466. readonly leftCamera: Nullable<FreeCamera>;
  87467. /**
  87468. * Gets the right camera of a rig setup in case of Rigged Camera
  87469. */
  87470. readonly rightCamera: Nullable<FreeCamera>;
  87471. /**
  87472. * Gets the left camera target of a rig setup in case of Rigged Camera
  87473. * @returns the target position
  87474. */
  87475. getLeftTarget(): Nullable<Vector3>;
  87476. /**
  87477. * Gets the right camera target of a rig setup in case of Rigged Camera
  87478. * @returns the target position
  87479. */
  87480. getRightTarget(): Nullable<Vector3>;
  87481. /**
  87482. * @hidden
  87483. */
  87484. setCameraRigMode(mode: number, rigParams: any): void;
  87485. /** @hidden */
  87486. static _setStereoscopicRigMode(camera: Camera): void;
  87487. /** @hidden */
  87488. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  87489. /** @hidden */
  87490. static _setVRRigMode(camera: Camera, rigParams: any): void;
  87491. /** @hidden */
  87492. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  87493. /** @hidden */
  87494. _getVRProjectionMatrix(): Matrix;
  87495. protected _updateCameraRotationMatrix(): void;
  87496. protected _updateWebVRCameraRotationMatrix(): void;
  87497. /**
  87498. * This function MUST be overwritten by the different WebVR cameras available.
  87499. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87500. * @hidden
  87501. */
  87502. _getWebVRProjectionMatrix(): Matrix;
  87503. /**
  87504. * This function MUST be overwritten by the different WebVR cameras available.
  87505. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  87506. * @hidden
  87507. */
  87508. _getWebVRViewMatrix(): Matrix;
  87509. /** @hidden */
  87510. setCameraRigParameter(name: string, value: any): void;
  87511. /**
  87512. * needs to be overridden by children so sub has required properties to be copied
  87513. * @hidden
  87514. */
  87515. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  87516. /**
  87517. * May need to be overridden by children
  87518. * @hidden
  87519. */
  87520. _updateRigCameras(): void;
  87521. /** @hidden */
  87522. _setupInputs(): void;
  87523. /**
  87524. * Serialiaze the camera setup to a json represention
  87525. * @returns the JSON representation
  87526. */
  87527. serialize(): any;
  87528. /**
  87529. * Clones the current camera.
  87530. * @param name The cloned camera name
  87531. * @returns the cloned camera
  87532. */
  87533. clone(name: string): Camera;
  87534. /**
  87535. * Gets the direction of the camera relative to a given local axis.
  87536. * @param localAxis Defines the reference axis to provide a relative direction.
  87537. * @return the direction
  87538. */
  87539. getDirection(localAxis: Vector3): Vector3;
  87540. /**
  87541. * Gets the direction of the camera relative to a given local axis into a passed vector.
  87542. * @param localAxis Defines the reference axis to provide a relative direction.
  87543. * @param result Defines the vector to store the result in
  87544. */
  87545. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  87546. /**
  87547. * Gets a camera constructor for a given camera type
  87548. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  87549. * @param name The name of the camera the result will be able to instantiate
  87550. * @param scene The scene the result will construct the camera in
  87551. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  87552. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  87553. * @returns a factory method to construc the camera
  87554. */
  87555. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  87556. /**
  87557. * Compute the world matrix of the camera.
  87558. * @returns the camera workd matrix
  87559. */
  87560. computeWorldMatrix(): Matrix;
  87561. /**
  87562. * Parse a JSON and creates the camera from the parsed information
  87563. * @param parsedCamera The JSON to parse
  87564. * @param scene The scene to instantiate the camera in
  87565. * @returns the newly constructed camera
  87566. */
  87567. static Parse(parsedCamera: any, scene: Scene): Camera;
  87568. }
  87569. }
  87570. declare module BABYLON {
  87571. /**
  87572. * Interface for any object that can request an animation frame
  87573. */
  87574. export interface ICustomAnimationFrameRequester {
  87575. /**
  87576. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  87577. */
  87578. renderFunction?: Function;
  87579. /**
  87580. * Called to request the next frame to render to
  87581. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  87582. */
  87583. requestAnimationFrame: Function;
  87584. /**
  87585. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  87586. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  87587. */
  87588. requestID?: number;
  87589. }
  87590. /**
  87591. * Interface containing an array of animations
  87592. */
  87593. export interface IAnimatable {
  87594. /**
  87595. * Array of animations
  87596. */
  87597. animations: Array<Animation>;
  87598. }
  87599. /** Interface used by value gradients (color, factor, ...) */
  87600. export interface IValueGradient {
  87601. /**
  87602. * Gets or sets the gradient value (between 0 and 1)
  87603. */
  87604. gradient: number;
  87605. }
  87606. /** Class used to store color4 gradient */
  87607. export class ColorGradient implements IValueGradient {
  87608. /**
  87609. * Gets or sets the gradient value (between 0 and 1)
  87610. */
  87611. gradient: number;
  87612. /**
  87613. * Gets or sets first associated color
  87614. */
  87615. color1: Color4;
  87616. /**
  87617. * Gets or sets second associated color
  87618. */
  87619. color2?: Color4;
  87620. /**
  87621. * Will get a color picked randomly between color1 and color2.
  87622. * If color2 is undefined then color1 will be used
  87623. * @param result defines the target Color4 to store the result in
  87624. */
  87625. getColorToRef(result: Color4): void;
  87626. }
  87627. /** Class used to store color 3 gradient */
  87628. export class Color3Gradient implements IValueGradient {
  87629. /**
  87630. * Gets or sets the gradient value (between 0 and 1)
  87631. */
  87632. gradient: number;
  87633. /**
  87634. * Gets or sets the associated color
  87635. */
  87636. color: Color3;
  87637. }
  87638. /** Class used to store factor gradient */
  87639. export class FactorGradient implements IValueGradient {
  87640. /**
  87641. * Gets or sets the gradient value (between 0 and 1)
  87642. */
  87643. gradient: number;
  87644. /**
  87645. * Gets or sets first associated factor
  87646. */
  87647. factor1: number;
  87648. /**
  87649. * Gets or sets second associated factor
  87650. */
  87651. factor2?: number;
  87652. /**
  87653. * Will get a number picked randomly between factor1 and factor2.
  87654. * If factor2 is undefined then factor1 will be used
  87655. * @returns the picked number
  87656. */
  87657. getFactor(): number;
  87658. }
  87659. /**
  87660. * @ignore
  87661. * Application error to support additional information when loading a file
  87662. */
  87663. export class LoadFileError extends Error {
  87664. /** defines the optional XHR request */
  87665. request?: XMLHttpRequest | undefined;
  87666. private static _setPrototypeOf;
  87667. /**
  87668. * Creates a new LoadFileError
  87669. * @param message defines the message of the error
  87670. * @param request defines the optional XHR request
  87671. */
  87672. constructor(message: string,
  87673. /** defines the optional XHR request */
  87674. request?: XMLHttpRequest | undefined);
  87675. }
  87676. /**
  87677. * Class used to define a retry strategy when error happens while loading assets
  87678. */
  87679. export class RetryStrategy {
  87680. /**
  87681. * Function used to defines an exponential back off strategy
  87682. * @param maxRetries defines the maximum number of retries (3 by default)
  87683. * @param baseInterval defines the interval between retries
  87684. * @returns the strategy function to use
  87685. */
  87686. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87687. }
  87688. /**
  87689. * File request interface
  87690. */
  87691. export interface IFileRequest {
  87692. /**
  87693. * Raised when the request is complete (success or error).
  87694. */
  87695. onCompleteObservable: Observable<IFileRequest>;
  87696. /**
  87697. * Aborts the request for a file.
  87698. */
  87699. abort: () => void;
  87700. }
  87701. /**
  87702. * Class containing a set of static utilities functions
  87703. */
  87704. export class Tools {
  87705. /**
  87706. * Gets or sets the base URL to use to load assets
  87707. */
  87708. static BaseUrl: string;
  87709. /**
  87710. * Enable/Disable Custom HTTP Request Headers globally.
  87711. * default = false
  87712. * @see CustomRequestHeaders
  87713. */
  87714. static UseCustomRequestHeaders: boolean;
  87715. /**
  87716. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  87717. * i.e. when loading files, where the server/service expects an Authorization header.
  87718. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  87719. */
  87720. static CustomRequestHeaders: {
  87721. [key: string]: string;
  87722. };
  87723. /**
  87724. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  87725. */
  87726. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  87727. /**
  87728. * Default behaviour for cors in the application.
  87729. * It can be a string if the expected behavior is identical in the entire app.
  87730. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  87731. */
  87732. static CorsBehavior: string | ((url: string | string[]) => string);
  87733. /**
  87734. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  87735. * @ignorenaming
  87736. */
  87737. static UseFallbackTexture: boolean;
  87738. /**
  87739. * Use this object to register external classes like custom textures or material
  87740. * to allow the laoders to instantiate them
  87741. */
  87742. static RegisteredExternalClasses: {
  87743. [key: string]: Object;
  87744. };
  87745. /**
  87746. * Texture content used if a texture cannot loaded
  87747. * @ignorenaming
  87748. */
  87749. static fallbackTexture: string;
  87750. /**
  87751. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  87752. * @param u defines the coordinate on X axis
  87753. * @param v defines the coordinate on Y axis
  87754. * @param width defines the width of the source data
  87755. * @param height defines the height of the source data
  87756. * @param pixels defines the source byte array
  87757. * @param color defines the output color
  87758. */
  87759. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  87760. /**
  87761. * Interpolates between a and b via alpha
  87762. * @param a The lower value (returned when alpha = 0)
  87763. * @param b The upper value (returned when alpha = 1)
  87764. * @param alpha The interpolation-factor
  87765. * @return The mixed value
  87766. */
  87767. static Mix(a: number, b: number, alpha: number): number;
  87768. /**
  87769. * Tries to instantiate a new object from a given class name
  87770. * @param className defines the class name to instantiate
  87771. * @returns the new object or null if the system was not able to do the instantiation
  87772. */
  87773. static Instantiate(className: string): any;
  87774. /**
  87775. * Provides a slice function that will work even on IE
  87776. * @param data defines the array to slice
  87777. * @param start defines the start of the data (optional)
  87778. * @param end defines the end of the data (optional)
  87779. * @returns the new sliced array
  87780. */
  87781. static Slice<T>(data: T, start?: number, end?: number): T;
  87782. /**
  87783. * Polyfill for setImmediate
  87784. * @param action defines the action to execute after the current execution block
  87785. */
  87786. static SetImmediate(action: () => void): void;
  87787. /**
  87788. * Function indicating if a number is an exponent of 2
  87789. * @param value defines the value to test
  87790. * @returns true if the value is an exponent of 2
  87791. */
  87792. static IsExponentOfTwo(value: number): boolean;
  87793. private static _tmpFloatArray;
  87794. /**
  87795. * Returns the nearest 32-bit single precision float representation of a Number
  87796. * @param value A Number. If the parameter is of a different type, it will get converted
  87797. * to a number or to NaN if it cannot be converted
  87798. * @returns number
  87799. */
  87800. static FloatRound(value: number): number;
  87801. /**
  87802. * Find the next highest power of two.
  87803. * @param x Number to start search from.
  87804. * @return Next highest power of two.
  87805. */
  87806. static CeilingPOT(x: number): number;
  87807. /**
  87808. * Find the next lowest power of two.
  87809. * @param x Number to start search from.
  87810. * @return Next lowest power of two.
  87811. */
  87812. static FloorPOT(x: number): number;
  87813. /**
  87814. * Find the nearest power of two.
  87815. * @param x Number to start search from.
  87816. * @return Next nearest power of two.
  87817. */
  87818. static NearestPOT(x: number): number;
  87819. /**
  87820. * Get the closest exponent of two
  87821. * @param value defines the value to approximate
  87822. * @param max defines the maximum value to return
  87823. * @param mode defines how to define the closest value
  87824. * @returns closest exponent of two of the given value
  87825. */
  87826. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  87827. /**
  87828. * Extracts the filename from a path
  87829. * @param path defines the path to use
  87830. * @returns the filename
  87831. */
  87832. static GetFilename(path: string): string;
  87833. /**
  87834. * Extracts the "folder" part of a path (everything before the filename).
  87835. * @param uri The URI to extract the info from
  87836. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  87837. * @returns The "folder" part of the path
  87838. */
  87839. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  87840. /**
  87841. * Extracts text content from a DOM element hierarchy
  87842. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  87843. */
  87844. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  87845. /**
  87846. * Convert an angle in radians to degrees
  87847. * @param angle defines the angle to convert
  87848. * @returns the angle in degrees
  87849. */
  87850. static ToDegrees(angle: number): number;
  87851. /**
  87852. * Convert an angle in degrees to radians
  87853. * @param angle defines the angle to convert
  87854. * @returns the angle in radians
  87855. */
  87856. static ToRadians(angle: number): number;
  87857. /**
  87858. * Encode a buffer to a base64 string
  87859. * @param buffer defines the buffer to encode
  87860. * @returns the encoded string
  87861. */
  87862. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  87863. /**
  87864. * Extracts minimum and maximum values from a list of indexed positions
  87865. * @param positions defines the positions to use
  87866. * @param indices defines the indices to the positions
  87867. * @param indexStart defines the start index
  87868. * @param indexCount defines the end index
  87869. * @param bias defines bias value to add to the result
  87870. * @return minimum and maximum values
  87871. */
  87872. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87873. minimum: Vector3;
  87874. maximum: Vector3;
  87875. };
  87876. /**
  87877. * Extracts minimum and maximum values from a list of positions
  87878. * @param positions defines the positions to use
  87879. * @param start defines the start index in the positions array
  87880. * @param count defines the number of positions to handle
  87881. * @param bias defines bias value to add to the result
  87882. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87883. * @return minimum and maximum values
  87884. */
  87885. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87886. minimum: Vector3;
  87887. maximum: Vector3;
  87888. };
  87889. /**
  87890. * Returns an array if obj is not an array
  87891. * @param obj defines the object to evaluate as an array
  87892. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  87893. * @returns either obj directly if obj is an array or a new array containing obj
  87894. */
  87895. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  87896. /**
  87897. * Gets the pointer prefix to use
  87898. * @returns "pointer" if touch is enabled. Else returns "mouse"
  87899. */
  87900. static GetPointerPrefix(): string;
  87901. /**
  87902. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  87903. * @param func - the function to be called
  87904. * @param requester - the object that will request the next frame. Falls back to window.
  87905. * @returns frame number
  87906. */
  87907. static QueueNewFrame(func: () => void, requester?: any): number;
  87908. /**
  87909. * Ask the browser to promote the current element to fullscreen rendering mode
  87910. * @param element defines the DOM element to promote
  87911. */
  87912. static RequestFullscreen(element: HTMLElement): void;
  87913. /**
  87914. * Asks the browser to exit fullscreen mode
  87915. */
  87916. static ExitFullscreen(): void;
  87917. /**
  87918. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  87919. * @param url define the url we are trying
  87920. * @param element define the dom element where to configure the cors policy
  87921. */
  87922. static SetCorsBehavior(url: string | string[], element: {
  87923. crossOrigin: string | null;
  87924. }): void;
  87925. /**
  87926. * Removes unwanted characters from an url
  87927. * @param url defines the url to clean
  87928. * @returns the cleaned url
  87929. */
  87930. static CleanUrl(url: string): string;
  87931. /**
  87932. * Gets or sets a function used to pre-process url before using them to load assets
  87933. */
  87934. static PreprocessUrl: (url: string) => string;
  87935. /**
  87936. * Loads an image as an HTMLImageElement.
  87937. * @param input url string, ArrayBuffer, or Blob to load
  87938. * @param onLoad callback called when the image successfully loads
  87939. * @param onError callback called when the image fails to load
  87940. * @param offlineProvider offline provider for caching
  87941. * @returns the HTMLImageElement of the loaded image
  87942. */
  87943. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  87944. /**
  87945. * Loads a file
  87946. * @param url url string, ArrayBuffer, or Blob to load
  87947. * @param onSuccess callback called when the file successfully loads
  87948. * @param onProgress callback called while file is loading (if the server supports this mode)
  87949. * @param offlineProvider defines the offline provider for caching
  87950. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  87951. * @param onError callback called when the file fails to load
  87952. * @returns a file request object
  87953. */
  87954. 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;
  87955. /**
  87956. * Load a script (identified by an url). When the url returns, the
  87957. * content of this file is added into a new script element, attached to the DOM (body element)
  87958. * @param scriptUrl defines the url of the script to laod
  87959. * @param onSuccess defines the callback called when the script is loaded
  87960. * @param onError defines the callback to call if an error occurs
  87961. */
  87962. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  87963. /**
  87964. * Loads a file from a blob
  87965. * @param fileToLoad defines the blob to use
  87966. * @param callback defines the callback to call when data is loaded
  87967. * @param progressCallback defines the callback to call during loading process
  87968. * @returns a file request object
  87969. */
  87970. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  87971. /**
  87972. * Loads a file
  87973. * @param fileToLoad defines the file to load
  87974. * @param callback defines the callback to call when data is loaded
  87975. * @param progressCallBack defines the callback to call during loading process
  87976. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  87977. * @returns a file request object
  87978. */
  87979. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  87980. /**
  87981. * Creates a data url from a given string content
  87982. * @param content defines the content to convert
  87983. * @returns the new data url link
  87984. */
  87985. static FileAsURL(content: string): string;
  87986. /**
  87987. * Format the given number to a specific decimal format
  87988. * @param value defines the number to format
  87989. * @param decimals defines the number of decimals to use
  87990. * @returns the formatted string
  87991. */
  87992. static Format(value: number, decimals?: number): string;
  87993. /**
  87994. * Checks if a given vector is inside a specific range
  87995. * @param v defines the vector to test
  87996. * @param min defines the minimum range
  87997. * @param max defines the maximum range
  87998. */
  87999. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  88000. /**
  88001. * Tries to copy an object by duplicating every property
  88002. * @param source defines the source object
  88003. * @param destination defines the target object
  88004. * @param doNotCopyList defines a list of properties to avoid
  88005. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  88006. */
  88007. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  88008. /**
  88009. * Gets a boolean indicating if the given object has no own property
  88010. * @param obj defines the object to test
  88011. * @returns true if object has no own property
  88012. */
  88013. static IsEmpty(obj: any): boolean;
  88014. /**
  88015. * Function used to register events at window level
  88016. * @param events defines the events to register
  88017. */
  88018. static RegisterTopRootEvents(events: {
  88019. name: string;
  88020. handler: Nullable<(e: FocusEvent) => any>;
  88021. }[]): void;
  88022. /**
  88023. * Function used to unregister events from window level
  88024. * @param events defines the events to unregister
  88025. */
  88026. static UnregisterTopRootEvents(events: {
  88027. name: string;
  88028. handler: Nullable<(e: FocusEvent) => any>;
  88029. }[]): void;
  88030. /**
  88031. * @ignore
  88032. */
  88033. static _ScreenshotCanvas: HTMLCanvasElement;
  88034. /**
  88035. * Dumps the current bound framebuffer
  88036. * @param width defines the rendering width
  88037. * @param height defines the rendering height
  88038. * @param engine defines the hosting engine
  88039. * @param successCallback defines the callback triggered once the data are available
  88040. * @param mimeType defines the mime type of the result
  88041. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  88042. */
  88043. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88044. /**
  88045. * Converts the canvas data to blob.
  88046. * This acts as a polyfill for browsers not supporting the to blob function.
  88047. * @param canvas Defines the canvas to extract the data from
  88048. * @param successCallback Defines the callback triggered once the data are available
  88049. * @param mimeType Defines the mime type of the result
  88050. */
  88051. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  88052. /**
  88053. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  88054. * @param successCallback defines the callback triggered once the data are available
  88055. * @param mimeType defines the mime type of the result
  88056. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  88057. */
  88058. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  88059. /**
  88060. * Downloads a blob in the browser
  88061. * @param blob defines the blob to download
  88062. * @param fileName defines the name of the downloaded file
  88063. */
  88064. static Download(blob: Blob, fileName: string): void;
  88065. /**
  88066. * Captures a screenshot of the current rendering
  88067. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88068. * @param engine defines the rendering engine
  88069. * @param camera defines the source camera
  88070. * @param size This parameter can be set to a single number or to an object with the
  88071. * following (optional) properties: precision, width, height. If a single number is passed,
  88072. * it will be used for both width and height. If an object is passed, the screenshot size
  88073. * will be derived from the parameters. The precision property is a multiplier allowing
  88074. * rendering at a higher or lower resolution
  88075. * @param successCallback defines the callback receives a single parameter which contains the
  88076. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88077. * src parameter of an <img> to display it
  88078. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  88079. * Check your browser for supported MIME types
  88080. */
  88081. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  88082. /**
  88083. * Generates an image screenshot from the specified camera.
  88084. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  88085. * @param engine The engine to use for rendering
  88086. * @param camera The camera to use for rendering
  88087. * @param size This parameter can be set to a single number or to an object with the
  88088. * following (optional) properties: precision, width, height. If a single number is passed,
  88089. * it will be used for both width and height. If an object is passed, the screenshot size
  88090. * will be derived from the parameters. The precision property is a multiplier allowing
  88091. * rendering at a higher or lower resolution
  88092. * @param successCallback The callback receives a single parameter which contains the
  88093. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  88094. * src parameter of an <img> to display it
  88095. * @param mimeType The MIME type of the screenshot image (default: image/png).
  88096. * Check your browser for supported MIME types
  88097. * @param samples Texture samples (default: 1)
  88098. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  88099. * @param fileName A name for for the downloaded file.
  88100. */
  88101. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  88102. /**
  88103. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88104. * Be aware Math.random() could cause collisions, but:
  88105. * "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"
  88106. * @returns a pseudo random id
  88107. */
  88108. static RandomId(): string;
  88109. /**
  88110. * Test if the given uri is a base64 string
  88111. * @param uri The uri to test
  88112. * @return True if the uri is a base64 string or false otherwise
  88113. */
  88114. static IsBase64(uri: string): boolean;
  88115. /**
  88116. * Decode the given base64 uri.
  88117. * @param uri The uri to decode
  88118. * @return The decoded base64 data.
  88119. */
  88120. static DecodeBase64(uri: string): ArrayBuffer;
  88121. /**
  88122. * No log
  88123. */
  88124. static readonly NoneLogLevel: number;
  88125. /**
  88126. * Only message logs
  88127. */
  88128. static readonly MessageLogLevel: number;
  88129. /**
  88130. * Only warning logs
  88131. */
  88132. static readonly WarningLogLevel: number;
  88133. /**
  88134. * Only error logs
  88135. */
  88136. static readonly ErrorLogLevel: number;
  88137. /**
  88138. * All logs
  88139. */
  88140. static readonly AllLogLevel: number;
  88141. /**
  88142. * Gets a value indicating the number of loading errors
  88143. * @ignorenaming
  88144. */
  88145. static readonly errorsCount: number;
  88146. /**
  88147. * Callback called when a new log is added
  88148. */
  88149. static OnNewCacheEntry: (entry: string) => void;
  88150. /**
  88151. * Log a message to the console
  88152. * @param message defines the message to log
  88153. */
  88154. static Log(message: string): void;
  88155. /**
  88156. * Write a warning message to the console
  88157. * @param message defines the message to log
  88158. */
  88159. static Warn(message: string): void;
  88160. /**
  88161. * Write an error message to the console
  88162. * @param message defines the message to log
  88163. */
  88164. static Error(message: string): void;
  88165. /**
  88166. * Gets current log cache (list of logs)
  88167. */
  88168. static readonly LogCache: string;
  88169. /**
  88170. * Clears the log cache
  88171. */
  88172. static ClearLogCache(): void;
  88173. /**
  88174. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  88175. */
  88176. static LogLevels: number;
  88177. /**
  88178. * Checks if the loaded document was accessed via `file:`-Protocol.
  88179. * @returns boolean
  88180. */
  88181. static IsFileURL(): boolean;
  88182. /**
  88183. * Checks if the window object exists
  88184. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  88185. */
  88186. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  88187. /**
  88188. * No performance log
  88189. */
  88190. static readonly PerformanceNoneLogLevel: number;
  88191. /**
  88192. * Use user marks to log performance
  88193. */
  88194. static readonly PerformanceUserMarkLogLevel: number;
  88195. /**
  88196. * Log performance to the console
  88197. */
  88198. static readonly PerformanceConsoleLogLevel: number;
  88199. private static _performance;
  88200. /**
  88201. * Sets the current performance log level
  88202. */
  88203. static PerformanceLogLevel: number;
  88204. private static _StartPerformanceCounterDisabled;
  88205. private static _EndPerformanceCounterDisabled;
  88206. private static _StartUserMark;
  88207. private static _EndUserMark;
  88208. private static _StartPerformanceConsole;
  88209. private static _EndPerformanceConsole;
  88210. /**
  88211. * Injects the @see CustomRequestHeaders into the given request
  88212. * @param request the request that should be used for injection
  88213. */
  88214. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  88215. /**
  88216. * Starts a performance counter
  88217. */
  88218. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88219. /**
  88220. * Ends a specific performance coutner
  88221. */
  88222. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  88223. /**
  88224. * Gets either window.performance.now() if supported or Date.now() else
  88225. */
  88226. static readonly Now: number;
  88227. /**
  88228. * This method will return the name of the class used to create the instance of the given object.
  88229. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  88230. * @param object the object to get the class name from
  88231. * @param isType defines if the object is actually a type
  88232. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  88233. */
  88234. static GetClassName(object: any, isType?: boolean): string;
  88235. /**
  88236. * Gets the first element of an array satisfying a given predicate
  88237. * @param array defines the array to browse
  88238. * @param predicate defines the predicate to use
  88239. * @returns null if not found or the element
  88240. */
  88241. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  88242. /**
  88243. * This method will return the name of the full name of the class, including its owning module (if any).
  88244. * 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).
  88245. * @param object the object to get the class name from
  88246. * @param isType defines if the object is actually a type
  88247. * @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.
  88248. * @ignorenaming
  88249. */
  88250. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  88251. /**
  88252. * Returns a promise that resolves after the given amount of time.
  88253. * @param delay Number of milliseconds to delay
  88254. * @returns Promise that resolves after the given amount of time
  88255. */
  88256. static DelayAsync(delay: number): Promise<void>;
  88257. /**
  88258. * Gets the current gradient from an array of IValueGradient
  88259. * @param ratio defines the current ratio to get
  88260. * @param gradients defines the array of IValueGradient
  88261. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88262. */
  88263. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88264. }
  88265. /**
  88266. * This class is used to track a performance counter which is number based.
  88267. * The user has access to many properties which give statistics of different nature.
  88268. *
  88269. * The implementer can track two kinds of Performance Counter: time and count.
  88270. * 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.
  88271. * 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.
  88272. */
  88273. export class PerfCounter {
  88274. /**
  88275. * Gets or sets a global boolean to turn on and off all the counters
  88276. */
  88277. static Enabled: boolean;
  88278. /**
  88279. * Returns the smallest value ever
  88280. */
  88281. readonly min: number;
  88282. /**
  88283. * Returns the biggest value ever
  88284. */
  88285. readonly max: number;
  88286. /**
  88287. * Returns the average value since the performance counter is running
  88288. */
  88289. readonly average: number;
  88290. /**
  88291. * Returns the average value of the last second the counter was monitored
  88292. */
  88293. readonly lastSecAverage: number;
  88294. /**
  88295. * Returns the current value
  88296. */
  88297. readonly current: number;
  88298. /**
  88299. * Gets the accumulated total
  88300. */
  88301. readonly total: number;
  88302. /**
  88303. * Gets the total value count
  88304. */
  88305. readonly count: number;
  88306. /**
  88307. * Creates a new counter
  88308. */
  88309. constructor();
  88310. /**
  88311. * Call this method to start monitoring a new frame.
  88312. * 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.
  88313. */
  88314. fetchNewFrame(): void;
  88315. /**
  88316. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  88317. * @param newCount the count value to add to the monitored count
  88318. * @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.
  88319. */
  88320. addCount(newCount: number, fetchResult: boolean): void;
  88321. /**
  88322. * Start monitoring this performance counter
  88323. */
  88324. beginMonitoring(): void;
  88325. /**
  88326. * Compute the time lapsed since the previous beginMonitoring() call.
  88327. * @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
  88328. */
  88329. endMonitoring(newFrame?: boolean): void;
  88330. private _fetchResult;
  88331. private _startMonitoringTime;
  88332. private _min;
  88333. private _max;
  88334. private _average;
  88335. private _current;
  88336. private _totalValueCount;
  88337. private _totalAccumulated;
  88338. private _lastSecAverage;
  88339. private _lastSecAccumulated;
  88340. private _lastSecTime;
  88341. private _lastSecValueCount;
  88342. }
  88343. /**
  88344. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  88345. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  88346. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  88347. * @param name The name of the class, case should be preserved
  88348. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  88349. */
  88350. export function className(name: string, module?: string): (target: Object) => void;
  88351. /**
  88352. * An implementation of a loop for asynchronous functions.
  88353. */
  88354. export class AsyncLoop {
  88355. /**
  88356. * Defines the number of iterations for the loop
  88357. */
  88358. iterations: number;
  88359. /**
  88360. * Defines the current index of the loop.
  88361. */
  88362. index: number;
  88363. private _done;
  88364. private _fn;
  88365. private _successCallback;
  88366. /**
  88367. * Constructor.
  88368. * @param iterations the number of iterations.
  88369. * @param func the function to run each iteration
  88370. * @param successCallback the callback that will be called upon succesful execution
  88371. * @param offset starting offset.
  88372. */
  88373. constructor(
  88374. /**
  88375. * Defines the number of iterations for the loop
  88376. */
  88377. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  88378. /**
  88379. * Execute the next iteration. Must be called after the last iteration was finished.
  88380. */
  88381. executeNext(): void;
  88382. /**
  88383. * Break the loop and run the success callback.
  88384. */
  88385. breakLoop(): void;
  88386. /**
  88387. * Create and run an async loop.
  88388. * @param iterations the number of iterations.
  88389. * @param fn the function to run each iteration
  88390. * @param successCallback the callback that will be called upon succesful execution
  88391. * @param offset starting offset.
  88392. * @returns the created async loop object
  88393. */
  88394. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  88395. /**
  88396. * A for-loop that will run a given number of iterations synchronous and the rest async.
  88397. * @param iterations total number of iterations
  88398. * @param syncedIterations number of synchronous iterations in each async iteration.
  88399. * @param fn the function to call each iteration.
  88400. * @param callback a success call back that will be called when iterating stops.
  88401. * @param breakFunction a break condition (optional)
  88402. * @param timeout timeout settings for the setTimeout function. default - 0.
  88403. * @returns the created async loop object
  88404. */
  88405. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  88406. }
  88407. }
  88408. declare module BABYLON {
  88409. /** @hidden */
  88410. export interface ICollisionCoordinator {
  88411. createCollider(): Collider;
  88412. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88413. init(scene: Scene): void;
  88414. }
  88415. /** @hidden */
  88416. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  88417. private _scene;
  88418. private _scaledPosition;
  88419. private _scaledVelocity;
  88420. private _finalPosition;
  88421. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  88422. createCollider(): Collider;
  88423. init(scene: Scene): void;
  88424. private _collideWithWorld;
  88425. }
  88426. }
  88427. declare module BABYLON {
  88428. /**
  88429. * This class defines the direct association between an animation and a target
  88430. */
  88431. export class TargetedAnimation {
  88432. /**
  88433. * Animation to perform
  88434. */
  88435. animation: Animation;
  88436. /**
  88437. * Target to animate
  88438. */
  88439. target: any;
  88440. }
  88441. /**
  88442. * Use this class to create coordinated animations on multiple targets
  88443. */
  88444. export class AnimationGroup implements IDisposable {
  88445. /** The name of the animation group */
  88446. name: string;
  88447. private _scene;
  88448. private _targetedAnimations;
  88449. private _animatables;
  88450. private _from;
  88451. private _to;
  88452. private _isStarted;
  88453. private _isPaused;
  88454. private _speedRatio;
  88455. /**
  88456. * Gets or sets the unique id of the node
  88457. */
  88458. uniqueId: number;
  88459. /**
  88460. * This observable will notify when one animation have ended
  88461. */
  88462. onAnimationEndObservable: Observable<TargetedAnimation>;
  88463. /**
  88464. * Observer raised when one animation loops
  88465. */
  88466. onAnimationLoopObservable: Observable<TargetedAnimation>;
  88467. /**
  88468. * This observable will notify when all animations have ended.
  88469. */
  88470. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  88471. /**
  88472. * This observable will notify when all animations have paused.
  88473. */
  88474. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  88475. /**
  88476. * This observable will notify when all animations are playing.
  88477. */
  88478. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  88479. /**
  88480. * Gets the first frame
  88481. */
  88482. readonly from: number;
  88483. /**
  88484. * Gets the last frame
  88485. */
  88486. readonly to: number;
  88487. /**
  88488. * Define if the animations are started
  88489. */
  88490. readonly isStarted: boolean;
  88491. /**
  88492. * Gets a value indicating that the current group is playing
  88493. */
  88494. readonly isPlaying: boolean;
  88495. /**
  88496. * Gets or sets the speed ratio to use for all animations
  88497. */
  88498. /**
  88499. * Gets or sets the speed ratio to use for all animations
  88500. */
  88501. speedRatio: number;
  88502. /**
  88503. * Gets the targeted animations for this animation group
  88504. */
  88505. readonly targetedAnimations: Array<TargetedAnimation>;
  88506. /**
  88507. * returning the list of animatables controlled by this animation group.
  88508. */
  88509. readonly animatables: Array<Animatable>;
  88510. /**
  88511. * Instantiates a new Animation Group.
  88512. * This helps managing several animations at once.
  88513. * @see http://doc.babylonjs.com/how_to/group
  88514. * @param name Defines the name of the group
  88515. * @param scene Defines the scene the group belongs to
  88516. */
  88517. constructor(
  88518. /** The name of the animation group */
  88519. name: string, scene?: Nullable<Scene>);
  88520. /**
  88521. * Add an animation (with its target) in the group
  88522. * @param animation defines the animation we want to add
  88523. * @param target defines the target of the animation
  88524. * @returns the TargetedAnimation object
  88525. */
  88526. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  88527. /**
  88528. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  88529. * It can add constant keys at begin or end
  88530. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  88531. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  88532. * @returns the animation group
  88533. */
  88534. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  88535. /**
  88536. * Start all animations on given targets
  88537. * @param loop defines if animations must loop
  88538. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  88539. * @param from defines the from key (optional)
  88540. * @param to defines the to key (optional)
  88541. * @returns the current animation group
  88542. */
  88543. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  88544. /**
  88545. * Pause all animations
  88546. * @returns the animation group
  88547. */
  88548. pause(): AnimationGroup;
  88549. /**
  88550. * Play all animations to initial state
  88551. * This function will start() the animations if they were not started or will restart() them if they were paused
  88552. * @param loop defines if animations must loop
  88553. * @returns the animation group
  88554. */
  88555. play(loop?: boolean): AnimationGroup;
  88556. /**
  88557. * Reset all animations to initial state
  88558. * @returns the animation group
  88559. */
  88560. reset(): AnimationGroup;
  88561. /**
  88562. * Restart animations from key 0
  88563. * @returns the animation group
  88564. */
  88565. restart(): AnimationGroup;
  88566. /**
  88567. * Stop all animations
  88568. * @returns the animation group
  88569. */
  88570. stop(): AnimationGroup;
  88571. /**
  88572. * Set animation weight for all animatables
  88573. * @param weight defines the weight to use
  88574. * @return the animationGroup
  88575. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88576. */
  88577. setWeightForAllAnimatables(weight: number): AnimationGroup;
  88578. /**
  88579. * Synchronize and normalize all animatables with a source animatable
  88580. * @param root defines the root animatable to synchronize with
  88581. * @return the animationGroup
  88582. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  88583. */
  88584. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  88585. /**
  88586. * Goes to a specific frame in this animation group
  88587. * @param frame the frame number to go to
  88588. * @return the animationGroup
  88589. */
  88590. goToFrame(frame: number): AnimationGroup;
  88591. /**
  88592. * Dispose all associated resources
  88593. */
  88594. dispose(): void;
  88595. private _checkAnimationGroupEnded;
  88596. /**
  88597. * Clone the current animation group and returns a copy
  88598. * @param newName defines the name of the new group
  88599. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  88600. * @returns the new aniamtion group
  88601. */
  88602. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  88603. /**
  88604. * Returns a new AnimationGroup object parsed from the source provided.
  88605. * @param parsedAnimationGroup defines the source
  88606. * @param scene defines the scene that will receive the animationGroup
  88607. * @returns a new AnimationGroup
  88608. */
  88609. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  88610. /**
  88611. * Returns the string "AnimationGroup"
  88612. * @returns "AnimationGroup"
  88613. */
  88614. getClassName(): string;
  88615. /**
  88616. * Creates a detailled string about the object
  88617. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  88618. * @returns a string representing the object
  88619. */
  88620. toString(fullDetails?: boolean): string;
  88621. }
  88622. }
  88623. declare module BABYLON {
  88624. /**
  88625. * Define an interface for all classes that will hold resources
  88626. */
  88627. export interface IDisposable {
  88628. /**
  88629. * Releases all held resources
  88630. */
  88631. dispose(): void;
  88632. }
  88633. /** Interface defining initialization parameters for Scene class */
  88634. export interface SceneOptions {
  88635. /**
  88636. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  88637. * It will improve performance when the number of geometries becomes important.
  88638. */
  88639. useGeometryUniqueIdsMap?: boolean;
  88640. /**
  88641. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  88642. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88643. */
  88644. useMaterialMeshMap?: boolean;
  88645. /**
  88646. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  88647. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  88648. */
  88649. useClonedMeshhMap?: boolean;
  88650. }
  88651. /**
  88652. * Represents a scene to be rendered by the engine.
  88653. * @see http://doc.babylonjs.com/features/scene
  88654. */
  88655. export class Scene extends AbstractScene implements IAnimatable {
  88656. private static _uniqueIdCounter;
  88657. /** The fog is deactivated */
  88658. static readonly FOGMODE_NONE: number;
  88659. /** The fog density is following an exponential function */
  88660. static readonly FOGMODE_EXP: number;
  88661. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  88662. static readonly FOGMODE_EXP2: number;
  88663. /** The fog density is following a linear function. */
  88664. static readonly FOGMODE_LINEAR: number;
  88665. /**
  88666. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  88667. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88668. */
  88669. static MinDeltaTime: number;
  88670. /**
  88671. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  88672. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  88673. */
  88674. static MaxDeltaTime: number;
  88675. /**
  88676. * Factory used to create the default material.
  88677. * @param name The name of the material to create
  88678. * @param scene The scene to create the material for
  88679. * @returns The default material
  88680. */
  88681. static DefaultMaterialFactory(scene: Scene): Material;
  88682. /**
  88683. * Factory used to create the a collision coordinator.
  88684. * @returns The collision coordinator
  88685. */
  88686. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  88687. /** @hidden */
  88688. readonly _isScene: boolean;
  88689. /**
  88690. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  88691. */
  88692. autoClear: boolean;
  88693. /**
  88694. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  88695. */
  88696. autoClearDepthAndStencil: boolean;
  88697. /**
  88698. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  88699. */
  88700. clearColor: Color4;
  88701. /**
  88702. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  88703. */
  88704. ambientColor: Color3;
  88705. /** @hidden */
  88706. _environmentBRDFTexture: BaseTexture;
  88707. /** @hidden */
  88708. protected _environmentTexture: Nullable<BaseTexture>;
  88709. /**
  88710. * Texture used in all pbr material as the reflection texture.
  88711. * As in the majority of the scene they are the same (exception for multi room and so on),
  88712. * this is easier to reference from here than from all the materials.
  88713. */
  88714. /**
  88715. * Texture used in all pbr material as the reflection texture.
  88716. * As in the majority of the scene they are the same (exception for multi room and so on),
  88717. * this is easier to set here than in all the materials.
  88718. */
  88719. environmentTexture: Nullable<BaseTexture>;
  88720. /** @hidden */
  88721. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88722. /**
  88723. * Default image processing configuration used either in the rendering
  88724. * Forward main pass or through the imageProcessingPostProcess if present.
  88725. * As in the majority of the scene they are the same (exception for multi camera),
  88726. * this is easier to reference from here than from all the materials and post process.
  88727. *
  88728. * No setter as we it is a shared configuration, you can set the values instead.
  88729. */
  88730. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  88731. private _forceWireframe;
  88732. /**
  88733. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  88734. */
  88735. forceWireframe: boolean;
  88736. private _forcePointsCloud;
  88737. /**
  88738. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  88739. */
  88740. forcePointsCloud: boolean;
  88741. /**
  88742. * Gets or sets the active clipplane 1
  88743. */
  88744. clipPlane: Nullable<Plane>;
  88745. /**
  88746. * Gets or sets the active clipplane 2
  88747. */
  88748. clipPlane2: Nullable<Plane>;
  88749. /**
  88750. * Gets or sets the active clipplane 3
  88751. */
  88752. clipPlane3: Nullable<Plane>;
  88753. /**
  88754. * Gets or sets the active clipplane 4
  88755. */
  88756. clipPlane4: Nullable<Plane>;
  88757. /**
  88758. * Gets or sets a boolean indicating if animations are enabled
  88759. */
  88760. animationsEnabled: boolean;
  88761. private _animationPropertiesOverride;
  88762. /**
  88763. * Gets or sets the animation properties override
  88764. */
  88765. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88766. /**
  88767. * Gets or sets a boolean indicating if a constant deltatime has to be used
  88768. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  88769. */
  88770. useConstantAnimationDeltaTime: boolean;
  88771. /**
  88772. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  88773. * Please note that it requires to run a ray cast through the scene on every frame
  88774. */
  88775. constantlyUpdateMeshUnderPointer: boolean;
  88776. /**
  88777. * Defines the HTML cursor to use when hovering over interactive elements
  88778. */
  88779. hoverCursor: string;
  88780. /**
  88781. * Defines the HTML default cursor to use (empty by default)
  88782. */
  88783. defaultCursor: string;
  88784. /**
  88785. * This is used to call preventDefault() on pointer down
  88786. * in order to block unwanted artifacts like system double clicks
  88787. */
  88788. preventDefaultOnPointerDown: boolean;
  88789. /**
  88790. * This is used to call preventDefault() on pointer up
  88791. * in order to block unwanted artifacts like system double clicks
  88792. */
  88793. preventDefaultOnPointerUp: boolean;
  88794. /**
  88795. * Gets or sets user defined metadata
  88796. */
  88797. metadata: any;
  88798. /**
  88799. * For internal use only. Please do not use.
  88800. */
  88801. reservedDataStore: any;
  88802. /**
  88803. * Gets the name of the plugin used to load this scene (null by default)
  88804. */
  88805. loadingPluginName: string;
  88806. /**
  88807. * Use this array to add regular expressions used to disable offline support for specific urls
  88808. */
  88809. disableOfflineSupportExceptionRules: RegExp[];
  88810. /**
  88811. * An event triggered when the scene is disposed.
  88812. */
  88813. onDisposeObservable: Observable<Scene>;
  88814. private _onDisposeObserver;
  88815. /** Sets a function to be executed when this scene is disposed. */
  88816. onDispose: () => void;
  88817. /**
  88818. * An event triggered before rendering the scene (right after animations and physics)
  88819. */
  88820. onBeforeRenderObservable: Observable<Scene>;
  88821. private _onBeforeRenderObserver;
  88822. /** Sets a function to be executed before rendering this scene */
  88823. beforeRender: Nullable<() => void>;
  88824. /**
  88825. * An event triggered after rendering the scene
  88826. */
  88827. onAfterRenderObservable: Observable<Scene>;
  88828. private _onAfterRenderObserver;
  88829. /** Sets a function to be executed after rendering this scene */
  88830. afterRender: Nullable<() => void>;
  88831. /**
  88832. * An event triggered before animating the scene
  88833. */
  88834. onBeforeAnimationsObservable: Observable<Scene>;
  88835. /**
  88836. * An event triggered after animations processing
  88837. */
  88838. onAfterAnimationsObservable: Observable<Scene>;
  88839. /**
  88840. * An event triggered before draw calls are ready to be sent
  88841. */
  88842. onBeforeDrawPhaseObservable: Observable<Scene>;
  88843. /**
  88844. * An event triggered after draw calls have been sent
  88845. */
  88846. onAfterDrawPhaseObservable: Observable<Scene>;
  88847. /**
  88848. * An event triggered when the scene is ready
  88849. */
  88850. onReadyObservable: Observable<Scene>;
  88851. /**
  88852. * An event triggered before rendering a camera
  88853. */
  88854. onBeforeCameraRenderObservable: Observable<Camera>;
  88855. private _onBeforeCameraRenderObserver;
  88856. /** Sets a function to be executed before rendering a camera*/
  88857. beforeCameraRender: () => void;
  88858. /**
  88859. * An event triggered after rendering a camera
  88860. */
  88861. onAfterCameraRenderObservable: Observable<Camera>;
  88862. private _onAfterCameraRenderObserver;
  88863. /** Sets a function to be executed after rendering a camera*/
  88864. afterCameraRender: () => void;
  88865. /**
  88866. * An event triggered when active meshes evaluation is about to start
  88867. */
  88868. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  88869. /**
  88870. * An event triggered when active meshes evaluation is done
  88871. */
  88872. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  88873. /**
  88874. * An event triggered when particles rendering is about to start
  88875. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88876. */
  88877. onBeforeParticlesRenderingObservable: Observable<Scene>;
  88878. /**
  88879. * An event triggered when particles rendering is done
  88880. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  88881. */
  88882. onAfterParticlesRenderingObservable: Observable<Scene>;
  88883. /**
  88884. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  88885. */
  88886. onDataLoadedObservable: Observable<Scene>;
  88887. /**
  88888. * An event triggered when a camera is created
  88889. */
  88890. onNewCameraAddedObservable: Observable<Camera>;
  88891. /**
  88892. * An event triggered when a camera is removed
  88893. */
  88894. onCameraRemovedObservable: Observable<Camera>;
  88895. /**
  88896. * An event triggered when a light is created
  88897. */
  88898. onNewLightAddedObservable: Observable<Light>;
  88899. /**
  88900. * An event triggered when a light is removed
  88901. */
  88902. onLightRemovedObservable: Observable<Light>;
  88903. /**
  88904. * An event triggered when a geometry is created
  88905. */
  88906. onNewGeometryAddedObservable: Observable<Geometry>;
  88907. /**
  88908. * An event triggered when a geometry is removed
  88909. */
  88910. onGeometryRemovedObservable: Observable<Geometry>;
  88911. /**
  88912. * An event triggered when a transform node is created
  88913. */
  88914. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  88915. /**
  88916. * An event triggered when a transform node is removed
  88917. */
  88918. onTransformNodeRemovedObservable: Observable<TransformNode>;
  88919. /**
  88920. * An event triggered when a mesh is created
  88921. */
  88922. onNewMeshAddedObservable: Observable<AbstractMesh>;
  88923. /**
  88924. * An event triggered when a mesh is removed
  88925. */
  88926. onMeshRemovedObservable: Observable<AbstractMesh>;
  88927. /**
  88928. * An event triggered when a material is created
  88929. */
  88930. onNewMaterialAddedObservable: Observable<Material>;
  88931. /**
  88932. * An event triggered when a material is removed
  88933. */
  88934. onMaterialRemovedObservable: Observable<Material>;
  88935. /**
  88936. * An event triggered when a texture is created
  88937. */
  88938. onNewTextureAddedObservable: Observable<BaseTexture>;
  88939. /**
  88940. * An event triggered when a texture is removed
  88941. */
  88942. onTextureRemovedObservable: Observable<BaseTexture>;
  88943. /**
  88944. * An event triggered when render targets are about to be rendered
  88945. * Can happen multiple times per frame.
  88946. */
  88947. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  88948. /**
  88949. * An event triggered when render targets were rendered.
  88950. * Can happen multiple times per frame.
  88951. */
  88952. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  88953. /**
  88954. * An event triggered before calculating deterministic simulation step
  88955. */
  88956. onBeforeStepObservable: Observable<Scene>;
  88957. /**
  88958. * An event triggered after calculating deterministic simulation step
  88959. */
  88960. onAfterStepObservable: Observable<Scene>;
  88961. /**
  88962. * An event triggered when the activeCamera property is updated
  88963. */
  88964. onActiveCameraChanged: Observable<Scene>;
  88965. /**
  88966. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  88967. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88968. * 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)
  88969. */
  88970. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88971. /**
  88972. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  88973. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  88974. * 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)
  88975. */
  88976. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  88977. /**
  88978. * This Observable will when a mesh has been imported into the scene.
  88979. */
  88980. onMeshImportedObservable: Observable<AbstractMesh>;
  88981. /**
  88982. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  88983. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  88984. */
  88985. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  88986. /** @hidden */
  88987. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  88988. /**
  88989. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  88990. */
  88991. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  88992. /**
  88993. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  88994. */
  88995. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  88996. /**
  88997. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  88998. */
  88999. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  89000. private _onPointerMove;
  89001. private _onPointerDown;
  89002. private _onPointerUp;
  89003. /** Callback called when a pointer move is detected */
  89004. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89005. /** Callback called when a pointer down is detected */
  89006. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  89007. /** Callback called when a pointer up is detected */
  89008. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  89009. /** Callback called when a pointer pick is detected */
  89010. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  89011. /**
  89012. * 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).
  89013. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  89014. */
  89015. onPrePointerObservable: Observable<PointerInfoPre>;
  89016. /**
  89017. * Observable event triggered each time an input event is received from the rendering canvas
  89018. */
  89019. onPointerObservable: Observable<PointerInfo>;
  89020. /**
  89021. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  89022. */
  89023. readonly unTranslatedPointer: Vector2;
  89024. /** The distance in pixel that you have to move to prevent some events */
  89025. static DragMovementThreshold: number;
  89026. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  89027. static LongPressDelay: number;
  89028. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  89029. static DoubleClickDelay: number;
  89030. /** If you need to check double click without raising a single click at first click, enable this flag */
  89031. static ExclusiveDoubleClickMode: boolean;
  89032. private _initClickEvent;
  89033. private _initActionManager;
  89034. private _delayedSimpleClick;
  89035. private _delayedSimpleClickTimeout;
  89036. private _previousDelayedSimpleClickTimeout;
  89037. private _meshPickProceed;
  89038. private _previousButtonPressed;
  89039. private _currentPickResult;
  89040. private _previousPickResult;
  89041. private _totalPointersPressed;
  89042. private _doubleClickOccured;
  89043. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  89044. cameraToUseForPointers: Nullable<Camera>;
  89045. private _pointerX;
  89046. private _pointerY;
  89047. private _unTranslatedPointerX;
  89048. private _unTranslatedPointerY;
  89049. private _startingPointerPosition;
  89050. private _previousStartingPointerPosition;
  89051. private _startingPointerTime;
  89052. private _previousStartingPointerTime;
  89053. private _pointerCaptures;
  89054. private _timeAccumulator;
  89055. private _currentStepId;
  89056. private _currentInternalStep;
  89057. /** @hidden */
  89058. _mirroredCameraPosition: Nullable<Vector3>;
  89059. /**
  89060. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  89061. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  89062. */
  89063. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  89064. /**
  89065. * Observable event triggered each time an keyboard event is received from the hosting window
  89066. */
  89067. onKeyboardObservable: Observable<KeyboardInfo>;
  89068. private _onKeyDown;
  89069. private _onKeyUp;
  89070. private _onCanvasFocusObserver;
  89071. private _onCanvasBlurObserver;
  89072. private _useRightHandedSystem;
  89073. /**
  89074. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  89075. */
  89076. useRightHandedSystem: boolean;
  89077. /**
  89078. * Sets the step Id used by deterministic lock step
  89079. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89080. * @param newStepId defines the step Id
  89081. */
  89082. setStepId(newStepId: number): void;
  89083. /**
  89084. * Gets the step Id used by deterministic lock step
  89085. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89086. * @returns the step Id
  89087. */
  89088. getStepId(): number;
  89089. /**
  89090. * Gets the internal step used by deterministic lock step
  89091. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89092. * @returns the internal step
  89093. */
  89094. getInternalStep(): number;
  89095. private _fogEnabled;
  89096. /**
  89097. * Gets or sets a boolean indicating if fog is enabled on this scene
  89098. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89099. * (Default is true)
  89100. */
  89101. fogEnabled: boolean;
  89102. private _fogMode;
  89103. /**
  89104. * Gets or sets the fog mode to use
  89105. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89106. * | mode | value |
  89107. * | --- | --- |
  89108. * | FOGMODE_NONE | 0 |
  89109. * | FOGMODE_EXP | 1 |
  89110. * | FOGMODE_EXP2 | 2 |
  89111. * | FOGMODE_LINEAR | 3 |
  89112. */
  89113. fogMode: number;
  89114. /**
  89115. * Gets or sets the fog color to use
  89116. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89117. * (Default is Color3(0.2, 0.2, 0.3))
  89118. */
  89119. fogColor: Color3;
  89120. /**
  89121. * Gets or sets the fog density to use
  89122. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89123. * (Default is 0.1)
  89124. */
  89125. fogDensity: number;
  89126. /**
  89127. * Gets or sets the fog start distance to use
  89128. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89129. * (Default is 0)
  89130. */
  89131. fogStart: number;
  89132. /**
  89133. * Gets or sets the fog end distance to use
  89134. * @see http://doc.babylonjs.com/babylon101/environment#fog
  89135. * (Default is 1000)
  89136. */
  89137. fogEnd: number;
  89138. private _shadowsEnabled;
  89139. /**
  89140. * Gets or sets a boolean indicating if shadows are enabled on this scene
  89141. */
  89142. shadowsEnabled: boolean;
  89143. private _lightsEnabled;
  89144. /**
  89145. * Gets or sets a boolean indicating if lights are enabled on this scene
  89146. */
  89147. lightsEnabled: boolean;
  89148. /** All of the active cameras added to this scene. */
  89149. activeCameras: Camera[];
  89150. private _activeCamera;
  89151. /** Gets or sets the current active camera */
  89152. activeCamera: Nullable<Camera>;
  89153. private _defaultMaterial;
  89154. /** The default material used on meshes when no material is affected */
  89155. /** The default material used on meshes when no material is affected */
  89156. defaultMaterial: Material;
  89157. private _texturesEnabled;
  89158. /**
  89159. * Gets or sets a boolean indicating if textures are enabled on this scene
  89160. */
  89161. texturesEnabled: boolean;
  89162. /**
  89163. * Gets or sets a boolean indicating if particles are enabled on this scene
  89164. */
  89165. particlesEnabled: boolean;
  89166. /**
  89167. * Gets or sets a boolean indicating if sprites are enabled on this scene
  89168. */
  89169. spritesEnabled: boolean;
  89170. private _skeletonsEnabled;
  89171. /**
  89172. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  89173. */
  89174. skeletonsEnabled: boolean;
  89175. /**
  89176. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  89177. */
  89178. lensFlaresEnabled: boolean;
  89179. /**
  89180. * Gets or sets a boolean indicating if collisions are enabled on this scene
  89181. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89182. */
  89183. collisionsEnabled: boolean;
  89184. private _collisionCoordinator;
  89185. /** @hidden */
  89186. readonly collisionCoordinator: ICollisionCoordinator;
  89187. /**
  89188. * Defines the gravity applied to this scene (used only for collisions)
  89189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89190. */
  89191. gravity: Vector3;
  89192. /**
  89193. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  89194. */
  89195. postProcessesEnabled: boolean;
  89196. /**
  89197. * The list of postprocesses added to the scene
  89198. */
  89199. postProcesses: PostProcess[];
  89200. /**
  89201. * Gets the current postprocess manager
  89202. */
  89203. postProcessManager: PostProcessManager;
  89204. /**
  89205. * Gets or sets a boolean indicating if render targets are enabled on this scene
  89206. */
  89207. renderTargetsEnabled: boolean;
  89208. /**
  89209. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  89210. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  89211. */
  89212. dumpNextRenderTargets: boolean;
  89213. /**
  89214. * The list of user defined render targets added to the scene
  89215. */
  89216. customRenderTargets: RenderTargetTexture[];
  89217. /**
  89218. * Defines if texture loading must be delayed
  89219. * If true, textures will only be loaded when they need to be rendered
  89220. */
  89221. useDelayedTextureLoading: boolean;
  89222. /**
  89223. * Gets the list of meshes imported to the scene through SceneLoader
  89224. */
  89225. importedMeshesFiles: String[];
  89226. /**
  89227. * Gets or sets a boolean indicating if probes are enabled on this scene
  89228. */
  89229. probesEnabled: boolean;
  89230. /**
  89231. * Gets or sets the current offline provider to use to store scene data
  89232. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  89233. */
  89234. offlineProvider: IOfflineProvider;
  89235. /**
  89236. * Gets or sets the action manager associated with the scene
  89237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89238. */
  89239. actionManager: AbstractActionManager;
  89240. private _meshesForIntersections;
  89241. /**
  89242. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  89243. */
  89244. proceduralTexturesEnabled: boolean;
  89245. private _engine;
  89246. private _totalVertices;
  89247. /** @hidden */
  89248. _activeIndices: PerfCounter;
  89249. /** @hidden */
  89250. _activeParticles: PerfCounter;
  89251. /** @hidden */
  89252. _activeBones: PerfCounter;
  89253. private _animationRatio;
  89254. /** @hidden */
  89255. _animationTimeLast: number;
  89256. /** @hidden */
  89257. _animationTime: number;
  89258. /**
  89259. * Gets or sets a general scale for animation speed
  89260. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  89261. */
  89262. animationTimeScale: number;
  89263. /** @hidden */
  89264. _cachedMaterial: Nullable<Material>;
  89265. /** @hidden */
  89266. _cachedEffect: Nullable<Effect>;
  89267. /** @hidden */
  89268. _cachedVisibility: Nullable<number>;
  89269. private _renderId;
  89270. private _frameId;
  89271. private _executeWhenReadyTimeoutId;
  89272. private _intermediateRendering;
  89273. private _viewUpdateFlag;
  89274. private _projectionUpdateFlag;
  89275. private _alternateViewUpdateFlag;
  89276. private _alternateProjectionUpdateFlag;
  89277. /** @hidden */
  89278. _toBeDisposed: Nullable<IDisposable>[];
  89279. private _activeRequests;
  89280. /** @hidden */
  89281. _pendingData: any[];
  89282. private _isDisposed;
  89283. /**
  89284. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  89285. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  89286. */
  89287. dispatchAllSubMeshesOfActiveMeshes: boolean;
  89288. private _activeMeshes;
  89289. private _processedMaterials;
  89290. private _renderTargets;
  89291. /** @hidden */
  89292. _activeParticleSystems: SmartArray<IParticleSystem>;
  89293. private _activeSkeletons;
  89294. private _softwareSkinnedMeshes;
  89295. private _renderingManager;
  89296. /** @hidden */
  89297. _activeAnimatables: Animatable[];
  89298. private _transformMatrix;
  89299. private _sceneUbo;
  89300. private _alternateSceneUbo;
  89301. private _viewMatrix;
  89302. private _projectionMatrix;
  89303. private _alternateViewMatrix;
  89304. private _alternateProjectionMatrix;
  89305. private _alternateTransformMatrix;
  89306. private _useAlternateCameraConfiguration;
  89307. private _alternateRendering;
  89308. private _wheelEventName;
  89309. /** @hidden */
  89310. _forcedViewPosition: Nullable<Vector3>;
  89311. /** @hidden */
  89312. readonly _isAlternateRenderingEnabled: boolean;
  89313. private _frustumPlanes;
  89314. /**
  89315. * Gets the list of frustum planes (built from the active camera)
  89316. */
  89317. readonly frustumPlanes: Plane[];
  89318. /**
  89319. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  89320. * This is useful if there are more lights that the maximum simulteanous authorized
  89321. */
  89322. requireLightSorting: boolean;
  89323. /** @hidden */
  89324. readonly useMaterialMeshMap: boolean;
  89325. /** @hidden */
  89326. readonly useClonedMeshhMap: boolean;
  89327. private _pointerOverMesh;
  89328. private _pickedDownMesh;
  89329. private _pickedUpMesh;
  89330. private _externalData;
  89331. private _uid;
  89332. /**
  89333. * @hidden
  89334. * Backing store of defined scene components.
  89335. */
  89336. _components: ISceneComponent[];
  89337. /**
  89338. * @hidden
  89339. * Backing store of defined scene components.
  89340. */
  89341. _serializableComponents: ISceneSerializableComponent[];
  89342. /**
  89343. * List of components to register on the next registration step.
  89344. */
  89345. private _transientComponents;
  89346. /**
  89347. * Registers the transient components if needed.
  89348. */
  89349. private _registerTransientComponents;
  89350. /**
  89351. * @hidden
  89352. * Add a component to the scene.
  89353. * Note that the ccomponent could be registered on th next frame if this is called after
  89354. * the register component stage.
  89355. * @param component Defines the component to add to the scene
  89356. */
  89357. _addComponent(component: ISceneComponent): void;
  89358. /**
  89359. * @hidden
  89360. * Gets a component from the scene.
  89361. * @param name defines the name of the component to retrieve
  89362. * @returns the component or null if not present
  89363. */
  89364. _getComponent(name: string): Nullable<ISceneComponent>;
  89365. /**
  89366. * @hidden
  89367. * Defines the actions happening before camera updates.
  89368. */
  89369. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  89370. /**
  89371. * @hidden
  89372. * Defines the actions happening before clear the canvas.
  89373. */
  89374. _beforeClearStage: Stage<SimpleStageAction>;
  89375. /**
  89376. * @hidden
  89377. * Defines the actions when collecting render targets for the frame.
  89378. */
  89379. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89380. /**
  89381. * @hidden
  89382. * Defines the actions happening for one camera in the frame.
  89383. */
  89384. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  89385. /**
  89386. * @hidden
  89387. * Defines the actions happening during the per mesh ready checks.
  89388. */
  89389. _isReadyForMeshStage: Stage<MeshStageAction>;
  89390. /**
  89391. * @hidden
  89392. * Defines the actions happening before evaluate active mesh checks.
  89393. */
  89394. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  89395. /**
  89396. * @hidden
  89397. * Defines the actions happening during the evaluate sub mesh checks.
  89398. */
  89399. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  89400. /**
  89401. * @hidden
  89402. * Defines the actions happening during the active mesh stage.
  89403. */
  89404. _activeMeshStage: Stage<ActiveMeshStageAction>;
  89405. /**
  89406. * @hidden
  89407. * Defines the actions happening during the per camera render target step.
  89408. */
  89409. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  89410. /**
  89411. * @hidden
  89412. * Defines the actions happening just before the active camera is drawing.
  89413. */
  89414. _beforeCameraDrawStage: Stage<CameraStageAction>;
  89415. /**
  89416. * @hidden
  89417. * Defines the actions happening just before a render target is drawing.
  89418. */
  89419. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89420. /**
  89421. * @hidden
  89422. * Defines the actions happening just before a rendering group is drawing.
  89423. */
  89424. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89425. /**
  89426. * @hidden
  89427. * Defines the actions happening just before a mesh is drawing.
  89428. */
  89429. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89430. /**
  89431. * @hidden
  89432. * Defines the actions happening just after a mesh has been drawn.
  89433. */
  89434. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  89435. /**
  89436. * @hidden
  89437. * Defines the actions happening just after a rendering group has been drawn.
  89438. */
  89439. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  89440. /**
  89441. * @hidden
  89442. * Defines the actions happening just after the active camera has been drawn.
  89443. */
  89444. _afterCameraDrawStage: Stage<CameraStageAction>;
  89445. /**
  89446. * @hidden
  89447. * Defines the actions happening just after a render target has been drawn.
  89448. */
  89449. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  89450. /**
  89451. * @hidden
  89452. * Defines the actions happening just after rendering all cameras and computing intersections.
  89453. */
  89454. _afterRenderStage: Stage<SimpleStageAction>;
  89455. /**
  89456. * @hidden
  89457. * Defines the actions happening when a pointer move event happens.
  89458. */
  89459. _pointerMoveStage: Stage<PointerMoveStageAction>;
  89460. /**
  89461. * @hidden
  89462. * Defines the actions happening when a pointer down event happens.
  89463. */
  89464. _pointerDownStage: Stage<PointerUpDownStageAction>;
  89465. /**
  89466. * @hidden
  89467. * Defines the actions happening when a pointer up event happens.
  89468. */
  89469. _pointerUpStage: Stage<PointerUpDownStageAction>;
  89470. /**
  89471. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  89472. */
  89473. private geometriesByUniqueId;
  89474. /**
  89475. * Creates a new Scene
  89476. * @param engine defines the engine to use to render this scene
  89477. * @param options defines the scene options
  89478. */
  89479. constructor(engine: Engine, options?: SceneOptions);
  89480. private _defaultMeshCandidates;
  89481. /**
  89482. * @hidden
  89483. */
  89484. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  89485. private _defaultSubMeshCandidates;
  89486. /**
  89487. * @hidden
  89488. */
  89489. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  89490. /**
  89491. * Sets the default candidate providers for the scene.
  89492. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  89493. * and getCollidingSubMeshCandidates to their default function
  89494. */
  89495. setDefaultCandidateProviders(): void;
  89496. /**
  89497. * Gets the mesh that is currently under the pointer
  89498. */
  89499. readonly meshUnderPointer: Nullable<AbstractMesh>;
  89500. /**
  89501. * Gets or sets the current on-screen X position of the pointer
  89502. */
  89503. pointerX: number;
  89504. /**
  89505. * Gets or sets the current on-screen Y position of the pointer
  89506. */
  89507. pointerY: number;
  89508. /**
  89509. * Gets the cached material (ie. the latest rendered one)
  89510. * @returns the cached material
  89511. */
  89512. getCachedMaterial(): Nullable<Material>;
  89513. /**
  89514. * Gets the cached effect (ie. the latest rendered one)
  89515. * @returns the cached effect
  89516. */
  89517. getCachedEffect(): Nullable<Effect>;
  89518. /**
  89519. * Gets the cached visibility state (ie. the latest rendered one)
  89520. * @returns the cached visibility state
  89521. */
  89522. getCachedVisibility(): Nullable<number>;
  89523. /**
  89524. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  89525. * @param material defines the current material
  89526. * @param effect defines the current effect
  89527. * @param visibility defines the current visibility state
  89528. * @returns true if one parameter is not cached
  89529. */
  89530. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  89531. /**
  89532. * Gets the engine associated with the scene
  89533. * @returns an Engine
  89534. */
  89535. getEngine(): Engine;
  89536. /**
  89537. * Gets the total number of vertices rendered per frame
  89538. * @returns the total number of vertices rendered per frame
  89539. */
  89540. getTotalVertices(): number;
  89541. /**
  89542. * Gets the performance counter for total vertices
  89543. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89544. */
  89545. readonly totalVerticesPerfCounter: PerfCounter;
  89546. /**
  89547. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  89548. * @returns the total number of active indices rendered per frame
  89549. */
  89550. getActiveIndices(): number;
  89551. /**
  89552. * Gets the performance counter for active indices
  89553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89554. */
  89555. readonly totalActiveIndicesPerfCounter: PerfCounter;
  89556. /**
  89557. * Gets the total number of active particles rendered per frame
  89558. * @returns the total number of active particles rendered per frame
  89559. */
  89560. getActiveParticles(): number;
  89561. /**
  89562. * Gets the performance counter for active particles
  89563. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89564. */
  89565. readonly activeParticlesPerfCounter: PerfCounter;
  89566. /**
  89567. * Gets the total number of active bones rendered per frame
  89568. * @returns the total number of active bones rendered per frame
  89569. */
  89570. getActiveBones(): number;
  89571. /**
  89572. * Gets the performance counter for active bones
  89573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  89574. */
  89575. readonly activeBonesPerfCounter: PerfCounter;
  89576. /**
  89577. * Gets the array of active meshes
  89578. * @returns an array of AbstractMesh
  89579. */
  89580. getActiveMeshes(): SmartArray<AbstractMesh>;
  89581. /**
  89582. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  89583. * @returns a number
  89584. */
  89585. getAnimationRatio(): number;
  89586. /**
  89587. * Gets an unique Id for the current render phase
  89588. * @returns a number
  89589. */
  89590. getRenderId(): number;
  89591. /**
  89592. * Gets an unique Id for the current frame
  89593. * @returns a number
  89594. */
  89595. getFrameId(): number;
  89596. /** Call this function if you want to manually increment the render Id*/
  89597. incrementRenderId(): void;
  89598. private _updatePointerPosition;
  89599. private _createUbo;
  89600. private _createAlternateUbo;
  89601. private _setRayOnPointerInfo;
  89602. /**
  89603. * Use this method to simulate a pointer move on a mesh
  89604. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89605. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89606. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89607. * @returns the current scene
  89608. */
  89609. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89610. private _processPointerMove;
  89611. private _checkPrePointerObservable;
  89612. /**
  89613. * Use this method to simulate a pointer down on a mesh
  89614. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89615. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89616. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89617. * @returns the current scene
  89618. */
  89619. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  89620. private _processPointerDown;
  89621. /**
  89622. * Use this method to simulate a pointer up on a mesh
  89623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  89624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  89625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  89626. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  89627. * @returns the current scene
  89628. */
  89629. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  89630. private _processPointerUp;
  89631. /**
  89632. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  89633. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  89634. * @returns true if the pointer was captured
  89635. */
  89636. isPointerCaptured(pointerId?: number): boolean;
  89637. /** @hidden */
  89638. _isPointerSwiping(): boolean;
  89639. /**
  89640. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  89641. * @param attachUp defines if you want to attach events to pointerup
  89642. * @param attachDown defines if you want to attach events to pointerdown
  89643. * @param attachMove defines if you want to attach events to pointermove
  89644. */
  89645. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  89646. /** Detaches all event handlers*/
  89647. detachControl(): void;
  89648. /**
  89649. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  89650. * Delay loaded resources are not taking in account
  89651. * @return true if all required resources are ready
  89652. */
  89653. isReady(): boolean;
  89654. /** Resets all cached information relative to material (including effect and visibility) */
  89655. resetCachedMaterial(): void;
  89656. /**
  89657. * Registers a function to be called before every frame render
  89658. * @param func defines the function to register
  89659. */
  89660. registerBeforeRender(func: () => void): void;
  89661. /**
  89662. * Unregisters a function called before every frame render
  89663. * @param func defines the function to unregister
  89664. */
  89665. unregisterBeforeRender(func: () => void): void;
  89666. /**
  89667. * Registers a function to be called after every frame render
  89668. * @param func defines the function to register
  89669. */
  89670. registerAfterRender(func: () => void): void;
  89671. /**
  89672. * Unregisters a function called after every frame render
  89673. * @param func defines the function to unregister
  89674. */
  89675. unregisterAfterRender(func: () => void): void;
  89676. private _executeOnceBeforeRender;
  89677. /**
  89678. * The provided function will run before render once and will be disposed afterwards.
  89679. * A timeout delay can be provided so that the function will be executed in N ms.
  89680. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  89681. * @param func The function to be executed.
  89682. * @param timeout optional delay in ms
  89683. */
  89684. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  89685. /** @hidden */
  89686. _addPendingData(data: any): void;
  89687. /** @hidden */
  89688. _removePendingData(data: any): void;
  89689. /**
  89690. * Returns the number of items waiting to be loaded
  89691. * @returns the number of items waiting to be loaded
  89692. */
  89693. getWaitingItemsCount(): number;
  89694. /**
  89695. * Returns a boolean indicating if the scene is still loading data
  89696. */
  89697. readonly isLoading: boolean;
  89698. /**
  89699. * Registers a function to be executed when the scene is ready
  89700. * @param {Function} func - the function to be executed
  89701. */
  89702. executeWhenReady(func: () => void): void;
  89703. /**
  89704. * Returns a promise that resolves when the scene is ready
  89705. * @returns A promise that resolves when the scene is ready
  89706. */
  89707. whenReadyAsync(): Promise<void>;
  89708. /** @hidden */
  89709. _checkIsReady(): void;
  89710. /**
  89711. * Gets all animatable attached to the scene
  89712. */
  89713. readonly animatables: Animatable[];
  89714. /**
  89715. * Resets the last animation time frame.
  89716. * Useful to override when animations start running when loading a scene for the first time.
  89717. */
  89718. resetLastAnimationTimeFrame(): void;
  89719. /** @hidden */
  89720. _switchToAlternateCameraConfiguration(active: boolean): void;
  89721. /**
  89722. * Gets the current view matrix
  89723. * @returns a Matrix
  89724. */
  89725. getViewMatrix(): Matrix;
  89726. /**
  89727. * Gets the current projection matrix
  89728. * @returns a Matrix
  89729. */
  89730. getProjectionMatrix(): Matrix;
  89731. /**
  89732. * Gets the current transform matrix
  89733. * @returns a Matrix made of View * Projection
  89734. */
  89735. getTransformMatrix(): Matrix;
  89736. /**
  89737. * Sets the current transform matrix
  89738. * @param view defines the View matrix to use
  89739. * @param projection defines the Projection matrix to use
  89740. */
  89741. setTransformMatrix(view: Matrix, projection: Matrix): void;
  89742. /** @hidden */
  89743. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  89744. /**
  89745. * Gets the uniform buffer used to store scene data
  89746. * @returns a UniformBuffer
  89747. */
  89748. getSceneUniformBuffer(): UniformBuffer;
  89749. /**
  89750. * Gets an unique (relatively to the current scene) Id
  89751. * @returns an unique number for the scene
  89752. */
  89753. getUniqueId(): number;
  89754. /**
  89755. * Add a mesh to the list of scene's meshes
  89756. * @param newMesh defines the mesh to add
  89757. * @param recursive if all child meshes should also be added to the scene
  89758. */
  89759. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  89760. /**
  89761. * Remove a mesh for the list of scene's meshes
  89762. * @param toRemove defines the mesh to remove
  89763. * @param recursive if all child meshes should also be removed from the scene
  89764. * @returns the index where the mesh was in the mesh list
  89765. */
  89766. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  89767. /**
  89768. * Add a transform node to the list of scene's transform nodes
  89769. * @param newTransformNode defines the transform node to add
  89770. */
  89771. addTransformNode(newTransformNode: TransformNode): void;
  89772. /**
  89773. * Remove a transform node for the list of scene's transform nodes
  89774. * @param toRemove defines the transform node to remove
  89775. * @returns the index where the transform node was in the transform node list
  89776. */
  89777. removeTransformNode(toRemove: TransformNode): number;
  89778. /**
  89779. * Remove a skeleton for the list of scene's skeletons
  89780. * @param toRemove defines the skeleton to remove
  89781. * @returns the index where the skeleton was in the skeleton list
  89782. */
  89783. removeSkeleton(toRemove: Skeleton): number;
  89784. /**
  89785. * Remove a morph target for the list of scene's morph targets
  89786. * @param toRemove defines the morph target to remove
  89787. * @returns the index where the morph target was in the morph target list
  89788. */
  89789. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  89790. /**
  89791. * Remove a light for the list of scene's lights
  89792. * @param toRemove defines the light to remove
  89793. * @returns the index where the light was in the light list
  89794. */
  89795. removeLight(toRemove: Light): number;
  89796. /**
  89797. * Remove a camera for the list of scene's cameras
  89798. * @param toRemove defines the camera to remove
  89799. * @returns the index where the camera was in the camera list
  89800. */
  89801. removeCamera(toRemove: Camera): number;
  89802. /**
  89803. * Remove a particle system for the list of scene's particle systems
  89804. * @param toRemove defines the particle system to remove
  89805. * @returns the index where the particle system was in the particle system list
  89806. */
  89807. removeParticleSystem(toRemove: IParticleSystem): number;
  89808. /**
  89809. * Remove a animation for the list of scene's animations
  89810. * @param toRemove defines the animation to remove
  89811. * @returns the index where the animation was in the animation list
  89812. */
  89813. removeAnimation(toRemove: Animation): number;
  89814. /**
  89815. * Removes the given animation group from this scene.
  89816. * @param toRemove The animation group to remove
  89817. * @returns The index of the removed animation group
  89818. */
  89819. removeAnimationGroup(toRemove: AnimationGroup): number;
  89820. /**
  89821. * Removes the given multi-material from this scene.
  89822. * @param toRemove The multi-material to remove
  89823. * @returns The index of the removed multi-material
  89824. */
  89825. removeMultiMaterial(toRemove: MultiMaterial): number;
  89826. /**
  89827. * Removes the given material from this scene.
  89828. * @param toRemove The material to remove
  89829. * @returns The index of the removed material
  89830. */
  89831. removeMaterial(toRemove: Material): number;
  89832. /**
  89833. * Removes the given action manager from this scene.
  89834. * @param toRemove The action manager to remove
  89835. * @returns The index of the removed action manager
  89836. */
  89837. removeActionManager(toRemove: AbstractActionManager): number;
  89838. /**
  89839. * Removes the given texture from this scene.
  89840. * @param toRemove The texture to remove
  89841. * @returns The index of the removed texture
  89842. */
  89843. removeTexture(toRemove: BaseTexture): number;
  89844. /**
  89845. * Adds the given light to this scene
  89846. * @param newLight The light to add
  89847. */
  89848. addLight(newLight: Light): void;
  89849. /**
  89850. * Sorts the list list based on light priorities
  89851. */
  89852. sortLightsByPriority(): void;
  89853. /**
  89854. * Adds the given camera to this scene
  89855. * @param newCamera The camera to add
  89856. */
  89857. addCamera(newCamera: Camera): void;
  89858. /**
  89859. * Adds the given skeleton to this scene
  89860. * @param newSkeleton The skeleton to add
  89861. */
  89862. addSkeleton(newSkeleton: Skeleton): void;
  89863. /**
  89864. * Adds the given particle system to this scene
  89865. * @param newParticleSystem The particle system to add
  89866. */
  89867. addParticleSystem(newParticleSystem: IParticleSystem): void;
  89868. /**
  89869. * Adds the given animation to this scene
  89870. * @param newAnimation The animation to add
  89871. */
  89872. addAnimation(newAnimation: Animation): void;
  89873. /**
  89874. * Adds the given animation group to this scene.
  89875. * @param newAnimationGroup The animation group to add
  89876. */
  89877. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  89878. /**
  89879. * Adds the given multi-material to this scene
  89880. * @param newMultiMaterial The multi-material to add
  89881. */
  89882. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  89883. /**
  89884. * Adds the given material to this scene
  89885. * @param newMaterial The material to add
  89886. */
  89887. addMaterial(newMaterial: Material): void;
  89888. /**
  89889. * Adds the given morph target to this scene
  89890. * @param newMorphTargetManager The morph target to add
  89891. */
  89892. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  89893. /**
  89894. * Adds the given geometry to this scene
  89895. * @param newGeometry The geometry to add
  89896. */
  89897. addGeometry(newGeometry: Geometry): void;
  89898. /**
  89899. * Adds the given action manager to this scene
  89900. * @param newActionManager The action manager to add
  89901. */
  89902. addActionManager(newActionManager: AbstractActionManager): void;
  89903. /**
  89904. * Adds the given texture to this scene.
  89905. * @param newTexture The texture to add
  89906. */
  89907. addTexture(newTexture: BaseTexture): void;
  89908. /**
  89909. * Switch active camera
  89910. * @param newCamera defines the new active camera
  89911. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  89912. */
  89913. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  89914. /**
  89915. * sets the active camera of the scene using its ID
  89916. * @param id defines the camera's ID
  89917. * @return the new active camera or null if none found.
  89918. */
  89919. setActiveCameraByID(id: string): Nullable<Camera>;
  89920. /**
  89921. * sets the active camera of the scene using its name
  89922. * @param name defines the camera's name
  89923. * @returns the new active camera or null if none found.
  89924. */
  89925. setActiveCameraByName(name: string): Nullable<Camera>;
  89926. /**
  89927. * get an animation group using its name
  89928. * @param name defines the material's name
  89929. * @return the animation group or null if none found.
  89930. */
  89931. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  89932. /**
  89933. * get a material using its id
  89934. * @param id defines the material's ID
  89935. * @return the material or null if none found.
  89936. */
  89937. getMaterialByID(id: string): Nullable<Material>;
  89938. /**
  89939. * Gets a material using its name
  89940. * @param name defines the material's name
  89941. * @return the material or null if none found.
  89942. */
  89943. getMaterialByName(name: string): Nullable<Material>;
  89944. /**
  89945. * Gets a camera using its id
  89946. * @param id defines the id to look for
  89947. * @returns the camera or null if not found
  89948. */
  89949. getCameraByID(id: string): Nullable<Camera>;
  89950. /**
  89951. * Gets a camera using its unique id
  89952. * @param uniqueId defines the unique id to look for
  89953. * @returns the camera or null if not found
  89954. */
  89955. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  89956. /**
  89957. * Gets a camera using its name
  89958. * @param name defines the camera's name
  89959. * @return the camera or null if none found.
  89960. */
  89961. getCameraByName(name: string): Nullable<Camera>;
  89962. /**
  89963. * Gets a bone using its id
  89964. * @param id defines the bone's id
  89965. * @return the bone or null if not found
  89966. */
  89967. getBoneByID(id: string): Nullable<Bone>;
  89968. /**
  89969. * Gets a bone using its id
  89970. * @param name defines the bone's name
  89971. * @return the bone or null if not found
  89972. */
  89973. getBoneByName(name: string): Nullable<Bone>;
  89974. /**
  89975. * Gets a light node using its name
  89976. * @param name defines the the light's name
  89977. * @return the light or null if none found.
  89978. */
  89979. getLightByName(name: string): Nullable<Light>;
  89980. /**
  89981. * Gets a light node using its id
  89982. * @param id defines the light's id
  89983. * @return the light or null if none found.
  89984. */
  89985. getLightByID(id: string): Nullable<Light>;
  89986. /**
  89987. * Gets a light node using its scene-generated unique ID
  89988. * @param uniqueId defines the light's unique id
  89989. * @return the light or null if none found.
  89990. */
  89991. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  89992. /**
  89993. * Gets a particle system by id
  89994. * @param id defines the particle system id
  89995. * @return the corresponding system or null if none found
  89996. */
  89997. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  89998. /**
  89999. * Gets a geometry using its ID
  90000. * @param id defines the geometry's id
  90001. * @return the geometry or null if none found.
  90002. */
  90003. getGeometryByID(id: string): Nullable<Geometry>;
  90004. private _getGeometryByUniqueID;
  90005. /**
  90006. * Add a new geometry to this scene
  90007. * @param geometry defines the geometry to be added to the scene.
  90008. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  90009. * @return a boolean defining if the geometry was added or not
  90010. */
  90011. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  90012. /**
  90013. * Removes an existing geometry
  90014. * @param geometry defines the geometry to be removed from the scene
  90015. * @return a boolean defining if the geometry was removed or not
  90016. */
  90017. removeGeometry(geometry: Geometry): boolean;
  90018. /**
  90019. * Gets the list of geometries attached to the scene
  90020. * @returns an array of Geometry
  90021. */
  90022. getGeometries(): Geometry[];
  90023. /**
  90024. * Gets the first added mesh found of a given ID
  90025. * @param id defines the id to search for
  90026. * @return the mesh found or null if not found at all
  90027. */
  90028. getMeshByID(id: string): Nullable<AbstractMesh>;
  90029. /**
  90030. * Gets a list of meshes using their id
  90031. * @param id defines the id to search for
  90032. * @returns a list of meshes
  90033. */
  90034. getMeshesByID(id: string): Array<AbstractMesh>;
  90035. /**
  90036. * Gets the first added transform node found of a given ID
  90037. * @param id defines the id to search for
  90038. * @return the found transform node or null if not found at all.
  90039. */
  90040. getTransformNodeByID(id: string): Nullable<TransformNode>;
  90041. /**
  90042. * Gets a list of transform nodes using their id
  90043. * @param id defines the id to search for
  90044. * @returns a list of transform nodes
  90045. */
  90046. getTransformNodesByID(id: string): Array<TransformNode>;
  90047. /**
  90048. * Gets a mesh with its auto-generated unique id
  90049. * @param uniqueId defines the unique id to search for
  90050. * @return the found mesh or null if not found at all.
  90051. */
  90052. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  90053. /**
  90054. * Gets a the last added mesh using a given id
  90055. * @param id defines the id to search for
  90056. * @return the found mesh or null if not found at all.
  90057. */
  90058. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  90059. /**
  90060. * Gets a the last added node (Mesh, Camera, Light) using a given id
  90061. * @param id defines the id to search for
  90062. * @return the found node or null if not found at all
  90063. */
  90064. getLastEntryByID(id: string): Nullable<Node>;
  90065. /**
  90066. * Gets a node (Mesh, Camera, Light) using a given id
  90067. * @param id defines the id to search for
  90068. * @return the found node or null if not found at all
  90069. */
  90070. getNodeByID(id: string): Nullable<Node>;
  90071. /**
  90072. * Gets a node (Mesh, Camera, Light) using a given name
  90073. * @param name defines the name to search for
  90074. * @return the found node or null if not found at all.
  90075. */
  90076. getNodeByName(name: string): Nullable<Node>;
  90077. /**
  90078. * Gets a mesh using a given name
  90079. * @param name defines the name to search for
  90080. * @return the found mesh or null if not found at all.
  90081. */
  90082. getMeshByName(name: string): Nullable<AbstractMesh>;
  90083. /**
  90084. * Gets a transform node using a given name
  90085. * @param name defines the name to search for
  90086. * @return the found transform node or null if not found at all.
  90087. */
  90088. getTransformNodeByName(name: string): Nullable<TransformNode>;
  90089. /**
  90090. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  90091. * @param id defines the id to search for
  90092. * @return the found skeleton or null if not found at all.
  90093. */
  90094. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  90095. /**
  90096. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  90097. * @param id defines the id to search for
  90098. * @return the found skeleton or null if not found at all.
  90099. */
  90100. getSkeletonById(id: string): Nullable<Skeleton>;
  90101. /**
  90102. * Gets a skeleton using a given name
  90103. * @param name defines the name to search for
  90104. * @return the found skeleton or null if not found at all.
  90105. */
  90106. getSkeletonByName(name: string): Nullable<Skeleton>;
  90107. /**
  90108. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  90109. * @param id defines the id to search for
  90110. * @return the found morph target manager or null if not found at all.
  90111. */
  90112. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  90113. /**
  90114. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  90115. * @param id defines the id to search for
  90116. * @return the found morph target or null if not found at all.
  90117. */
  90118. getMorphTargetById(id: string): Nullable<MorphTarget>;
  90119. /**
  90120. * Gets a boolean indicating if the given mesh is active
  90121. * @param mesh defines the mesh to look for
  90122. * @returns true if the mesh is in the active list
  90123. */
  90124. isActiveMesh(mesh: AbstractMesh): boolean;
  90125. /**
  90126. * Return a unique id as a string which can serve as an identifier for the scene
  90127. */
  90128. readonly uid: string;
  90129. /**
  90130. * Add an externaly attached data from its key.
  90131. * This method call will fail and return false, if such key already exists.
  90132. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  90133. * @param key the unique key that identifies the data
  90134. * @param data the data object to associate to the key for this Engine instance
  90135. * @return true if no such key were already present and the data was added successfully, false otherwise
  90136. */
  90137. addExternalData<T>(key: string, data: T): boolean;
  90138. /**
  90139. * Get an externaly attached data from its key
  90140. * @param key the unique key that identifies the data
  90141. * @return the associated data, if present (can be null), or undefined if not present
  90142. */
  90143. getExternalData<T>(key: string): Nullable<T>;
  90144. /**
  90145. * Get an externaly attached data from its key, create it using a factory if it's not already present
  90146. * @param key the unique key that identifies the data
  90147. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  90148. * @return the associated data, can be null if the factory returned null.
  90149. */
  90150. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  90151. /**
  90152. * Remove an externaly attached data from the Engine instance
  90153. * @param key the unique key that identifies the data
  90154. * @return true if the data was successfully removed, false if it doesn't exist
  90155. */
  90156. removeExternalData(key: string): boolean;
  90157. private _evaluateSubMesh;
  90158. /**
  90159. * Clear the processed materials smart array preventing retention point in material dispose.
  90160. */
  90161. freeProcessedMaterials(): void;
  90162. private _preventFreeActiveMeshesAndRenderingGroups;
  90163. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  90164. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  90165. * when disposing several meshes in a row or a hierarchy of meshes.
  90166. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  90167. */
  90168. blockfreeActiveMeshesAndRenderingGroups: boolean;
  90169. /**
  90170. * Clear the active meshes smart array preventing retention point in mesh dispose.
  90171. */
  90172. freeActiveMeshes(): void;
  90173. /**
  90174. * Clear the info related to rendering groups preventing retention points during dispose.
  90175. */
  90176. freeRenderingGroups(): void;
  90177. /** @hidden */
  90178. _isInIntermediateRendering(): boolean;
  90179. /**
  90180. * Lambda returning the list of potentially active meshes.
  90181. */
  90182. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  90183. /**
  90184. * Lambda returning the list of potentially active sub meshes.
  90185. */
  90186. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  90187. /**
  90188. * Lambda returning the list of potentially intersecting sub meshes.
  90189. */
  90190. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  90191. /**
  90192. * Lambda returning the list of potentially colliding sub meshes.
  90193. */
  90194. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  90195. private _activeMeshesFrozen;
  90196. /**
  90197. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  90198. * @returns the current scene
  90199. */
  90200. freezeActiveMeshes(): Scene;
  90201. /**
  90202. * Use this function to restart evaluating active meshes on every frame
  90203. * @returns the current scene
  90204. */
  90205. unfreezeActiveMeshes(): Scene;
  90206. private _evaluateActiveMeshes;
  90207. private _activeMesh;
  90208. /**
  90209. * Update the transform matrix to update from the current active camera
  90210. * @param force defines a boolean used to force the update even if cache is up to date
  90211. */
  90212. updateTransformMatrix(force?: boolean): void;
  90213. /**
  90214. * 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)
  90215. * @param alternateCamera defines the camera to use
  90216. */
  90217. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  90218. /** @hidden */
  90219. _allowPostProcessClearColor: boolean;
  90220. private _renderForCamera;
  90221. private _processSubCameras;
  90222. private _checkIntersections;
  90223. /** @hidden */
  90224. _advancePhysicsEngineStep(step: number): void;
  90225. /**
  90226. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  90227. */
  90228. getDeterministicFrameTime: () => number;
  90229. /** @hidden */
  90230. _animate(): void;
  90231. /**
  90232. * Render the scene
  90233. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  90234. */
  90235. render(updateCameras?: boolean): void;
  90236. /**
  90237. * Freeze all materials
  90238. * A frozen material will not be updatable but should be faster to render
  90239. */
  90240. freezeMaterials(): void;
  90241. /**
  90242. * Unfreeze all materials
  90243. * A frozen material will not be updatable but should be faster to render
  90244. */
  90245. unfreezeMaterials(): void;
  90246. /**
  90247. * Releases all held ressources
  90248. */
  90249. dispose(): void;
  90250. /**
  90251. * Gets if the scene is already disposed
  90252. */
  90253. readonly isDisposed: boolean;
  90254. /**
  90255. * Call this function to reduce memory footprint of the scene.
  90256. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  90257. */
  90258. clearCachedVertexData(): void;
  90259. /**
  90260. * This function will remove the local cached buffer data from texture.
  90261. * It will save memory but will prevent the texture from being rebuilt
  90262. */
  90263. cleanCachedTextureBuffer(): void;
  90264. /**
  90265. * Get the world extend vectors with an optional filter
  90266. *
  90267. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  90268. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  90269. */
  90270. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  90271. min: Vector3;
  90272. max: Vector3;
  90273. };
  90274. /**
  90275. * Creates a ray that can be used to pick in the scene
  90276. * @param x defines the x coordinate of the origin (on-screen)
  90277. * @param y defines the y coordinate of the origin (on-screen)
  90278. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90279. * @param camera defines the camera to use for the picking
  90280. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90281. * @returns a Ray
  90282. */
  90283. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  90284. /**
  90285. * Creates a ray that can be used to pick in the scene
  90286. * @param x defines the x coordinate of the origin (on-screen)
  90287. * @param y defines the y coordinate of the origin (on-screen)
  90288. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  90289. * @param result defines the ray where to store the picking ray
  90290. * @param camera defines the camera to use for the picking
  90291. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  90292. * @returns the current scene
  90293. */
  90294. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  90295. /**
  90296. * Creates a ray that can be used to pick in the scene
  90297. * @param x defines the x coordinate of the origin (on-screen)
  90298. * @param y defines the y coordinate of the origin (on-screen)
  90299. * @param camera defines the camera to use for the picking
  90300. * @returns a Ray
  90301. */
  90302. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  90303. /**
  90304. * Creates a ray that can be used to pick in the scene
  90305. * @param x defines the x coordinate of the origin (on-screen)
  90306. * @param y defines the y coordinate of the origin (on-screen)
  90307. * @param result defines the ray where to store the picking ray
  90308. * @param camera defines the camera to use for the picking
  90309. * @returns the current scene
  90310. */
  90311. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  90312. /** Launch a ray to try to pick a mesh in the scene
  90313. * @param x position on screen
  90314. * @param y position on screen
  90315. * @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
  90316. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  90317. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90318. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90319. * @returns a PickingInfo
  90320. */
  90321. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  90322. /** Use the given ray to pick a mesh in the scene
  90323. * @param ray The ray to use to pick meshes
  90324. * @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
  90325. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  90326. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90327. * @returns a PickingInfo
  90328. */
  90329. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90330. /**
  90331. * Launch a ray to try to pick a mesh in the scene
  90332. * @param x X position on screen
  90333. * @param y Y position on screen
  90334. * @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
  90335. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90336. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90337. * @returns an array of PickingInfo
  90338. */
  90339. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90340. /**
  90341. * Launch a ray to try to pick a mesh in the scene
  90342. * @param ray Ray to use
  90343. * @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
  90344. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90345. * @returns an array of PickingInfo
  90346. */
  90347. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90348. /**
  90349. * Force the value of meshUnderPointer
  90350. * @param mesh defines the mesh to use
  90351. */
  90352. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  90353. /**
  90354. * Gets the mesh under the pointer
  90355. * @returns a Mesh or null if no mesh is under the pointer
  90356. */
  90357. getPointerOverMesh(): Nullable<AbstractMesh>;
  90358. /** @hidden */
  90359. _rebuildGeometries(): void;
  90360. /** @hidden */
  90361. _rebuildTextures(): void;
  90362. private _getByTags;
  90363. /**
  90364. * Get a list of meshes by tags
  90365. * @param tagsQuery defines the tags query to use
  90366. * @param forEach defines a predicate used to filter results
  90367. * @returns an array of Mesh
  90368. */
  90369. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  90370. /**
  90371. * Get a list of cameras by tags
  90372. * @param tagsQuery defines the tags query to use
  90373. * @param forEach defines a predicate used to filter results
  90374. * @returns an array of Camera
  90375. */
  90376. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  90377. /**
  90378. * Get a list of lights by tags
  90379. * @param tagsQuery defines the tags query to use
  90380. * @param forEach defines a predicate used to filter results
  90381. * @returns an array of Light
  90382. */
  90383. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  90384. /**
  90385. * Get a list of materials by tags
  90386. * @param tagsQuery defines the tags query to use
  90387. * @param forEach defines a predicate used to filter results
  90388. * @returns an array of Material
  90389. */
  90390. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  90391. /**
  90392. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90393. * This allowed control for front to back rendering or reversly depending of the special needs.
  90394. *
  90395. * @param renderingGroupId The rendering group id corresponding to its index
  90396. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90397. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90398. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90399. */
  90400. 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;
  90401. /**
  90402. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90403. *
  90404. * @param renderingGroupId The rendering group id corresponding to its index
  90405. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90406. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90407. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90408. */
  90409. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90410. /**
  90411. * Gets the current auto clear configuration for one rendering group of the rendering
  90412. * manager.
  90413. * @param index the rendering group index to get the information for
  90414. * @returns The auto clear setup for the requested rendering group
  90415. */
  90416. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90417. private _blockMaterialDirtyMechanism;
  90418. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  90419. blockMaterialDirtyMechanism: boolean;
  90420. /**
  90421. * Will flag all materials as dirty to trigger new shader compilation
  90422. * @param flag defines the flag used to specify which material part must be marked as dirty
  90423. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  90424. */
  90425. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90426. /** @hidden */
  90427. _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;
  90428. /** @hidden */
  90429. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  90430. }
  90431. }
  90432. declare module BABYLON {
  90433. /**
  90434. * Set of assets to keep when moving a scene into an asset container.
  90435. */
  90436. export class KeepAssets extends AbstractScene {
  90437. }
  90438. /**
  90439. * Container with a set of assets that can be added or removed from a scene.
  90440. */
  90441. export class AssetContainer extends AbstractScene {
  90442. /**
  90443. * The scene the AssetContainer belongs to.
  90444. */
  90445. scene: Scene;
  90446. /**
  90447. * Instantiates an AssetContainer.
  90448. * @param scene The scene the AssetContainer belongs to.
  90449. */
  90450. constructor(scene: Scene);
  90451. /**
  90452. * Adds all the assets from the container to the scene.
  90453. */
  90454. addAllToScene(): void;
  90455. /**
  90456. * Removes all the assets in the container from the scene
  90457. */
  90458. removeAllFromScene(): void;
  90459. /**
  90460. * Disposes all the assets in the container
  90461. */
  90462. dispose(): void;
  90463. private _moveAssets;
  90464. /**
  90465. * Removes all the assets contained in the scene and adds them to the container.
  90466. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  90467. */
  90468. moveAllFromScene(keepAssets?: KeepAssets): void;
  90469. /**
  90470. * 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.
  90471. * @returns the root mesh
  90472. */
  90473. createRootMesh(): Mesh;
  90474. }
  90475. }
  90476. declare module BABYLON {
  90477. /**
  90478. * Defines how the parser contract is defined.
  90479. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  90480. */
  90481. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  90482. /**
  90483. * Defines how the individual parser contract is defined.
  90484. * These parser can parse an individual asset
  90485. */
  90486. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  90487. /**
  90488. * Base class of the scene acting as a container for the different elements composing a scene.
  90489. * This class is dynamically extended by the different components of the scene increasing
  90490. * flexibility and reducing coupling
  90491. */
  90492. export abstract class AbstractScene {
  90493. /**
  90494. * Stores the list of available parsers in the application.
  90495. */
  90496. private static _BabylonFileParsers;
  90497. /**
  90498. * Stores the list of available individual parsers in the application.
  90499. */
  90500. private static _IndividualBabylonFileParsers;
  90501. /**
  90502. * Adds a parser in the list of available ones
  90503. * @param name Defines the name of the parser
  90504. * @param parser Defines the parser to add
  90505. */
  90506. static AddParser(name: string, parser: BabylonFileParser): void;
  90507. /**
  90508. * Gets a general parser from the list of avaialble ones
  90509. * @param name Defines the name of the parser
  90510. * @returns the requested parser or null
  90511. */
  90512. static GetParser(name: string): Nullable<BabylonFileParser>;
  90513. /**
  90514. * Adds n individual parser in the list of available ones
  90515. * @param name Defines the name of the parser
  90516. * @param parser Defines the parser to add
  90517. */
  90518. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  90519. /**
  90520. * Gets an individual parser from the list of avaialble ones
  90521. * @param name Defines the name of the parser
  90522. * @returns the requested parser or null
  90523. */
  90524. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  90525. /**
  90526. * Parser json data and populate both a scene and its associated container object
  90527. * @param jsonData Defines the data to parse
  90528. * @param scene Defines the scene to parse the data for
  90529. * @param container Defines the container attached to the parsing sequence
  90530. * @param rootUrl Defines the root url of the data
  90531. */
  90532. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  90533. /**
  90534. * Gets the list of root nodes (ie. nodes with no parent)
  90535. */
  90536. rootNodes: Node[];
  90537. /** All of the cameras added to this scene
  90538. * @see http://doc.babylonjs.com/babylon101/cameras
  90539. */
  90540. cameras: Camera[];
  90541. /**
  90542. * All of the lights added to this scene
  90543. * @see http://doc.babylonjs.com/babylon101/lights
  90544. */
  90545. lights: Light[];
  90546. /**
  90547. * All of the (abstract) meshes added to this scene
  90548. */
  90549. meshes: AbstractMesh[];
  90550. /**
  90551. * The list of skeletons added to the scene
  90552. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90553. */
  90554. skeletons: Skeleton[];
  90555. /**
  90556. * All of the particle systems added to this scene
  90557. * @see http://doc.babylonjs.com/babylon101/particles
  90558. */
  90559. particleSystems: IParticleSystem[];
  90560. /**
  90561. * Gets a list of Animations associated with the scene
  90562. */
  90563. animations: Animation[];
  90564. /**
  90565. * All of the animation groups added to this scene
  90566. * @see http://doc.babylonjs.com/how_to/group
  90567. */
  90568. animationGroups: AnimationGroup[];
  90569. /**
  90570. * All of the multi-materials added to this scene
  90571. * @see http://doc.babylonjs.com/how_to/multi_materials
  90572. */
  90573. multiMaterials: MultiMaterial[];
  90574. /**
  90575. * All of the materials added to this scene
  90576. * In the context of a Scene, it is not supposed to be modified manually.
  90577. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  90578. * Note also that the order of the Material wihin the array is not significant and might change.
  90579. * @see http://doc.babylonjs.com/babylon101/materials
  90580. */
  90581. materials: Material[];
  90582. /**
  90583. * The list of morph target managers added to the scene
  90584. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  90585. */
  90586. morphTargetManagers: MorphTargetManager[];
  90587. /**
  90588. * The list of geometries used in the scene.
  90589. */
  90590. geometries: Geometry[];
  90591. /**
  90592. * All of the tranform nodes added to this scene
  90593. * In the context of a Scene, it is not supposed to be modified manually.
  90594. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  90595. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  90596. * @see http://doc.babylonjs.com/how_to/transformnode
  90597. */
  90598. transformNodes: TransformNode[];
  90599. /**
  90600. * ActionManagers available on the scene.
  90601. */
  90602. actionManagers: AbstractActionManager[];
  90603. /**
  90604. * Textures to keep.
  90605. */
  90606. textures: BaseTexture[];
  90607. }
  90608. }
  90609. declare module BABYLON {
  90610. /**
  90611. * Defines a sound that can be played in the application.
  90612. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  90613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90614. */
  90615. export class Sound {
  90616. /**
  90617. * The name of the sound in the scene.
  90618. */
  90619. name: string;
  90620. /**
  90621. * Does the sound autoplay once loaded.
  90622. */
  90623. autoplay: boolean;
  90624. /**
  90625. * Does the sound loop after it finishes playing once.
  90626. */
  90627. loop: boolean;
  90628. /**
  90629. * Does the sound use a custom attenuation curve to simulate the falloff
  90630. * happening when the source gets further away from the camera.
  90631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90632. */
  90633. useCustomAttenuation: boolean;
  90634. /**
  90635. * The sound track id this sound belongs to.
  90636. */
  90637. soundTrackId: number;
  90638. /**
  90639. * Is this sound currently played.
  90640. */
  90641. isPlaying: boolean;
  90642. /**
  90643. * Is this sound currently paused.
  90644. */
  90645. isPaused: boolean;
  90646. /**
  90647. * Does this sound enables spatial sound.
  90648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90649. */
  90650. spatialSound: boolean;
  90651. /**
  90652. * Define the reference distance the sound should be heard perfectly.
  90653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90654. */
  90655. refDistance: number;
  90656. /**
  90657. * Define the roll off factor of spatial sounds.
  90658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90659. */
  90660. rolloffFactor: number;
  90661. /**
  90662. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  90663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90664. */
  90665. maxDistance: number;
  90666. /**
  90667. * Define the distance attenuation model the sound will follow.
  90668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90669. */
  90670. distanceModel: string;
  90671. /**
  90672. * @hidden
  90673. * Back Compat
  90674. **/
  90675. onended: () => any;
  90676. /**
  90677. * Observable event when the current playing sound finishes.
  90678. */
  90679. onEndedObservable: Observable<Sound>;
  90680. private _panningModel;
  90681. private _playbackRate;
  90682. private _streaming;
  90683. private _startTime;
  90684. private _startOffset;
  90685. private _position;
  90686. /** @hidden */
  90687. _positionInEmitterSpace: boolean;
  90688. private _localDirection;
  90689. private _volume;
  90690. private _isReadyToPlay;
  90691. private _isDirectional;
  90692. private _readyToPlayCallback;
  90693. private _audioBuffer;
  90694. private _soundSource;
  90695. private _streamingSource;
  90696. private _soundPanner;
  90697. private _soundGain;
  90698. private _inputAudioNode;
  90699. private _outputAudioNode;
  90700. private _coneInnerAngle;
  90701. private _coneOuterAngle;
  90702. private _coneOuterGain;
  90703. private _scene;
  90704. private _connectedTransformNode;
  90705. private _customAttenuationFunction;
  90706. private _registerFunc;
  90707. private _isOutputConnected;
  90708. private _htmlAudioElement;
  90709. private _urlType;
  90710. /** @hidden */
  90711. static _SceneComponentInitialization: (scene: Scene) => void;
  90712. /**
  90713. * Create a sound and attach it to a scene
  90714. * @param name Name of your sound
  90715. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  90716. * @param scene defines the scene the sound belongs to
  90717. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  90718. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  90719. */
  90720. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  90721. /**
  90722. * Release the sound and its associated resources
  90723. */
  90724. dispose(): void;
  90725. /**
  90726. * Gets if the sounds is ready to be played or not.
  90727. * @returns true if ready, otherwise false
  90728. */
  90729. isReady(): boolean;
  90730. private _soundLoaded;
  90731. /**
  90732. * Sets the data of the sound from an audiobuffer
  90733. * @param audioBuffer The audioBuffer containing the data
  90734. */
  90735. setAudioBuffer(audioBuffer: AudioBuffer): void;
  90736. /**
  90737. * Updates the current sounds options such as maxdistance, loop...
  90738. * @param options A JSON object containing values named as the object properties
  90739. */
  90740. updateOptions(options: any): void;
  90741. private _createSpatialParameters;
  90742. private _updateSpatialParameters;
  90743. /**
  90744. * Switch the panning model to HRTF:
  90745. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  90746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90747. */
  90748. switchPanningModelToHRTF(): void;
  90749. /**
  90750. * Switch the panning model to Equal Power:
  90751. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  90752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  90753. */
  90754. switchPanningModelToEqualPower(): void;
  90755. private _switchPanningModel;
  90756. /**
  90757. * Connect this sound to a sound track audio node like gain...
  90758. * @param soundTrackAudioNode the sound track audio node to connect to
  90759. */
  90760. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  90761. /**
  90762. * Transform this sound into a directional source
  90763. * @param coneInnerAngle Size of the inner cone in degree
  90764. * @param coneOuterAngle Size of the outer cone in degree
  90765. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  90766. */
  90767. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  90768. /**
  90769. * Gets or sets the inner angle for the directional cone.
  90770. */
  90771. /**
  90772. * Gets or sets the inner angle for the directional cone.
  90773. */
  90774. directionalConeInnerAngle: number;
  90775. /**
  90776. * Gets or sets the outer angle for the directional cone.
  90777. */
  90778. /**
  90779. * Gets or sets the outer angle for the directional cone.
  90780. */
  90781. directionalConeOuterAngle: number;
  90782. /**
  90783. * Sets the position of the emitter if spatial sound is enabled
  90784. * @param newPosition Defines the new posisiton
  90785. */
  90786. setPosition(newPosition: Vector3): void;
  90787. /**
  90788. * Sets the local direction of the emitter if spatial sound is enabled
  90789. * @param newLocalDirection Defines the new local direction
  90790. */
  90791. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  90792. private _updateDirection;
  90793. /** @hidden */
  90794. updateDistanceFromListener(): void;
  90795. /**
  90796. * Sets a new custom attenuation function for the sound.
  90797. * @param callback Defines the function used for the attenuation
  90798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  90799. */
  90800. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  90801. /**
  90802. * Play the sound
  90803. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  90804. * @param offset (optional) Start the sound setting it at a specific time
  90805. */
  90806. play(time?: number, offset?: number): void;
  90807. private _onended;
  90808. /**
  90809. * Stop the sound
  90810. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  90811. */
  90812. stop(time?: number): void;
  90813. /**
  90814. * Put the sound in pause
  90815. */
  90816. pause(): void;
  90817. /**
  90818. * Sets a dedicated volume for this sounds
  90819. * @param newVolume Define the new volume of the sound
  90820. * @param time Define in how long the sound should be at this value
  90821. */
  90822. setVolume(newVolume: number, time?: number): void;
  90823. /**
  90824. * Set the sound play back rate
  90825. * @param newPlaybackRate Define the playback rate the sound should be played at
  90826. */
  90827. setPlaybackRate(newPlaybackRate: number): void;
  90828. /**
  90829. * Gets the volume of the sound.
  90830. * @returns the volume of the sound
  90831. */
  90832. getVolume(): number;
  90833. /**
  90834. * Attach the sound to a dedicated mesh
  90835. * @param transformNode The transform node to connect the sound with
  90836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90837. */
  90838. attachToMesh(transformNode: TransformNode): void;
  90839. /**
  90840. * Detach the sound from the previously attached mesh
  90841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  90842. */
  90843. detachFromMesh(): void;
  90844. private _onRegisterAfterWorldMatrixUpdate;
  90845. /**
  90846. * Clone the current sound in the scene.
  90847. * @returns the new sound clone
  90848. */
  90849. clone(): Nullable<Sound>;
  90850. /**
  90851. * Gets the current underlying audio buffer containing the data
  90852. * @returns the audio buffer
  90853. */
  90854. getAudioBuffer(): Nullable<AudioBuffer>;
  90855. /**
  90856. * Serializes the Sound in a JSON representation
  90857. * @returns the JSON representation of the sound
  90858. */
  90859. serialize(): any;
  90860. /**
  90861. * Parse a JSON representation of a sound to innstantiate in a given scene
  90862. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  90863. * @param scene Define the scene the new parsed sound should be created in
  90864. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  90865. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  90866. * @returns the newly parsed sound
  90867. */
  90868. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  90869. }
  90870. }
  90871. declare module BABYLON {
  90872. /**
  90873. * This defines an action helpful to play a defined sound on a triggered action.
  90874. */
  90875. export class PlaySoundAction extends Action {
  90876. private _sound;
  90877. /**
  90878. * Instantiate the action
  90879. * @param triggerOptions defines the trigger options
  90880. * @param sound defines the sound to play
  90881. * @param condition defines the trigger related conditions
  90882. */
  90883. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90884. /** @hidden */
  90885. _prepare(): void;
  90886. /**
  90887. * Execute the action and play the sound.
  90888. */
  90889. execute(): void;
  90890. /**
  90891. * Serializes the actions and its related information.
  90892. * @param parent defines the object to serialize in
  90893. * @returns the serialized object
  90894. */
  90895. serialize(parent: any): any;
  90896. }
  90897. /**
  90898. * This defines an action helpful to stop a defined sound on a triggered action.
  90899. */
  90900. export class StopSoundAction extends Action {
  90901. private _sound;
  90902. /**
  90903. * Instantiate the action
  90904. * @param triggerOptions defines the trigger options
  90905. * @param sound defines the sound to stop
  90906. * @param condition defines the trigger related conditions
  90907. */
  90908. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  90909. /** @hidden */
  90910. _prepare(): void;
  90911. /**
  90912. * Execute the action and stop the sound.
  90913. */
  90914. execute(): void;
  90915. /**
  90916. * Serializes the actions and its related information.
  90917. * @param parent defines the object to serialize in
  90918. * @returns the serialized object
  90919. */
  90920. serialize(parent: any): any;
  90921. }
  90922. }
  90923. declare module BABYLON {
  90924. /**
  90925. * This defines an action responsible to change the value of a property
  90926. * by interpolating between its current value and the newly set one once triggered.
  90927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90928. */
  90929. export class InterpolateValueAction extends Action {
  90930. /**
  90931. * Defines the path of the property where the value should be interpolated
  90932. */
  90933. propertyPath: string;
  90934. /**
  90935. * Defines the target value at the end of the interpolation.
  90936. */
  90937. value: any;
  90938. /**
  90939. * Defines the time it will take for the property to interpolate to the value.
  90940. */
  90941. duration: number;
  90942. /**
  90943. * Defines if the other scene animations should be stopped when the action has been triggered
  90944. */
  90945. stopOtherAnimations?: boolean;
  90946. /**
  90947. * Defines a callback raised once the interpolation animation has been done.
  90948. */
  90949. onInterpolationDone?: () => void;
  90950. /**
  90951. * Observable triggered once the interpolation animation has been done.
  90952. */
  90953. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  90954. private _target;
  90955. private _effectiveTarget;
  90956. private _property;
  90957. /**
  90958. * Instantiate the action
  90959. * @param triggerOptions defines the trigger options
  90960. * @param target defines the object containing the value to interpolate
  90961. * @param propertyPath defines the path to the property in the target object
  90962. * @param value defines the target value at the end of the interpolation
  90963. * @param duration deines the time it will take for the property to interpolate to the value.
  90964. * @param condition defines the trigger related conditions
  90965. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  90966. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  90967. */
  90968. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  90969. /** @hidden */
  90970. _prepare(): void;
  90971. /**
  90972. * Execute the action starts the value interpolation.
  90973. */
  90974. execute(): void;
  90975. /**
  90976. * Serializes the actions and its related information.
  90977. * @param parent defines the object to serialize in
  90978. * @returns the serialized object
  90979. */
  90980. serialize(parent: any): any;
  90981. }
  90982. }
  90983. declare module BABYLON {
  90984. /**
  90985. * Options allowed during the creation of a sound track.
  90986. */
  90987. export interface ISoundTrackOptions {
  90988. /**
  90989. * The volume the sound track should take during creation
  90990. */
  90991. volume?: number;
  90992. /**
  90993. * Define if the sound track is the main sound track of the scene
  90994. */
  90995. mainTrack?: boolean;
  90996. }
  90997. /**
  90998. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  90999. * It will be also used in a future release to apply effects on a specific track.
  91000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91001. */
  91002. export class SoundTrack {
  91003. /**
  91004. * The unique identifier of the sound track in the scene.
  91005. */
  91006. id: number;
  91007. /**
  91008. * The list of sounds included in the sound track.
  91009. */
  91010. soundCollection: Array<Sound>;
  91011. private _outputAudioNode;
  91012. private _scene;
  91013. private _isMainTrack;
  91014. private _connectedAnalyser;
  91015. private _options;
  91016. private _isInitialized;
  91017. /**
  91018. * Creates a new sound track.
  91019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  91020. * @param scene Define the scene the sound track belongs to
  91021. * @param options
  91022. */
  91023. constructor(scene: Scene, options?: ISoundTrackOptions);
  91024. private _initializeSoundTrackAudioGraph;
  91025. /**
  91026. * Release the sound track and its associated resources
  91027. */
  91028. dispose(): void;
  91029. /**
  91030. * Adds a sound to this sound track
  91031. * @param sound define the cound to add
  91032. * @ignoreNaming
  91033. */
  91034. AddSound(sound: Sound): void;
  91035. /**
  91036. * Removes a sound to this sound track
  91037. * @param sound define the cound to remove
  91038. * @ignoreNaming
  91039. */
  91040. RemoveSound(sound: Sound): void;
  91041. /**
  91042. * Set a global volume for the full sound track.
  91043. * @param newVolume Define the new volume of the sound track
  91044. */
  91045. setVolume(newVolume: number): void;
  91046. /**
  91047. * Switch the panning model to HRTF:
  91048. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91050. */
  91051. switchPanningModelToHRTF(): void;
  91052. /**
  91053. * Switch the panning model to Equal Power:
  91054. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91056. */
  91057. switchPanningModelToEqualPower(): void;
  91058. /**
  91059. * Connect the sound track to an audio analyser allowing some amazing
  91060. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  91061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  91062. * @param analyser The analyser to connect to the engine
  91063. */
  91064. connectToAnalyser(analyser: Analyser): void;
  91065. }
  91066. }
  91067. declare module BABYLON {
  91068. interface AbstractScene {
  91069. /**
  91070. * The list of sounds used in the scene.
  91071. */
  91072. sounds: Nullable<Array<Sound>>;
  91073. }
  91074. interface Scene {
  91075. /**
  91076. * @hidden
  91077. * Backing field
  91078. */
  91079. _mainSoundTrack: SoundTrack;
  91080. /**
  91081. * The main sound track played by the scene.
  91082. * It cotains your primary collection of sounds.
  91083. */
  91084. mainSoundTrack: SoundTrack;
  91085. /**
  91086. * The list of sound tracks added to the scene
  91087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91088. */
  91089. soundTracks: Nullable<Array<SoundTrack>>;
  91090. /**
  91091. * Gets a sound using a given name
  91092. * @param name defines the name to search for
  91093. * @return the found sound or null if not found at all.
  91094. */
  91095. getSoundByName(name: string): Nullable<Sound>;
  91096. /**
  91097. * Gets or sets if audio support is enabled
  91098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91099. */
  91100. audioEnabled: boolean;
  91101. /**
  91102. * Gets or sets if audio will be output to headphones
  91103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91104. */
  91105. headphone: boolean;
  91106. }
  91107. /**
  91108. * Defines the sound scene component responsible to manage any sounds
  91109. * in a given scene.
  91110. */
  91111. export class AudioSceneComponent implements ISceneSerializableComponent {
  91112. /**
  91113. * The component name helpfull to identify the component in the list of scene components.
  91114. */
  91115. readonly name: string;
  91116. /**
  91117. * The scene the component belongs to.
  91118. */
  91119. scene: Scene;
  91120. private _audioEnabled;
  91121. /**
  91122. * Gets whether audio is enabled or not.
  91123. * Please use related enable/disable method to switch state.
  91124. */
  91125. readonly audioEnabled: boolean;
  91126. private _headphone;
  91127. /**
  91128. * Gets whether audio is outputing to headphone or not.
  91129. * Please use the according Switch methods to change output.
  91130. */
  91131. readonly headphone: boolean;
  91132. /**
  91133. * Creates a new instance of the component for the given scene
  91134. * @param scene Defines the scene to register the component in
  91135. */
  91136. constructor(scene: Scene);
  91137. /**
  91138. * Registers the component in a given scene
  91139. */
  91140. register(): void;
  91141. /**
  91142. * Rebuilds the elements related to this component in case of
  91143. * context lost for instance.
  91144. */
  91145. rebuild(): void;
  91146. /**
  91147. * Serializes the component data to the specified json object
  91148. * @param serializationObject The object to serialize to
  91149. */
  91150. serialize(serializationObject: any): void;
  91151. /**
  91152. * Adds all the element from the container to the scene
  91153. * @param container the container holding the elements
  91154. */
  91155. addFromContainer(container: AbstractScene): void;
  91156. /**
  91157. * Removes all the elements in the container from the scene
  91158. * @param container contains the elements to remove
  91159. */
  91160. removeFromContainer(container: AbstractScene): void;
  91161. /**
  91162. * Disposes the component and the associated ressources.
  91163. */
  91164. dispose(): void;
  91165. /**
  91166. * Disables audio in the associated scene.
  91167. */
  91168. disableAudio(): void;
  91169. /**
  91170. * Enables audio in the associated scene.
  91171. */
  91172. enableAudio(): void;
  91173. /**
  91174. * Switch audio to headphone output.
  91175. */
  91176. switchAudioModeForHeadphones(): void;
  91177. /**
  91178. * Switch audio to normal speakers.
  91179. */
  91180. switchAudioModeForNormalSpeakers(): void;
  91181. private _afterRender;
  91182. }
  91183. }
  91184. declare module BABYLON {
  91185. /**
  91186. * Wraps one or more Sound objects and selects one with random weight for playback.
  91187. */
  91188. export class WeightedSound {
  91189. /** When true a Sound will be selected and played when the current playing Sound completes. */
  91190. loop: boolean;
  91191. private _coneInnerAngle;
  91192. private _coneOuterAngle;
  91193. private _volume;
  91194. /** A Sound is currently playing. */
  91195. isPlaying: boolean;
  91196. /** A Sound is currently paused. */
  91197. isPaused: boolean;
  91198. private _sounds;
  91199. private _weights;
  91200. private _currentIndex?;
  91201. /**
  91202. * Creates a new WeightedSound from the list of sounds given.
  91203. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  91204. * @param sounds Array of Sounds that will be selected from.
  91205. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  91206. */
  91207. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  91208. /**
  91209. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  91210. */
  91211. /**
  91212. * The size of cone in degress for a directional sound in which there will be no attenuation.
  91213. */
  91214. directionalConeInnerAngle: number;
  91215. /**
  91216. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91217. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91218. */
  91219. /**
  91220. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  91221. * Listener angles between innerAngle and outerAngle will falloff linearly.
  91222. */
  91223. directionalConeOuterAngle: number;
  91224. /**
  91225. * Playback volume.
  91226. */
  91227. /**
  91228. * Playback volume.
  91229. */
  91230. volume: number;
  91231. private _onended;
  91232. /**
  91233. * Suspend playback
  91234. */
  91235. pause(): void;
  91236. /**
  91237. * Stop playback
  91238. */
  91239. stop(): void;
  91240. /**
  91241. * Start playback.
  91242. * @param startOffset Position the clip head at a specific time in seconds.
  91243. */
  91244. play(startOffset?: number): void;
  91245. }
  91246. }
  91247. declare module BABYLON {
  91248. /**
  91249. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  91250. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  91251. */
  91252. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  91253. /**
  91254. * Gets the name of the behavior.
  91255. */
  91256. readonly name: string;
  91257. /**
  91258. * The easing function used by animations
  91259. */
  91260. static EasingFunction: BackEase;
  91261. /**
  91262. * The easing mode used by animations
  91263. */
  91264. static EasingMode: number;
  91265. /**
  91266. * The duration of the animation, in milliseconds
  91267. */
  91268. transitionDuration: number;
  91269. /**
  91270. * Length of the distance animated by the transition when lower radius is reached
  91271. */
  91272. lowerRadiusTransitionRange: number;
  91273. /**
  91274. * Length of the distance animated by the transition when upper radius is reached
  91275. */
  91276. upperRadiusTransitionRange: number;
  91277. private _autoTransitionRange;
  91278. /**
  91279. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91280. */
  91281. /**
  91282. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  91283. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  91284. */
  91285. autoTransitionRange: boolean;
  91286. private _attachedCamera;
  91287. private _onAfterCheckInputsObserver;
  91288. private _onMeshTargetChangedObserver;
  91289. /**
  91290. * Initializes the behavior.
  91291. */
  91292. init(): void;
  91293. /**
  91294. * Attaches the behavior to its arc rotate camera.
  91295. * @param camera Defines the camera to attach the behavior to
  91296. */
  91297. attach(camera: ArcRotateCamera): void;
  91298. /**
  91299. * Detaches the behavior from its current arc rotate camera.
  91300. */
  91301. detach(): void;
  91302. private _radiusIsAnimating;
  91303. private _radiusBounceTransition;
  91304. private _animatables;
  91305. private _cachedWheelPrecision;
  91306. /**
  91307. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  91308. * @param radiusLimit The limit to check against.
  91309. * @return Bool to indicate if at limit.
  91310. */
  91311. private _isRadiusAtLimit;
  91312. /**
  91313. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  91314. * @param radiusDelta The delta by which to animate to. Can be negative.
  91315. */
  91316. private _applyBoundRadiusAnimation;
  91317. /**
  91318. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  91319. */
  91320. protected _clearAnimationLocks(): void;
  91321. /**
  91322. * Stops and removes all animations that have been applied to the camera
  91323. */
  91324. stopAllAnimations(): void;
  91325. }
  91326. }
  91327. declare module BABYLON {
  91328. /**
  91329. * 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.
  91330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  91331. */
  91332. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  91333. /**
  91334. * Gets the name of the behavior.
  91335. */
  91336. readonly name: string;
  91337. private _mode;
  91338. private _radiusScale;
  91339. private _positionScale;
  91340. private _defaultElevation;
  91341. private _elevationReturnTime;
  91342. private _elevationReturnWaitTime;
  91343. private _zoomStopsAnimation;
  91344. private _framingTime;
  91345. /**
  91346. * The easing function used by animations
  91347. */
  91348. static EasingFunction: ExponentialEase;
  91349. /**
  91350. * The easing mode used by animations
  91351. */
  91352. static EasingMode: number;
  91353. /**
  91354. * Sets the current mode used by the behavior
  91355. */
  91356. /**
  91357. * Gets current mode used by the behavior.
  91358. */
  91359. mode: number;
  91360. /**
  91361. * Sets the scale applied to the radius (1 by default)
  91362. */
  91363. /**
  91364. * Gets the scale applied to the radius
  91365. */
  91366. radiusScale: number;
  91367. /**
  91368. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91369. */
  91370. /**
  91371. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  91372. */
  91373. positionScale: number;
  91374. /**
  91375. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91376. * behaviour is triggered, in radians.
  91377. */
  91378. /**
  91379. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  91380. * behaviour is triggered, in radians.
  91381. */
  91382. defaultElevation: number;
  91383. /**
  91384. * Sets the time (in milliseconds) taken to return to the default beta position.
  91385. * Negative value indicates camera should not return to default.
  91386. */
  91387. /**
  91388. * Gets the time (in milliseconds) taken to return to the default beta position.
  91389. * Negative value indicates camera should not return to default.
  91390. */
  91391. elevationReturnTime: number;
  91392. /**
  91393. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91394. */
  91395. /**
  91396. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  91397. */
  91398. elevationReturnWaitTime: number;
  91399. /**
  91400. * Sets the flag that indicates if user zooming should stop animation.
  91401. */
  91402. /**
  91403. * Gets the flag that indicates if user zooming should stop animation.
  91404. */
  91405. zoomStopsAnimation: boolean;
  91406. /**
  91407. * Sets the transition time when framing the mesh, in milliseconds
  91408. */
  91409. /**
  91410. * Gets the transition time when framing the mesh, in milliseconds
  91411. */
  91412. framingTime: number;
  91413. /**
  91414. * Define if the behavior should automatically change the configured
  91415. * camera limits and sensibilities.
  91416. */
  91417. autoCorrectCameraLimitsAndSensibility: boolean;
  91418. private _onPrePointerObservableObserver;
  91419. private _onAfterCheckInputsObserver;
  91420. private _onMeshTargetChangedObserver;
  91421. private _attachedCamera;
  91422. private _isPointerDown;
  91423. private _lastInteractionTime;
  91424. /**
  91425. * Initializes the behavior.
  91426. */
  91427. init(): void;
  91428. /**
  91429. * Attaches the behavior to its arc rotate camera.
  91430. * @param camera Defines the camera to attach the behavior to
  91431. */
  91432. attach(camera: ArcRotateCamera): void;
  91433. /**
  91434. * Detaches the behavior from its current arc rotate camera.
  91435. */
  91436. detach(): void;
  91437. private _animatables;
  91438. private _betaIsAnimating;
  91439. private _betaTransition;
  91440. private _radiusTransition;
  91441. private _vectorTransition;
  91442. /**
  91443. * Targets the given mesh and updates zoom level accordingly.
  91444. * @param mesh The mesh to target.
  91445. * @param radius Optional. If a cached radius position already exists, overrides default.
  91446. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91447. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91448. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91449. */
  91450. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91451. /**
  91452. * Targets the given mesh with its children and updates zoom level accordingly.
  91453. * @param mesh The mesh to target.
  91454. * @param radius Optional. If a cached radius position already exists, overrides default.
  91455. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91456. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91457. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91458. */
  91459. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91460. /**
  91461. * Targets the given meshes with their children and updates zoom level accordingly.
  91462. * @param meshes The mesh to target.
  91463. * @param radius Optional. If a cached radius position already exists, overrides default.
  91464. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  91465. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91466. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91467. */
  91468. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91469. /**
  91470. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  91471. * @param minimumWorld Determines the smaller position of the bounding box extend
  91472. * @param maximumWorld Determines the bigger position of the bounding box extend
  91473. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  91474. * @param onAnimationEnd Callback triggered at the end of the framing animation
  91475. */
  91476. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  91477. /**
  91478. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  91479. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  91480. * frustum width.
  91481. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  91482. * to fully enclose the mesh in the viewing frustum.
  91483. */
  91484. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  91485. /**
  91486. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  91487. * is automatically returned to its default position (expected to be above ground plane).
  91488. */
  91489. private _maintainCameraAboveGround;
  91490. /**
  91491. * Returns the frustum slope based on the canvas ratio and camera FOV
  91492. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  91493. */
  91494. private _getFrustumSlope;
  91495. /**
  91496. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  91497. */
  91498. private _clearAnimationLocks;
  91499. /**
  91500. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  91501. */
  91502. private _applyUserInteraction;
  91503. /**
  91504. * Stops and removes all animations that have been applied to the camera
  91505. */
  91506. stopAllAnimations(): void;
  91507. /**
  91508. * Gets a value indicating if the user is moving the camera
  91509. */
  91510. readonly isUserIsMoving: boolean;
  91511. /**
  91512. * The camera can move all the way towards the mesh.
  91513. */
  91514. static IgnoreBoundsSizeMode: number;
  91515. /**
  91516. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  91517. */
  91518. static FitFrustumSidesMode: number;
  91519. }
  91520. }
  91521. declare module BABYLON {
  91522. /**
  91523. * Base class for Camera Pointer Inputs.
  91524. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  91525. * for example usage.
  91526. */
  91527. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  91528. /**
  91529. * Defines the camera the input is attached to.
  91530. */
  91531. abstract camera: Camera;
  91532. /**
  91533. * Whether keyboard modifier keys are pressed at time of last mouse event.
  91534. */
  91535. protected _altKey: boolean;
  91536. protected _ctrlKey: boolean;
  91537. protected _metaKey: boolean;
  91538. protected _shiftKey: boolean;
  91539. /**
  91540. * Which mouse buttons were pressed at time of last mouse event.
  91541. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  91542. */
  91543. protected _buttonsPressed: number;
  91544. /**
  91545. * Defines the buttons associated with the input to handle camera move.
  91546. */
  91547. buttons: number[];
  91548. /**
  91549. * Attach the input controls to a specific dom element to get the input from.
  91550. * @param element Defines the element the controls should be listened from
  91551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91552. */
  91553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91554. /**
  91555. * Detach the current controls from the specified dom element.
  91556. * @param element Defines the element to stop listening the inputs from
  91557. */
  91558. detachControl(element: Nullable<HTMLElement>): void;
  91559. /**
  91560. * Gets the class name of the current input.
  91561. * @returns the class name
  91562. */
  91563. getClassName(): string;
  91564. /**
  91565. * Get the friendly name associated with the input class.
  91566. * @returns the input friendly name
  91567. */
  91568. getSimpleName(): string;
  91569. /**
  91570. * Called on pointer POINTERDOUBLETAP event.
  91571. * Override this method to provide functionality on POINTERDOUBLETAP event.
  91572. */
  91573. protected onDoubleTap(type: string): void;
  91574. /**
  91575. * Called on pointer POINTERMOVE event if only a single touch is active.
  91576. * Override this method to provide functionality.
  91577. */
  91578. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91579. /**
  91580. * Called on pointer POINTERMOVE event if multiple touches are active.
  91581. * Override this method to provide functionality.
  91582. */
  91583. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91584. /**
  91585. * Called on JS contextmenu event.
  91586. * Override this method to provide functionality.
  91587. */
  91588. protected onContextMenu(evt: PointerEvent): void;
  91589. /**
  91590. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91591. * press.
  91592. * Override this method to provide functionality.
  91593. */
  91594. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91595. /**
  91596. * Called each time a new POINTERUP event occurs. Ie, for each button
  91597. * release.
  91598. * Override this method to provide functionality.
  91599. */
  91600. protected onButtonUp(evt: PointerEvent): void;
  91601. /**
  91602. * Called when window becomes inactive.
  91603. * Override this method to provide functionality.
  91604. */
  91605. protected onLostFocus(): void;
  91606. private _pointerInput;
  91607. private _observer;
  91608. private _onLostFocus;
  91609. }
  91610. }
  91611. declare module BABYLON {
  91612. /**
  91613. * Manage the pointers inputs to control an arc rotate camera.
  91614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91615. */
  91616. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  91617. /**
  91618. * Defines the camera the input is attached to.
  91619. */
  91620. camera: ArcRotateCamera;
  91621. /**
  91622. * Gets the class name of the current input.
  91623. * @returns the class name
  91624. */
  91625. getClassName(): string;
  91626. /**
  91627. * Defines the buttons associated with the input to handle camera move.
  91628. */
  91629. buttons: number[];
  91630. /**
  91631. * Defines the pointer angular sensibility along the X axis or how fast is
  91632. * the camera rotating.
  91633. */
  91634. angularSensibilityX: number;
  91635. /**
  91636. * Defines the pointer angular sensibility along the Y axis or how fast is
  91637. * the camera rotating.
  91638. */
  91639. angularSensibilityY: number;
  91640. /**
  91641. * Defines the pointer pinch precision or how fast is the camera zooming.
  91642. */
  91643. pinchPrecision: number;
  91644. /**
  91645. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  91646. * from 0.
  91647. * It defines the percentage of current camera.radius to use as delta when
  91648. * pinch zoom is used.
  91649. */
  91650. pinchDeltaPercentage: number;
  91651. /**
  91652. * Defines the pointer panning sensibility or how fast is the camera moving.
  91653. */
  91654. panningSensibility: number;
  91655. /**
  91656. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  91657. */
  91658. multiTouchPanning: boolean;
  91659. /**
  91660. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  91661. * zoom (pinch) through multitouch.
  91662. */
  91663. multiTouchPanAndZoom: boolean;
  91664. /**
  91665. * Revers pinch action direction.
  91666. */
  91667. pinchInwards: boolean;
  91668. private _isPanClick;
  91669. private _twoFingerActivityCount;
  91670. private _isPinching;
  91671. /**
  91672. * Called on pointer POINTERMOVE event if only a single touch is active.
  91673. */
  91674. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  91675. /**
  91676. * Called on pointer POINTERDOUBLETAP event.
  91677. */
  91678. protected onDoubleTap(type: string): void;
  91679. /**
  91680. * Called on pointer POINTERMOVE event if multiple touches are active.
  91681. */
  91682. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  91683. /**
  91684. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  91685. * press.
  91686. */
  91687. protected onButtonDown(evt: PointerEvent, buttonCount: number): void;
  91688. /**
  91689. * Called each time a new POINTERUP event occurs. Ie, for each button
  91690. * release.
  91691. */
  91692. protected onButtonUp(evt: PointerEvent): void;
  91693. /**
  91694. * Called when window becomes inactive.
  91695. */
  91696. protected onLostFocus(): void;
  91697. }
  91698. }
  91699. declare module BABYLON {
  91700. /**
  91701. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  91702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91703. */
  91704. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  91705. /**
  91706. * Defines the camera the input is attached to.
  91707. */
  91708. camera: ArcRotateCamera;
  91709. /**
  91710. * Defines the list of key codes associated with the up action (increase alpha)
  91711. */
  91712. keysUp: number[];
  91713. /**
  91714. * Defines the list of key codes associated with the down action (decrease alpha)
  91715. */
  91716. keysDown: number[];
  91717. /**
  91718. * Defines the list of key codes associated with the left action (increase beta)
  91719. */
  91720. keysLeft: number[];
  91721. /**
  91722. * Defines the list of key codes associated with the right action (decrease beta)
  91723. */
  91724. keysRight: number[];
  91725. /**
  91726. * Defines the list of key codes associated with the reset action.
  91727. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  91728. */
  91729. keysReset: number[];
  91730. /**
  91731. * Defines the panning sensibility of the inputs.
  91732. * (How fast is the camera paning)
  91733. */
  91734. panningSensibility: number;
  91735. /**
  91736. * Defines the zooming sensibility of the inputs.
  91737. * (How fast is the camera zooming)
  91738. */
  91739. zoomingSensibility: number;
  91740. /**
  91741. * Defines wether maintaining the alt key down switch the movement mode from
  91742. * orientation to zoom.
  91743. */
  91744. useAltToZoom: boolean;
  91745. /**
  91746. * Rotation speed of the camera
  91747. */
  91748. angularSpeed: number;
  91749. private _keys;
  91750. private _ctrlPressed;
  91751. private _altPressed;
  91752. private _onCanvasBlurObserver;
  91753. private _onKeyboardObserver;
  91754. private _engine;
  91755. private _scene;
  91756. /**
  91757. * Attach the input controls to a specific dom element to get the input from.
  91758. * @param element Defines the element the controls should be listened from
  91759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91760. */
  91761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91762. /**
  91763. * Detach the current controls from the specified dom element.
  91764. * @param element Defines the element to stop listening the inputs from
  91765. */
  91766. detachControl(element: Nullable<HTMLElement>): void;
  91767. /**
  91768. * Update the current camera state depending on the inputs that have been used this frame.
  91769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91770. */
  91771. checkInputs(): void;
  91772. /**
  91773. * Gets the class name of the current intput.
  91774. * @returns the class name
  91775. */
  91776. getClassName(): string;
  91777. /**
  91778. * Get the friendly name associated with the input class.
  91779. * @returns the input friendly name
  91780. */
  91781. getSimpleName(): string;
  91782. }
  91783. }
  91784. declare module BABYLON {
  91785. /**
  91786. * Manage the mouse wheel inputs to control an arc rotate camera.
  91787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91788. */
  91789. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  91790. /**
  91791. * Defines the camera the input is attached to.
  91792. */
  91793. camera: ArcRotateCamera;
  91794. /**
  91795. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  91796. */
  91797. wheelPrecision: number;
  91798. /**
  91799. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  91800. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  91801. */
  91802. wheelDeltaPercentage: number;
  91803. private _wheel;
  91804. private _observer;
  91805. /**
  91806. * Attach the input controls to a specific dom element to get the input from.
  91807. * @param element Defines the element the controls should be listened from
  91808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91809. */
  91810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91811. /**
  91812. * Detach the current controls from the specified dom element.
  91813. * @param element Defines the element to stop listening the inputs from
  91814. */
  91815. detachControl(element: Nullable<HTMLElement>): void;
  91816. /**
  91817. * Gets the class name of the current intput.
  91818. * @returns the class name
  91819. */
  91820. getClassName(): string;
  91821. /**
  91822. * Get the friendly name associated with the input class.
  91823. * @returns the input friendly name
  91824. */
  91825. getSimpleName(): string;
  91826. }
  91827. }
  91828. declare module BABYLON {
  91829. /**
  91830. * Default Inputs manager for the ArcRotateCamera.
  91831. * It groups all the default supported inputs for ease of use.
  91832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91833. */
  91834. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  91835. /**
  91836. * Instantiates a new ArcRotateCameraInputsManager.
  91837. * @param camera Defines the camera the inputs belong to
  91838. */
  91839. constructor(camera: ArcRotateCamera);
  91840. /**
  91841. * Add mouse wheel input support to the input manager.
  91842. * @returns the current input manager
  91843. */
  91844. addMouseWheel(): ArcRotateCameraInputsManager;
  91845. /**
  91846. * Add pointers input support to the input manager.
  91847. * @returns the current input manager
  91848. */
  91849. addPointers(): ArcRotateCameraInputsManager;
  91850. /**
  91851. * Add keyboard input support to the input manager.
  91852. * @returns the current input manager
  91853. */
  91854. addKeyboard(): ArcRotateCameraInputsManager;
  91855. }
  91856. }
  91857. declare module BABYLON {
  91858. /**
  91859. * This represents an orbital type of camera.
  91860. *
  91861. * 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.
  91862. * 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.
  91863. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  91864. */
  91865. export class ArcRotateCamera extends TargetCamera {
  91866. /**
  91867. * Defines the rotation angle of the camera along the longitudinal axis.
  91868. */
  91869. alpha: number;
  91870. /**
  91871. * Defines the rotation angle of the camera along the latitudinal axis.
  91872. */
  91873. beta: number;
  91874. /**
  91875. * Defines the radius of the camera from it s target point.
  91876. */
  91877. radius: number;
  91878. protected _target: Vector3;
  91879. protected _targetHost: Nullable<AbstractMesh>;
  91880. /**
  91881. * Defines the target point of the camera.
  91882. * The camera looks towards it form the radius distance.
  91883. */
  91884. target: Vector3;
  91885. /**
  91886. * Define the current local position of the camera in the scene
  91887. */
  91888. position: Vector3;
  91889. /**
  91890. * Current inertia value on the longitudinal axis.
  91891. * The bigger this number the longer it will take for the camera to stop.
  91892. */
  91893. inertialAlphaOffset: number;
  91894. /**
  91895. * Current inertia value on the latitudinal axis.
  91896. * The bigger this number the longer it will take for the camera to stop.
  91897. */
  91898. inertialBetaOffset: number;
  91899. /**
  91900. * Current inertia value on the radius axis.
  91901. * The bigger this number the longer it will take for the camera to stop.
  91902. */
  91903. inertialRadiusOffset: number;
  91904. /**
  91905. * Minimum allowed angle on the longitudinal axis.
  91906. * This can help limiting how the Camera is able to move in the scene.
  91907. */
  91908. lowerAlphaLimit: Nullable<number>;
  91909. /**
  91910. * Maximum allowed angle on the longitudinal axis.
  91911. * This can help limiting how the Camera is able to move in the scene.
  91912. */
  91913. upperAlphaLimit: Nullable<number>;
  91914. /**
  91915. * Minimum allowed angle on the latitudinal axis.
  91916. * This can help limiting how the Camera is able to move in the scene.
  91917. */
  91918. lowerBetaLimit: number;
  91919. /**
  91920. * Maximum allowed angle on the latitudinal axis.
  91921. * This can help limiting how the Camera is able to move in the scene.
  91922. */
  91923. upperBetaLimit: number;
  91924. /**
  91925. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  91926. * This can help limiting how the Camera is able to move in the scene.
  91927. */
  91928. lowerRadiusLimit: Nullable<number>;
  91929. /**
  91930. * Maximum allowed distance of the camera to the target (The camera can not get further).
  91931. * This can help limiting how the Camera is able to move in the scene.
  91932. */
  91933. upperRadiusLimit: Nullable<number>;
  91934. /**
  91935. * Defines the current inertia value used during panning of the camera along the X axis.
  91936. */
  91937. inertialPanningX: number;
  91938. /**
  91939. * Defines the current inertia value used during panning of the camera along the Y axis.
  91940. */
  91941. inertialPanningY: number;
  91942. /**
  91943. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  91944. * Basically if your fingers moves away from more than this distance you will be considered
  91945. * in pinch mode.
  91946. */
  91947. pinchToPanMaxDistance: number;
  91948. /**
  91949. * Defines the maximum distance the camera can pan.
  91950. * This could help keeping the cammera always in your scene.
  91951. */
  91952. panningDistanceLimit: Nullable<number>;
  91953. /**
  91954. * Defines the target of the camera before paning.
  91955. */
  91956. panningOriginTarget: Vector3;
  91957. /**
  91958. * Defines the value of the inertia used during panning.
  91959. * 0 would mean stop inertia and one would mean no decelleration at all.
  91960. */
  91961. panningInertia: number;
  91962. /**
  91963. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  91964. */
  91965. angularSensibilityX: number;
  91966. /**
  91967. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  91968. */
  91969. angularSensibilityY: number;
  91970. /**
  91971. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  91972. */
  91973. pinchPrecision: number;
  91974. /**
  91975. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  91976. * It will be used instead of pinchDeltaPrecision if different from 0.
  91977. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  91978. */
  91979. pinchDeltaPercentage: number;
  91980. /**
  91981. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  91982. */
  91983. panningSensibility: number;
  91984. /**
  91985. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  91986. */
  91987. keysUp: number[];
  91988. /**
  91989. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  91990. */
  91991. keysDown: number[];
  91992. /**
  91993. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  91994. */
  91995. keysLeft: number[];
  91996. /**
  91997. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  91998. */
  91999. keysRight: number[];
  92000. /**
  92001. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92002. */
  92003. wheelPrecision: number;
  92004. /**
  92005. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  92006. * It will be used instead of pinchDeltaPrecision if different from 0.
  92007. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  92008. */
  92009. wheelDeltaPercentage: number;
  92010. /**
  92011. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  92012. */
  92013. zoomOnFactor: number;
  92014. /**
  92015. * Defines a screen offset for the camera position.
  92016. */
  92017. targetScreenOffset: Vector2;
  92018. /**
  92019. * Allows the camera to be completely reversed.
  92020. * If false the camera can not arrive upside down.
  92021. */
  92022. allowUpsideDown: boolean;
  92023. /**
  92024. * Define if double tap/click is used to restore the previously saved state of the camera.
  92025. */
  92026. useInputToRestoreState: boolean;
  92027. /** @hidden */
  92028. _viewMatrix: Matrix;
  92029. /** @hidden */
  92030. _useCtrlForPanning: boolean;
  92031. /** @hidden */
  92032. _panningMouseButton: number;
  92033. /**
  92034. * Defines the input associated to the camera.
  92035. */
  92036. inputs: ArcRotateCameraInputsManager;
  92037. /** @hidden */
  92038. _reset: () => void;
  92039. /**
  92040. * Defines the allowed panning axis.
  92041. */
  92042. panningAxis: Vector3;
  92043. protected _localDirection: Vector3;
  92044. protected _transformedDirection: Vector3;
  92045. private _bouncingBehavior;
  92046. /**
  92047. * Gets the bouncing behavior of the camera if it has been enabled.
  92048. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92049. */
  92050. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  92051. /**
  92052. * Defines if the bouncing behavior of the camera is enabled on the camera.
  92053. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92054. */
  92055. useBouncingBehavior: boolean;
  92056. private _framingBehavior;
  92057. /**
  92058. * Gets the framing behavior of the camera if it has been enabled.
  92059. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92060. */
  92061. readonly framingBehavior: Nullable<FramingBehavior>;
  92062. /**
  92063. * Defines if the framing behavior of the camera is enabled on the camera.
  92064. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92065. */
  92066. useFramingBehavior: boolean;
  92067. private _autoRotationBehavior;
  92068. /**
  92069. * Gets the auto rotation behavior of the camera if it has been enabled.
  92070. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92071. */
  92072. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  92073. /**
  92074. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  92075. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92076. */
  92077. useAutoRotationBehavior: boolean;
  92078. /**
  92079. * Observable triggered when the mesh target has been changed on the camera.
  92080. */
  92081. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  92082. /**
  92083. * Event raised when the camera is colliding with a mesh.
  92084. */
  92085. onCollide: (collidedMesh: AbstractMesh) => void;
  92086. /**
  92087. * Defines whether the camera should check collision with the objects oh the scene.
  92088. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  92089. */
  92090. checkCollisions: boolean;
  92091. /**
  92092. * Defines the collision radius of the camera.
  92093. * This simulates a sphere around the camera.
  92094. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92095. */
  92096. collisionRadius: Vector3;
  92097. protected _collider: Collider;
  92098. protected _previousPosition: Vector3;
  92099. protected _collisionVelocity: Vector3;
  92100. protected _newPosition: Vector3;
  92101. protected _previousAlpha: number;
  92102. protected _previousBeta: number;
  92103. protected _previousRadius: number;
  92104. protected _collisionTriggered: boolean;
  92105. protected _targetBoundingCenter: Nullable<Vector3>;
  92106. private _computationVector;
  92107. private _tempAxisVector;
  92108. private _tempAxisRotationMatrix;
  92109. /**
  92110. * Instantiates a new ArcRotateCamera in a given scene
  92111. * @param name Defines the name of the camera
  92112. * @param alpha Defines the camera rotation along the logitudinal axis
  92113. * @param beta Defines the camera rotation along the latitudinal axis
  92114. * @param radius Defines the camera distance from its target
  92115. * @param target Defines the camera target
  92116. * @param scene Defines the scene the camera belongs to
  92117. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92118. */
  92119. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92120. /** @hidden */
  92121. _initCache(): void;
  92122. /** @hidden */
  92123. _updateCache(ignoreParentClass?: boolean): void;
  92124. protected _getTargetPosition(): Vector3;
  92125. private _storedAlpha;
  92126. private _storedBeta;
  92127. private _storedRadius;
  92128. private _storedTarget;
  92129. /**
  92130. * Stores the current state of the camera (alpha, beta, radius and target)
  92131. * @returns the camera itself
  92132. */
  92133. storeState(): Camera;
  92134. /**
  92135. * @hidden
  92136. * Restored camera state. You must call storeState() first
  92137. */
  92138. _restoreStateValues(): boolean;
  92139. /** @hidden */
  92140. _isSynchronizedViewMatrix(): boolean;
  92141. /**
  92142. * Attached controls to the current camera.
  92143. * @param element Defines the element the controls should be listened from
  92144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92145. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  92146. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  92147. */
  92148. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  92149. /**
  92150. * Detach the current controls from the camera.
  92151. * The camera will stop reacting to inputs.
  92152. * @param element Defines the element to stop listening the inputs from
  92153. */
  92154. detachControl(element: HTMLElement): void;
  92155. /** @hidden */
  92156. _checkInputs(): void;
  92157. protected _checkLimits(): void;
  92158. /**
  92159. * Rebuilds angles (alpha, beta) and radius from the give position and target
  92160. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  92161. */
  92162. rebuildAnglesAndRadius(updateView?: boolean): void;
  92163. /**
  92164. * Use a position to define the current camera related information like aplha, beta and radius
  92165. * @param position Defines the position to set the camera at
  92166. */
  92167. setPosition(position: Vector3): void;
  92168. /**
  92169. * Defines the target the camera should look at.
  92170. * This will automatically adapt alpha beta and radius to fit within the new target.
  92171. * @param target Defines the new target as a Vector or a mesh
  92172. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  92173. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  92174. */
  92175. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  92176. /** @hidden */
  92177. _getViewMatrix(): Matrix;
  92178. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  92179. /**
  92180. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  92181. * @param meshes Defines the mesh to zoom on
  92182. * @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)
  92183. */
  92184. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  92185. /**
  92186. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  92187. * The target will be changed but the radius
  92188. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  92189. * @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)
  92190. */
  92191. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  92192. min: Vector3;
  92193. max: Vector3;
  92194. distance: number;
  92195. }, doNotUpdateMaxZ?: boolean): void;
  92196. /**
  92197. * @override
  92198. * Override Camera.createRigCamera
  92199. */
  92200. createRigCamera(name: string, cameraIndex: number): Camera;
  92201. /**
  92202. * @hidden
  92203. * @override
  92204. * Override Camera._updateRigCameras
  92205. */
  92206. _updateRigCameras(): void;
  92207. /**
  92208. * Destroy the camera and release the current resources hold by it.
  92209. */
  92210. dispose(): void;
  92211. /**
  92212. * Gets the current object class name.
  92213. * @return the class name
  92214. */
  92215. getClassName(): string;
  92216. }
  92217. }
  92218. declare module BABYLON {
  92219. /**
  92220. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  92221. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  92222. */
  92223. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  92224. /**
  92225. * Gets the name of the behavior.
  92226. */
  92227. readonly name: string;
  92228. private _zoomStopsAnimation;
  92229. private _idleRotationSpeed;
  92230. private _idleRotationWaitTime;
  92231. private _idleRotationSpinupTime;
  92232. /**
  92233. * Sets the flag that indicates if user zooming should stop animation.
  92234. */
  92235. /**
  92236. * Gets the flag that indicates if user zooming should stop animation.
  92237. */
  92238. zoomStopsAnimation: boolean;
  92239. /**
  92240. * Sets the default speed at which the camera rotates around the model.
  92241. */
  92242. /**
  92243. * Gets the default speed at which the camera rotates around the model.
  92244. */
  92245. idleRotationSpeed: number;
  92246. /**
  92247. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  92248. */
  92249. /**
  92250. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  92251. */
  92252. idleRotationWaitTime: number;
  92253. /**
  92254. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92255. */
  92256. /**
  92257. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  92258. */
  92259. idleRotationSpinupTime: number;
  92260. /**
  92261. * Gets a value indicating if the camera is currently rotating because of this behavior
  92262. */
  92263. readonly rotationInProgress: boolean;
  92264. private _onPrePointerObservableObserver;
  92265. private _onAfterCheckInputsObserver;
  92266. private _attachedCamera;
  92267. private _isPointerDown;
  92268. private _lastFrameTime;
  92269. private _lastInteractionTime;
  92270. private _cameraRotationSpeed;
  92271. /**
  92272. * Initializes the behavior.
  92273. */
  92274. init(): void;
  92275. /**
  92276. * Attaches the behavior to its arc rotate camera.
  92277. * @param camera Defines the camera to attach the behavior to
  92278. */
  92279. attach(camera: ArcRotateCamera): void;
  92280. /**
  92281. * Detaches the behavior from its current arc rotate camera.
  92282. */
  92283. detach(): void;
  92284. /**
  92285. * Returns true if user is scrolling.
  92286. * @return true if user is scrolling.
  92287. */
  92288. private _userIsZooming;
  92289. private _lastFrameRadius;
  92290. private _shouldAnimationStopForInteraction;
  92291. /**
  92292. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92293. */
  92294. private _applyUserInteraction;
  92295. private _userIsMoving;
  92296. }
  92297. }
  92298. declare module BABYLON {
  92299. /**
  92300. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  92301. */
  92302. export class AttachToBoxBehavior implements Behavior<Mesh> {
  92303. private ui;
  92304. /**
  92305. * The name of the behavior
  92306. */
  92307. name: string;
  92308. /**
  92309. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  92310. */
  92311. distanceAwayFromFace: number;
  92312. /**
  92313. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  92314. */
  92315. distanceAwayFromBottomOfFace: number;
  92316. private _faceVectors;
  92317. private _target;
  92318. private _scene;
  92319. private _onRenderObserver;
  92320. private _tmpMatrix;
  92321. private _tmpVector;
  92322. /**
  92323. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  92324. * @param ui The transform node that should be attched to the mesh
  92325. */
  92326. constructor(ui: TransformNode);
  92327. /**
  92328. * Initializes the behavior
  92329. */
  92330. init(): void;
  92331. private _closestFace;
  92332. private _zeroVector;
  92333. private _lookAtTmpMatrix;
  92334. private _lookAtToRef;
  92335. /**
  92336. * Attaches the AttachToBoxBehavior to the passed in mesh
  92337. * @param target The mesh that the specified node will be attached to
  92338. */
  92339. attach(target: Mesh): void;
  92340. /**
  92341. * Detaches the behavior from the mesh
  92342. */
  92343. detach(): void;
  92344. }
  92345. }
  92346. declare module BABYLON {
  92347. /**
  92348. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  92349. */
  92350. export class FadeInOutBehavior implements Behavior<Mesh> {
  92351. /**
  92352. * Time in milliseconds to delay before fading in (Default: 0)
  92353. */
  92354. delay: number;
  92355. /**
  92356. * Time in milliseconds for the mesh to fade in (Default: 300)
  92357. */
  92358. fadeInTime: number;
  92359. private _millisecondsPerFrame;
  92360. private _hovered;
  92361. private _hoverValue;
  92362. private _ownerNode;
  92363. /**
  92364. * Instatiates the FadeInOutBehavior
  92365. */
  92366. constructor();
  92367. /**
  92368. * The name of the behavior
  92369. */
  92370. readonly name: string;
  92371. /**
  92372. * Initializes the behavior
  92373. */
  92374. init(): void;
  92375. /**
  92376. * Attaches the fade behavior on the passed in mesh
  92377. * @param ownerNode The mesh that will be faded in/out once attached
  92378. */
  92379. attach(ownerNode: Mesh): void;
  92380. /**
  92381. * Detaches the behavior from the mesh
  92382. */
  92383. detach(): void;
  92384. /**
  92385. * Triggers the mesh to begin fading in or out
  92386. * @param value if the object should fade in or out (true to fade in)
  92387. */
  92388. fadeIn(value: boolean): void;
  92389. private _update;
  92390. private _setAllVisibility;
  92391. }
  92392. }
  92393. declare module BABYLON {
  92394. /**
  92395. * Class containing a set of static utilities functions for managing Pivots
  92396. * @hidden
  92397. */
  92398. export class PivotTools {
  92399. private static _PivotCached;
  92400. private static _OldPivotPoint;
  92401. private static _PivotTranslation;
  92402. private static _PivotTmpVector;
  92403. /** @hidden */
  92404. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  92405. /** @hidden */
  92406. static _RestorePivotPoint(mesh: AbstractMesh): void;
  92407. }
  92408. }
  92409. declare module BABYLON {
  92410. /**
  92411. * Class containing static functions to help procedurally build meshes
  92412. */
  92413. export class PlaneBuilder {
  92414. /**
  92415. * Creates a plane mesh
  92416. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92417. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92418. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92419. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92420. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92422. * @param name defines the name of the mesh
  92423. * @param options defines the options used to create the mesh
  92424. * @param scene defines the hosting scene
  92425. * @returns the plane mesh
  92426. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92427. */
  92428. static CreatePlane(name: string, options: {
  92429. size?: number;
  92430. width?: number;
  92431. height?: number;
  92432. sideOrientation?: number;
  92433. frontUVs?: Vector4;
  92434. backUVs?: Vector4;
  92435. updatable?: boolean;
  92436. sourcePlane?: Plane;
  92437. }, scene: Scene): Mesh;
  92438. }
  92439. }
  92440. declare module BABYLON {
  92441. /**
  92442. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  92443. */
  92444. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  92445. private static _AnyMouseID;
  92446. private _attachedNode;
  92447. private _dragPlane;
  92448. private _scene;
  92449. private _pointerObserver;
  92450. private _beforeRenderObserver;
  92451. private static _planeScene;
  92452. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  92453. /**
  92454. * 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)
  92455. */
  92456. maxDragAngle: number;
  92457. /**
  92458. * @hidden
  92459. */
  92460. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  92461. /**
  92462. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92463. */
  92464. currentDraggingPointerID: number;
  92465. /**
  92466. * The last position where the pointer hit the drag plane in world space
  92467. */
  92468. lastDragPosition: Vector3;
  92469. /**
  92470. * If the behavior is currently in a dragging state
  92471. */
  92472. dragging: boolean;
  92473. /**
  92474. * 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)
  92475. */
  92476. dragDeltaRatio: number;
  92477. /**
  92478. * If the drag plane orientation should be updated during the dragging (Default: true)
  92479. */
  92480. updateDragPlane: boolean;
  92481. private _debugMode;
  92482. private _moving;
  92483. /**
  92484. * Fires each time the attached mesh is dragged with the pointer
  92485. * * delta between last drag position and current drag position in world space
  92486. * * dragDistance along the drag axis
  92487. * * dragPlaneNormal normal of the current drag plane used during the drag
  92488. * * dragPlanePoint in world space where the drag intersects the drag plane
  92489. */
  92490. onDragObservable: Observable<{
  92491. delta: Vector3;
  92492. dragPlanePoint: Vector3;
  92493. dragPlaneNormal: Vector3;
  92494. dragDistance: number;
  92495. pointerId: number;
  92496. }>;
  92497. /**
  92498. * Fires each time a drag begins (eg. mouse down on mesh)
  92499. */
  92500. onDragStartObservable: Observable<{
  92501. dragPlanePoint: Vector3;
  92502. pointerId: number;
  92503. }>;
  92504. /**
  92505. * Fires each time a drag ends (eg. mouse release after drag)
  92506. */
  92507. onDragEndObservable: Observable<{
  92508. dragPlanePoint: Vector3;
  92509. pointerId: number;
  92510. }>;
  92511. /**
  92512. * If the attached mesh should be moved when dragged
  92513. */
  92514. moveAttached: boolean;
  92515. /**
  92516. * If the drag behavior will react to drag events (Default: true)
  92517. */
  92518. enabled: boolean;
  92519. /**
  92520. * If camera controls should be detached during the drag
  92521. */
  92522. detachCameraControls: boolean;
  92523. /**
  92524. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  92525. */
  92526. useObjectOrienationForDragging: boolean;
  92527. private _options;
  92528. /**
  92529. * Creates a pointer drag behavior that can be attached to a mesh
  92530. * @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)
  92531. */
  92532. constructor(options?: {
  92533. dragAxis?: Vector3;
  92534. dragPlaneNormal?: Vector3;
  92535. });
  92536. /**
  92537. * Predicate to determine if it is valid to move the object to a new position when it is moved
  92538. */
  92539. validateDrag: (targetPosition: Vector3) => boolean;
  92540. /**
  92541. * The name of the behavior
  92542. */
  92543. readonly name: string;
  92544. /**
  92545. * Initializes the behavior
  92546. */
  92547. init(): void;
  92548. private _tmpVector;
  92549. private _alternatePickedPoint;
  92550. private _worldDragAxis;
  92551. private _targetPosition;
  92552. private _attachedElement;
  92553. /**
  92554. * Attaches the drag behavior the passed in mesh
  92555. * @param ownerNode The mesh that will be dragged around once attached
  92556. */
  92557. attach(ownerNode: AbstractMesh): void;
  92558. /**
  92559. * Force relase the drag action by code.
  92560. */
  92561. releaseDrag(): void;
  92562. private _startDragRay;
  92563. private _lastPointerRay;
  92564. /**
  92565. * Simulates the start of a pointer drag event on the behavior
  92566. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  92567. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  92568. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  92569. */
  92570. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  92571. private _startDrag;
  92572. private _dragDelta;
  92573. private _moveDrag;
  92574. private _pickWithRayOnDragPlane;
  92575. private _pointA;
  92576. private _pointB;
  92577. private _pointC;
  92578. private _lineA;
  92579. private _lineB;
  92580. private _localAxis;
  92581. private _lookAt;
  92582. private _updateDragPlanePosition;
  92583. /**
  92584. * Detaches the behavior from the mesh
  92585. */
  92586. detach(): void;
  92587. }
  92588. }
  92589. declare module BABYLON {
  92590. /**
  92591. * A behavior that when attached to a mesh will allow the mesh to be scaled
  92592. */
  92593. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  92594. private _dragBehaviorA;
  92595. private _dragBehaviorB;
  92596. private _startDistance;
  92597. private _initialScale;
  92598. private _targetScale;
  92599. private _ownerNode;
  92600. private _sceneRenderObserver;
  92601. /**
  92602. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  92603. */
  92604. constructor();
  92605. /**
  92606. * The name of the behavior
  92607. */
  92608. readonly name: string;
  92609. /**
  92610. * Initializes the behavior
  92611. */
  92612. init(): void;
  92613. private _getCurrentDistance;
  92614. /**
  92615. * Attaches the scale behavior the passed in mesh
  92616. * @param ownerNode The mesh that will be scaled around once attached
  92617. */
  92618. attach(ownerNode: Mesh): void;
  92619. /**
  92620. * Detaches the behavior from the mesh
  92621. */
  92622. detach(): void;
  92623. }
  92624. }
  92625. declare module BABYLON {
  92626. /**
  92627. * 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
  92628. */
  92629. export class SixDofDragBehavior implements Behavior<Mesh> {
  92630. private static _virtualScene;
  92631. private _ownerNode;
  92632. private _sceneRenderObserver;
  92633. private _scene;
  92634. private _targetPosition;
  92635. private _virtualOriginMesh;
  92636. private _virtualDragMesh;
  92637. private _pointerObserver;
  92638. private _moving;
  92639. private _startingOrientation;
  92640. /**
  92641. * 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)
  92642. */
  92643. private zDragFactor;
  92644. /**
  92645. * If the object should rotate to face the drag origin
  92646. */
  92647. rotateDraggedObject: boolean;
  92648. /**
  92649. * If the behavior is currently in a dragging state
  92650. */
  92651. dragging: boolean;
  92652. /**
  92653. * 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)
  92654. */
  92655. dragDeltaRatio: number;
  92656. /**
  92657. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  92658. */
  92659. currentDraggingPointerID: number;
  92660. /**
  92661. * If camera controls should be detached during the drag
  92662. */
  92663. detachCameraControls: boolean;
  92664. /**
  92665. * Fires each time a drag starts
  92666. */
  92667. onDragStartObservable: Observable<{}>;
  92668. /**
  92669. * Fires each time a drag ends (eg. mouse release after drag)
  92670. */
  92671. onDragEndObservable: Observable<{}>;
  92672. /**
  92673. * 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
  92674. */
  92675. constructor();
  92676. /**
  92677. * The name of the behavior
  92678. */
  92679. readonly name: string;
  92680. /**
  92681. * Initializes the behavior
  92682. */
  92683. init(): void;
  92684. /**
  92685. * Attaches the scale behavior the passed in mesh
  92686. * @param ownerNode The mesh that will be scaled around once attached
  92687. */
  92688. attach(ownerNode: Mesh): void;
  92689. /**
  92690. * Detaches the behavior from the mesh
  92691. */
  92692. detach(): void;
  92693. }
  92694. }
  92695. declare module BABYLON {
  92696. /**
  92697. * Class used to apply inverse kinematics to bones
  92698. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  92699. */
  92700. export class BoneIKController {
  92701. private static _tmpVecs;
  92702. private static _tmpQuat;
  92703. private static _tmpMats;
  92704. /**
  92705. * Gets or sets the target mesh
  92706. */
  92707. targetMesh: AbstractMesh;
  92708. /** Gets or sets the mesh used as pole */
  92709. poleTargetMesh: AbstractMesh;
  92710. /**
  92711. * Gets or sets the bone used as pole
  92712. */
  92713. poleTargetBone: Nullable<Bone>;
  92714. /**
  92715. * Gets or sets the target position
  92716. */
  92717. targetPosition: Vector3;
  92718. /**
  92719. * Gets or sets the pole target position
  92720. */
  92721. poleTargetPosition: Vector3;
  92722. /**
  92723. * Gets or sets the pole target local offset
  92724. */
  92725. poleTargetLocalOffset: Vector3;
  92726. /**
  92727. * Gets or sets the pole angle
  92728. */
  92729. poleAngle: number;
  92730. /**
  92731. * Gets or sets the mesh associated with the controller
  92732. */
  92733. mesh: AbstractMesh;
  92734. /**
  92735. * 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)
  92736. */
  92737. slerpAmount: number;
  92738. private _bone1Quat;
  92739. private _bone1Mat;
  92740. private _bone2Ang;
  92741. private _bone1;
  92742. private _bone2;
  92743. private _bone1Length;
  92744. private _bone2Length;
  92745. private _maxAngle;
  92746. private _maxReach;
  92747. private _rightHandedSystem;
  92748. private _bendAxis;
  92749. private _slerping;
  92750. private _adjustRoll;
  92751. /**
  92752. * Gets or sets maximum allowed angle
  92753. */
  92754. maxAngle: number;
  92755. /**
  92756. * Creates a new BoneIKController
  92757. * @param mesh defines the mesh to control
  92758. * @param bone defines the bone to control
  92759. * @param options defines options to set up the controller
  92760. */
  92761. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  92762. targetMesh?: AbstractMesh;
  92763. poleTargetMesh?: AbstractMesh;
  92764. poleTargetBone?: Bone;
  92765. poleTargetLocalOffset?: Vector3;
  92766. poleAngle?: number;
  92767. bendAxis?: Vector3;
  92768. maxAngle?: number;
  92769. slerpAmount?: number;
  92770. });
  92771. private _setMaxAngle;
  92772. /**
  92773. * Force the controller to update the bones
  92774. */
  92775. update(): void;
  92776. }
  92777. }
  92778. declare module BABYLON {
  92779. /**
  92780. * Class used to make a bone look toward a point in space
  92781. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  92782. */
  92783. export class BoneLookController {
  92784. private static _tmpVecs;
  92785. private static _tmpQuat;
  92786. private static _tmpMats;
  92787. /**
  92788. * The target Vector3 that the bone will look at
  92789. */
  92790. target: Vector3;
  92791. /**
  92792. * The mesh that the bone is attached to
  92793. */
  92794. mesh: AbstractMesh;
  92795. /**
  92796. * The bone that will be looking to the target
  92797. */
  92798. bone: Bone;
  92799. /**
  92800. * The up axis of the coordinate system that is used when the bone is rotated
  92801. */
  92802. upAxis: Vector3;
  92803. /**
  92804. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  92805. */
  92806. upAxisSpace: Space;
  92807. /**
  92808. * Used to make an adjustment to the yaw of the bone
  92809. */
  92810. adjustYaw: number;
  92811. /**
  92812. * Used to make an adjustment to the pitch of the bone
  92813. */
  92814. adjustPitch: number;
  92815. /**
  92816. * Used to make an adjustment to the roll of the bone
  92817. */
  92818. adjustRoll: number;
  92819. /**
  92820. * 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)
  92821. */
  92822. slerpAmount: number;
  92823. private _minYaw;
  92824. private _maxYaw;
  92825. private _minPitch;
  92826. private _maxPitch;
  92827. private _minYawSin;
  92828. private _minYawCos;
  92829. private _maxYawSin;
  92830. private _maxYawCos;
  92831. private _midYawConstraint;
  92832. private _minPitchTan;
  92833. private _maxPitchTan;
  92834. private _boneQuat;
  92835. private _slerping;
  92836. private _transformYawPitch;
  92837. private _transformYawPitchInv;
  92838. private _firstFrameSkipped;
  92839. private _yawRange;
  92840. private _fowardAxis;
  92841. /**
  92842. * Gets or sets the minimum yaw angle that the bone can look to
  92843. */
  92844. minYaw: number;
  92845. /**
  92846. * Gets or sets the maximum yaw angle that the bone can look to
  92847. */
  92848. maxYaw: number;
  92849. /**
  92850. * Gets or sets the minimum pitch angle that the bone can look to
  92851. */
  92852. minPitch: number;
  92853. /**
  92854. * Gets or sets the maximum pitch angle that the bone can look to
  92855. */
  92856. maxPitch: number;
  92857. /**
  92858. * Create a BoneLookController
  92859. * @param mesh the mesh that the bone belongs to
  92860. * @param bone the bone that will be looking to the target
  92861. * @param target the target Vector3 to look at
  92862. * @param options optional settings:
  92863. * * maxYaw: the maximum angle the bone will yaw to
  92864. * * minYaw: the minimum angle the bone will yaw to
  92865. * * maxPitch: the maximum angle the bone will pitch to
  92866. * * minPitch: the minimum angle the bone will yaw to
  92867. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  92868. * * upAxis: the up axis of the coordinate system
  92869. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  92870. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  92871. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  92872. * * adjustYaw: used to make an adjustment to the yaw of the bone
  92873. * * adjustPitch: used to make an adjustment to the pitch of the bone
  92874. * * adjustRoll: used to make an adjustment to the roll of the bone
  92875. **/
  92876. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  92877. maxYaw?: number;
  92878. minYaw?: number;
  92879. maxPitch?: number;
  92880. minPitch?: number;
  92881. slerpAmount?: number;
  92882. upAxis?: Vector3;
  92883. upAxisSpace?: Space;
  92884. yawAxis?: Vector3;
  92885. pitchAxis?: Vector3;
  92886. adjustYaw?: number;
  92887. adjustPitch?: number;
  92888. adjustRoll?: number;
  92889. });
  92890. /**
  92891. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  92892. */
  92893. update(): void;
  92894. private _getAngleDiff;
  92895. private _getAngleBetween;
  92896. private _isAngleBetween;
  92897. }
  92898. }
  92899. declare module BABYLON {
  92900. /**
  92901. * Manage the gamepad inputs to control an arc rotate camera.
  92902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92903. */
  92904. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  92905. /**
  92906. * Defines the camera the input is attached to.
  92907. */
  92908. camera: ArcRotateCamera;
  92909. /**
  92910. * Defines the gamepad the input is gathering event from.
  92911. */
  92912. gamepad: Nullable<Gamepad>;
  92913. /**
  92914. * Defines the gamepad rotation sensiblity.
  92915. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92916. */
  92917. gamepadRotationSensibility: number;
  92918. /**
  92919. * Defines the gamepad move sensiblity.
  92920. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92921. */
  92922. gamepadMoveSensibility: number;
  92923. private _onGamepadConnectedObserver;
  92924. private _onGamepadDisconnectedObserver;
  92925. /**
  92926. * Attach the input controls to a specific dom element to get the input from.
  92927. * @param element Defines the element the controls should be listened from
  92928. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92929. */
  92930. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92931. /**
  92932. * Detach the current controls from the specified dom element.
  92933. * @param element Defines the element to stop listening the inputs from
  92934. */
  92935. detachControl(element: Nullable<HTMLElement>): void;
  92936. /**
  92937. * Update the current camera state depending on the inputs that have been used this frame.
  92938. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92939. */
  92940. checkInputs(): void;
  92941. /**
  92942. * Gets the class name of the current intput.
  92943. * @returns the class name
  92944. */
  92945. getClassName(): string;
  92946. /**
  92947. * Get the friendly name associated with the input class.
  92948. * @returns the input friendly name
  92949. */
  92950. getSimpleName(): string;
  92951. }
  92952. }
  92953. declare module BABYLON {
  92954. interface ArcRotateCameraInputsManager {
  92955. /**
  92956. * Add orientation input support to the input manager.
  92957. * @returns the current input manager
  92958. */
  92959. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  92960. }
  92961. /**
  92962. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  92963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92964. */
  92965. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  92966. /**
  92967. * Defines the camera the input is attached to.
  92968. */
  92969. camera: ArcRotateCamera;
  92970. /**
  92971. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  92972. */
  92973. alphaCorrection: number;
  92974. /**
  92975. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  92976. */
  92977. gammaCorrection: number;
  92978. private _alpha;
  92979. private _gamma;
  92980. private _dirty;
  92981. private _deviceOrientationHandler;
  92982. /**
  92983. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  92984. */
  92985. constructor();
  92986. /**
  92987. * Attach the input controls to a specific dom element to get the input from.
  92988. * @param element Defines the element the controls should be listened from
  92989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92990. */
  92991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92992. /** @hidden */
  92993. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  92994. /**
  92995. * Update the current camera state depending on the inputs that have been used this frame.
  92996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92997. */
  92998. checkInputs(): void;
  92999. /**
  93000. * Detach the current controls from the specified dom element.
  93001. * @param element Defines the element to stop listening the inputs from
  93002. */
  93003. detachControl(element: Nullable<HTMLElement>): void;
  93004. /**
  93005. * Gets the class name of the current intput.
  93006. * @returns the class name
  93007. */
  93008. getClassName(): string;
  93009. /**
  93010. * Get the friendly name associated with the input class.
  93011. * @returns the input friendly name
  93012. */
  93013. getSimpleName(): string;
  93014. }
  93015. }
  93016. declare module BABYLON {
  93017. /**
  93018. * Listen to mouse events to control the camera.
  93019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93020. */
  93021. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  93022. /**
  93023. * Defines the camera the input is attached to.
  93024. */
  93025. camera: FlyCamera;
  93026. /**
  93027. * Defines if touch is enabled. (Default is true.)
  93028. */
  93029. touchEnabled: boolean;
  93030. /**
  93031. * Defines the buttons associated with the input to handle camera rotation.
  93032. */
  93033. buttons: number[];
  93034. /**
  93035. * Assign buttons for Yaw control.
  93036. */
  93037. buttonsYaw: number[];
  93038. /**
  93039. * Assign buttons for Pitch control.
  93040. */
  93041. buttonsPitch: number[];
  93042. /**
  93043. * Assign buttons for Roll control.
  93044. */
  93045. buttonsRoll: number[];
  93046. /**
  93047. * Detect if any button is being pressed while mouse is moved.
  93048. * -1 = Mouse locked.
  93049. * 0 = Left button.
  93050. * 1 = Middle Button.
  93051. * 2 = Right Button.
  93052. */
  93053. activeButton: number;
  93054. /**
  93055. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  93056. * Higher values reduce its sensitivity.
  93057. */
  93058. angularSensibility: number;
  93059. private _mousemoveCallback;
  93060. private _observer;
  93061. private _rollObserver;
  93062. private previousPosition;
  93063. private noPreventDefault;
  93064. private element;
  93065. /**
  93066. * Listen to mouse events to control the camera.
  93067. * @param touchEnabled Define if touch is enabled. (Default is true.)
  93068. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93069. */
  93070. constructor(touchEnabled?: boolean);
  93071. /**
  93072. * Attach the mouse control to the HTML DOM element.
  93073. * @param element Defines the element that listens to the input events.
  93074. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  93075. */
  93076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93077. /**
  93078. * Detach the current controls from the specified dom element.
  93079. * @param element Defines the element to stop listening the inputs from
  93080. */
  93081. detachControl(element: Nullable<HTMLElement>): void;
  93082. /**
  93083. * Gets the class name of the current input.
  93084. * @returns the class name.
  93085. */
  93086. getClassName(): string;
  93087. /**
  93088. * Get the friendly name associated with the input class.
  93089. * @returns the input's friendly name.
  93090. */
  93091. getSimpleName(): string;
  93092. private _pointerInput;
  93093. private _onMouseMove;
  93094. /**
  93095. * Rotate camera by mouse offset.
  93096. */
  93097. private rotateCamera;
  93098. }
  93099. }
  93100. declare module BABYLON {
  93101. /**
  93102. * Default Inputs manager for the FlyCamera.
  93103. * It groups all the default supported inputs for ease of use.
  93104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93105. */
  93106. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  93107. /**
  93108. * Instantiates a new FlyCameraInputsManager.
  93109. * @param camera Defines the camera the inputs belong to.
  93110. */
  93111. constructor(camera: FlyCamera);
  93112. /**
  93113. * Add keyboard input support to the input manager.
  93114. * @returns the new FlyCameraKeyboardMoveInput().
  93115. */
  93116. addKeyboard(): FlyCameraInputsManager;
  93117. /**
  93118. * Add mouse input support to the input manager.
  93119. * @param touchEnabled Enable touch screen support.
  93120. * @returns the new FlyCameraMouseInput().
  93121. */
  93122. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  93123. }
  93124. }
  93125. declare module BABYLON {
  93126. /**
  93127. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93128. * such as in a 3D Space Shooter or a Flight Simulator.
  93129. */
  93130. export class FlyCamera extends TargetCamera {
  93131. /**
  93132. * Define the collision ellipsoid of the camera.
  93133. * This is helpful for simulating a camera body, like a player's body.
  93134. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93135. */
  93136. ellipsoid: Vector3;
  93137. /**
  93138. * Define an offset for the position of the ellipsoid around the camera.
  93139. * This can be helpful if the camera is attached away from the player's body center,
  93140. * such as at its head.
  93141. */
  93142. ellipsoidOffset: Vector3;
  93143. /**
  93144. * Enable or disable collisions of the camera with the rest of the scene objects.
  93145. */
  93146. checkCollisions: boolean;
  93147. /**
  93148. * Enable or disable gravity on the camera.
  93149. */
  93150. applyGravity: boolean;
  93151. /**
  93152. * Define the current direction the camera is moving to.
  93153. */
  93154. cameraDirection: Vector3;
  93155. /**
  93156. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  93157. * This overrides and empties cameraRotation.
  93158. */
  93159. rotationQuaternion: Quaternion;
  93160. /**
  93161. * Track Roll to maintain the wanted Rolling when looking around.
  93162. */
  93163. _trackRoll: number;
  93164. /**
  93165. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  93166. */
  93167. rollCorrect: number;
  93168. /**
  93169. * Mimic a banked turn, Rolling the camera when Yawing.
  93170. * It's recommended to use rollCorrect = 10 for faster banking correction.
  93171. */
  93172. bankedTurn: boolean;
  93173. /**
  93174. * Limit in radians for how much Roll banking will add. (Default: 90°)
  93175. */
  93176. bankedTurnLimit: number;
  93177. /**
  93178. * Value of 0 disables the banked Roll.
  93179. * Value of 1 is equal to the Yaw angle in radians.
  93180. */
  93181. bankedTurnMultiplier: number;
  93182. /**
  93183. * The inputs manager loads all the input sources, such as keyboard and mouse.
  93184. */
  93185. inputs: FlyCameraInputsManager;
  93186. /**
  93187. * Gets the input sensibility for mouse input.
  93188. * Higher values reduce sensitivity.
  93189. */
  93190. /**
  93191. * Sets the input sensibility for a mouse input.
  93192. * Higher values reduce sensitivity.
  93193. */
  93194. angularSensibility: number;
  93195. /**
  93196. * Get the keys for camera movement forward.
  93197. */
  93198. /**
  93199. * Set the keys for camera movement forward.
  93200. */
  93201. keysForward: number[];
  93202. /**
  93203. * Get the keys for camera movement backward.
  93204. */
  93205. keysBackward: number[];
  93206. /**
  93207. * Get the keys for camera movement up.
  93208. */
  93209. /**
  93210. * Set the keys for camera movement up.
  93211. */
  93212. keysUp: number[];
  93213. /**
  93214. * Get the keys for camera movement down.
  93215. */
  93216. /**
  93217. * Set the keys for camera movement down.
  93218. */
  93219. keysDown: number[];
  93220. /**
  93221. * Get the keys for camera movement left.
  93222. */
  93223. /**
  93224. * Set the keys for camera movement left.
  93225. */
  93226. keysLeft: number[];
  93227. /**
  93228. * Set the keys for camera movement right.
  93229. */
  93230. /**
  93231. * Set the keys for camera movement right.
  93232. */
  93233. keysRight: number[];
  93234. /**
  93235. * Event raised when the camera collides with a mesh in the scene.
  93236. */
  93237. onCollide: (collidedMesh: AbstractMesh) => void;
  93238. private _collider;
  93239. private _needMoveForGravity;
  93240. private _oldPosition;
  93241. private _diffPosition;
  93242. private _newPosition;
  93243. /** @hidden */
  93244. _localDirection: Vector3;
  93245. /** @hidden */
  93246. _transformedDirection: Vector3;
  93247. /**
  93248. * Instantiates a FlyCamera.
  93249. * This is a flying camera, designed for 3D movement and rotation in all directions,
  93250. * such as in a 3D Space Shooter or a Flight Simulator.
  93251. * @param name Define the name of the camera in the scene.
  93252. * @param position Define the starting position of the camera in the scene.
  93253. * @param scene Define the scene the camera belongs to.
  93254. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  93255. */
  93256. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93257. /**
  93258. * Attach a control to the HTML DOM element.
  93259. * @param element Defines the element that listens to the input events.
  93260. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  93261. */
  93262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93263. /**
  93264. * Detach a control from the HTML DOM element.
  93265. * The camera will stop reacting to that input.
  93266. * @param element Defines the element that listens to the input events.
  93267. */
  93268. detachControl(element: HTMLElement): void;
  93269. private _collisionMask;
  93270. /**
  93271. * Get the mask that the camera ignores in collision events.
  93272. */
  93273. /**
  93274. * Set the mask that the camera ignores in collision events.
  93275. */
  93276. collisionMask: number;
  93277. /** @hidden */
  93278. _collideWithWorld(displacement: Vector3): void;
  93279. /** @hidden */
  93280. private _onCollisionPositionChange;
  93281. /** @hidden */
  93282. _checkInputs(): void;
  93283. /** @hidden */
  93284. _decideIfNeedsToMove(): boolean;
  93285. /** @hidden */
  93286. _updatePosition(): void;
  93287. /**
  93288. * Restore the Roll to its target value at the rate specified.
  93289. * @param rate - Higher means slower restoring.
  93290. * @hidden
  93291. */
  93292. restoreRoll(rate: number): void;
  93293. /**
  93294. * Destroy the camera and release the current resources held by it.
  93295. */
  93296. dispose(): void;
  93297. /**
  93298. * Get the current object class name.
  93299. * @returns the class name.
  93300. */
  93301. getClassName(): string;
  93302. }
  93303. }
  93304. declare module BABYLON {
  93305. /**
  93306. * Listen to keyboard events to control the camera.
  93307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93308. */
  93309. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  93310. /**
  93311. * Defines the camera the input is attached to.
  93312. */
  93313. camera: FlyCamera;
  93314. /**
  93315. * The list of keyboard keys used to control the forward move of the camera.
  93316. */
  93317. keysForward: number[];
  93318. /**
  93319. * The list of keyboard keys used to control the backward move of the camera.
  93320. */
  93321. keysBackward: number[];
  93322. /**
  93323. * The list of keyboard keys used to control the forward move of the camera.
  93324. */
  93325. keysUp: number[];
  93326. /**
  93327. * The list of keyboard keys used to control the backward move of the camera.
  93328. */
  93329. keysDown: number[];
  93330. /**
  93331. * The list of keyboard keys used to control the right strafe move of the camera.
  93332. */
  93333. keysRight: number[];
  93334. /**
  93335. * The list of keyboard keys used to control the left strafe move of the camera.
  93336. */
  93337. keysLeft: number[];
  93338. private _keys;
  93339. private _onCanvasBlurObserver;
  93340. private _onKeyboardObserver;
  93341. private _engine;
  93342. private _scene;
  93343. /**
  93344. * Attach the input controls to a specific dom element to get the input from.
  93345. * @param element Defines the element the controls should be listened from
  93346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93347. */
  93348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93349. /**
  93350. * Detach the current controls from the specified dom element.
  93351. * @param element Defines the element to stop listening the inputs from
  93352. */
  93353. detachControl(element: Nullable<HTMLElement>): void;
  93354. /**
  93355. * Gets the class name of the current intput.
  93356. * @returns the class name
  93357. */
  93358. getClassName(): string;
  93359. /** @hidden */
  93360. _onLostFocus(e: FocusEvent): void;
  93361. /**
  93362. * Get the friendly name associated with the input class.
  93363. * @returns the input friendly name
  93364. */
  93365. getSimpleName(): string;
  93366. /**
  93367. * Update the current camera state depending on the inputs that have been used this frame.
  93368. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93369. */
  93370. checkInputs(): void;
  93371. }
  93372. }
  93373. declare module BABYLON {
  93374. /**
  93375. * Manage the mouse wheel inputs to control a follow camera.
  93376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93377. */
  93378. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  93379. /**
  93380. * Defines the camera the input is attached to.
  93381. */
  93382. camera: FollowCamera;
  93383. /**
  93384. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  93385. */
  93386. axisControlRadius: boolean;
  93387. /**
  93388. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  93389. */
  93390. axisControlHeight: boolean;
  93391. /**
  93392. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  93393. */
  93394. axisControlRotation: boolean;
  93395. /**
  93396. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  93397. * relation to mouseWheel events.
  93398. */
  93399. wheelPrecision: number;
  93400. /**
  93401. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93402. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93403. */
  93404. wheelDeltaPercentage: number;
  93405. private _wheel;
  93406. private _observer;
  93407. /**
  93408. * Attach the input controls to a specific dom element to get the input from.
  93409. * @param element Defines the element the controls should be listened from
  93410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93411. */
  93412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93413. /**
  93414. * Detach the current controls from the specified dom element.
  93415. * @param element Defines the element to stop listening the inputs from
  93416. */
  93417. detachControl(element: Nullable<HTMLElement>): void;
  93418. /**
  93419. * Gets the class name of the current intput.
  93420. * @returns the class name
  93421. */
  93422. getClassName(): string;
  93423. /**
  93424. * Get the friendly name associated with the input class.
  93425. * @returns the input friendly name
  93426. */
  93427. getSimpleName(): string;
  93428. }
  93429. }
  93430. declare module BABYLON {
  93431. /**
  93432. * Manage the pointers inputs to control an follow camera.
  93433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93434. */
  93435. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  93436. /**
  93437. * Defines the camera the input is attached to.
  93438. */
  93439. camera: FollowCamera;
  93440. /**
  93441. * Gets the class name of the current input.
  93442. * @returns the class name
  93443. */
  93444. getClassName(): string;
  93445. /**
  93446. * Defines the pointer angular sensibility along the X axis or how fast is
  93447. * the camera rotating.
  93448. * A negative number will reverse the axis direction.
  93449. */
  93450. angularSensibilityX: number;
  93451. /**
  93452. * Defines the pointer angular sensibility along the Y axis or how fast is
  93453. * the camera rotating.
  93454. * A negative number will reverse the axis direction.
  93455. */
  93456. angularSensibilityY: number;
  93457. /**
  93458. * Defines the pointer pinch precision or how fast is the camera zooming.
  93459. * A negative number will reverse the axis direction.
  93460. */
  93461. pinchPrecision: number;
  93462. /**
  93463. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  93464. * from 0.
  93465. * It defines the percentage of current camera.radius to use as delta when
  93466. * pinch zoom is used.
  93467. */
  93468. pinchDeltaPercentage: number;
  93469. /**
  93470. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  93471. */
  93472. axisXControlRadius: boolean;
  93473. /**
  93474. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  93475. */
  93476. axisXControlHeight: boolean;
  93477. /**
  93478. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  93479. */
  93480. axisXControlRotation: boolean;
  93481. /**
  93482. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  93483. */
  93484. axisYControlRadius: boolean;
  93485. /**
  93486. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  93487. */
  93488. axisYControlHeight: boolean;
  93489. /**
  93490. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  93491. */
  93492. axisYControlRotation: boolean;
  93493. /**
  93494. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  93495. */
  93496. axisPinchControlRadius: boolean;
  93497. /**
  93498. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  93499. */
  93500. axisPinchControlHeight: boolean;
  93501. /**
  93502. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  93503. */
  93504. axisPinchControlRotation: boolean;
  93505. /**
  93506. * Log error messages if basic misconfiguration has occurred.
  93507. */
  93508. warningEnable: boolean;
  93509. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  93510. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93511. private _warningCounter;
  93512. private _warning;
  93513. }
  93514. }
  93515. declare module BABYLON {
  93516. /**
  93517. * Default Inputs manager for the FollowCamera.
  93518. * It groups all the default supported inputs for ease of use.
  93519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93520. */
  93521. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  93522. /**
  93523. * Instantiates a new FollowCameraInputsManager.
  93524. * @param camera Defines the camera the inputs belong to
  93525. */
  93526. constructor(camera: FollowCamera);
  93527. /**
  93528. * Add keyboard input support to the input manager.
  93529. * @returns the current input manager
  93530. */
  93531. addKeyboard(): FollowCameraInputsManager;
  93532. /**
  93533. * Add mouse wheel input support to the input manager.
  93534. * @returns the current input manager
  93535. */
  93536. addMouseWheel(): FollowCameraInputsManager;
  93537. /**
  93538. * Add pointers input support to the input manager.
  93539. * @returns the current input manager
  93540. */
  93541. addPointers(): FollowCameraInputsManager;
  93542. /**
  93543. * Add orientation input support to the input manager.
  93544. * @returns the current input manager
  93545. */
  93546. addVRDeviceOrientation(): FollowCameraInputsManager;
  93547. }
  93548. }
  93549. declare module BABYLON {
  93550. /**
  93551. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  93552. * an arc rotate version arcFollowCamera are available.
  93553. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93554. */
  93555. export class FollowCamera extends TargetCamera {
  93556. /**
  93557. * Distance the follow camera should follow an object at
  93558. */
  93559. radius: number;
  93560. /**
  93561. * Minimum allowed distance of the camera to the axis of rotation
  93562. * (The camera can not get closer).
  93563. * This can help limiting how the Camera is able to move in the scene.
  93564. */
  93565. lowerRadiusLimit: Nullable<number>;
  93566. /**
  93567. * Maximum allowed distance of the camera to the axis of rotation
  93568. * (The camera can not get further).
  93569. * This can help limiting how the Camera is able to move in the scene.
  93570. */
  93571. upperRadiusLimit: Nullable<number>;
  93572. /**
  93573. * Define a rotation offset between the camera and the object it follows
  93574. */
  93575. rotationOffset: number;
  93576. /**
  93577. * Minimum allowed angle to camera position relative to target object.
  93578. * This can help limiting how the Camera is able to move in the scene.
  93579. */
  93580. lowerRotationOffsetLimit: Nullable<number>;
  93581. /**
  93582. * Maximum allowed angle to camera position relative to target object.
  93583. * This can help limiting how the Camera is able to move in the scene.
  93584. */
  93585. upperRotationOffsetLimit: Nullable<number>;
  93586. /**
  93587. * Define a height offset between the camera and the object it follows.
  93588. * It can help following an object from the top (like a car chaing a plane)
  93589. */
  93590. heightOffset: number;
  93591. /**
  93592. * Minimum allowed height of camera position relative to target object.
  93593. * This can help limiting how the Camera is able to move in the scene.
  93594. */
  93595. lowerHeightOffsetLimit: Nullable<number>;
  93596. /**
  93597. * Maximum allowed height of camera position relative to target object.
  93598. * This can help limiting how the Camera is able to move in the scene.
  93599. */
  93600. upperHeightOffsetLimit: Nullable<number>;
  93601. /**
  93602. * Define how fast the camera can accelerate to follow it s target.
  93603. */
  93604. cameraAcceleration: number;
  93605. /**
  93606. * Define the speed limit of the camera following an object.
  93607. */
  93608. maxCameraSpeed: number;
  93609. /**
  93610. * Define the target of the camera.
  93611. */
  93612. lockedTarget: Nullable<AbstractMesh>;
  93613. /**
  93614. * Defines the input associated with the camera.
  93615. */
  93616. inputs: FollowCameraInputsManager;
  93617. /**
  93618. * Instantiates the follow camera.
  93619. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93620. * @param name Define the name of the camera in the scene
  93621. * @param position Define the position of the camera
  93622. * @param scene Define the scene the camera belong to
  93623. * @param lockedTarget Define the target of the camera
  93624. */
  93625. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  93626. private _follow;
  93627. /**
  93628. * Attached controls to the current camera.
  93629. * @param element Defines the element the controls should be listened from
  93630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93631. */
  93632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93633. /**
  93634. * Detach the current controls from the camera.
  93635. * The camera will stop reacting to inputs.
  93636. * @param element Defines the element to stop listening the inputs from
  93637. */
  93638. detachControl(element: HTMLElement): void;
  93639. /** @hidden */
  93640. _checkInputs(): void;
  93641. private _checkLimits;
  93642. /**
  93643. * Gets the camera class name.
  93644. * @returns the class name
  93645. */
  93646. getClassName(): string;
  93647. }
  93648. /**
  93649. * Arc Rotate version of the follow camera.
  93650. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  93651. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93652. */
  93653. export class ArcFollowCamera extends TargetCamera {
  93654. /** The longitudinal angle of the camera */
  93655. alpha: number;
  93656. /** The latitudinal angle of the camera */
  93657. beta: number;
  93658. /** The radius of the camera from its target */
  93659. radius: number;
  93660. /** Define the camera target (the messh it should follow) */
  93661. target: Nullable<AbstractMesh>;
  93662. private _cartesianCoordinates;
  93663. /**
  93664. * Instantiates a new ArcFollowCamera
  93665. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  93666. * @param name Define the name of the camera
  93667. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  93668. * @param beta Define the rotation angle of the camera around the elevation axis
  93669. * @param radius Define the radius of the camera from its target point
  93670. * @param target Define the target of the camera
  93671. * @param scene Define the scene the camera belongs to
  93672. */
  93673. constructor(name: string,
  93674. /** The longitudinal angle of the camera */
  93675. alpha: number,
  93676. /** The latitudinal angle of the camera */
  93677. beta: number,
  93678. /** The radius of the camera from its target */
  93679. radius: number,
  93680. /** Define the camera target (the messh it should follow) */
  93681. target: Nullable<AbstractMesh>, scene: Scene);
  93682. private _follow;
  93683. /** @hidden */
  93684. _checkInputs(): void;
  93685. /**
  93686. * Returns the class name of the object.
  93687. * It is mostly used internally for serialization purposes.
  93688. */
  93689. getClassName(): string;
  93690. }
  93691. }
  93692. declare module BABYLON {
  93693. /**
  93694. * Manage the keyboard inputs to control the movement of a follow camera.
  93695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93696. */
  93697. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  93698. /**
  93699. * Defines the camera the input is attached to.
  93700. */
  93701. camera: FollowCamera;
  93702. /**
  93703. * Defines the list of key codes associated with the up action (increase heightOffset)
  93704. */
  93705. keysHeightOffsetIncr: number[];
  93706. /**
  93707. * Defines the list of key codes associated with the down action (decrease heightOffset)
  93708. */
  93709. keysHeightOffsetDecr: number[];
  93710. /**
  93711. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  93712. */
  93713. keysHeightOffsetModifierAlt: boolean;
  93714. /**
  93715. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  93716. */
  93717. keysHeightOffsetModifierCtrl: boolean;
  93718. /**
  93719. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  93720. */
  93721. keysHeightOffsetModifierShift: boolean;
  93722. /**
  93723. * Defines the list of key codes associated with the left action (increase rotationOffset)
  93724. */
  93725. keysRotationOffsetIncr: number[];
  93726. /**
  93727. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  93728. */
  93729. keysRotationOffsetDecr: number[];
  93730. /**
  93731. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  93732. */
  93733. keysRotationOffsetModifierAlt: boolean;
  93734. /**
  93735. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  93736. */
  93737. keysRotationOffsetModifierCtrl: boolean;
  93738. /**
  93739. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  93740. */
  93741. keysRotationOffsetModifierShift: boolean;
  93742. /**
  93743. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  93744. */
  93745. keysRadiusIncr: number[];
  93746. /**
  93747. * Defines the list of key codes associated with the zoom-out action (increase radius)
  93748. */
  93749. keysRadiusDecr: number[];
  93750. /**
  93751. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  93752. */
  93753. keysRadiusModifierAlt: boolean;
  93754. /**
  93755. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  93756. */
  93757. keysRadiusModifierCtrl: boolean;
  93758. /**
  93759. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  93760. */
  93761. keysRadiusModifierShift: boolean;
  93762. /**
  93763. * Defines the rate of change of heightOffset.
  93764. */
  93765. heightSensibility: number;
  93766. /**
  93767. * Defines the rate of change of rotationOffset.
  93768. */
  93769. rotationSensibility: number;
  93770. /**
  93771. * Defines the rate of change of radius.
  93772. */
  93773. radiusSensibility: number;
  93774. private _keys;
  93775. private _ctrlPressed;
  93776. private _altPressed;
  93777. private _shiftPressed;
  93778. private _onCanvasBlurObserver;
  93779. private _onKeyboardObserver;
  93780. private _engine;
  93781. private _scene;
  93782. /**
  93783. * Attach the input controls to a specific dom element to get the input from.
  93784. * @param element Defines the element the controls should be listened from
  93785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93786. */
  93787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93788. /**
  93789. * Detach the current controls from the specified dom element.
  93790. * @param element Defines the element to stop listening the inputs from
  93791. */
  93792. detachControl(element: Nullable<HTMLElement>): void;
  93793. /**
  93794. * Update the current camera state depending on the inputs that have been used this frame.
  93795. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93796. */
  93797. checkInputs(): void;
  93798. /**
  93799. * Gets the class name of the current input.
  93800. * @returns the class name
  93801. */
  93802. getClassName(): string;
  93803. /**
  93804. * Get the friendly name associated with the input class.
  93805. * @returns the input friendly name
  93806. */
  93807. getSimpleName(): string;
  93808. /**
  93809. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93810. * allow modification of the heightOffset value.
  93811. */
  93812. private _modifierHeightOffset;
  93813. /**
  93814. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93815. * allow modification of the rotationOffset value.
  93816. */
  93817. private _modifierRotationOffset;
  93818. /**
  93819. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  93820. * allow modification of the radius value.
  93821. */
  93822. private _modifierRadius;
  93823. }
  93824. }
  93825. declare module BABYLON {
  93826. interface FreeCameraInputsManager {
  93827. /**
  93828. * Add orientation input support to the input manager.
  93829. * @returns the current input manager
  93830. */
  93831. addDeviceOrientation(): FreeCameraInputsManager;
  93832. }
  93833. /**
  93834. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  93835. * Screen rotation is taken into account.
  93836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93837. */
  93838. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  93839. private _camera;
  93840. private _screenOrientationAngle;
  93841. private _constantTranform;
  93842. private _screenQuaternion;
  93843. private _alpha;
  93844. private _beta;
  93845. private _gamma;
  93846. /**
  93847. * Instantiates a new input
  93848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93849. */
  93850. constructor();
  93851. /**
  93852. * Define the camera controlled by the input.
  93853. */
  93854. camera: FreeCamera;
  93855. /**
  93856. * Attach the input controls to a specific dom element to get the input from.
  93857. * @param element Defines the element the controls should be listened from
  93858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93859. */
  93860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93861. private _orientationChanged;
  93862. private _deviceOrientation;
  93863. /**
  93864. * Detach the current controls from the specified dom element.
  93865. * @param element Defines the element to stop listening the inputs from
  93866. */
  93867. detachControl(element: Nullable<HTMLElement>): void;
  93868. /**
  93869. * Update the current camera state depending on the inputs that have been used this frame.
  93870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93871. */
  93872. checkInputs(): void;
  93873. /**
  93874. * Gets the class name of the current intput.
  93875. * @returns the class name
  93876. */
  93877. getClassName(): string;
  93878. /**
  93879. * Get the friendly name associated with the input class.
  93880. * @returns the input friendly name
  93881. */
  93882. getSimpleName(): string;
  93883. }
  93884. }
  93885. declare module BABYLON {
  93886. /**
  93887. * Manage the gamepad inputs to control a free camera.
  93888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93889. */
  93890. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  93891. /**
  93892. * Define the camera the input is attached to.
  93893. */
  93894. camera: FreeCamera;
  93895. /**
  93896. * Define the Gamepad controlling the input
  93897. */
  93898. gamepad: Nullable<Gamepad>;
  93899. /**
  93900. * Defines the gamepad rotation sensiblity.
  93901. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  93902. */
  93903. gamepadAngularSensibility: number;
  93904. /**
  93905. * Defines the gamepad move sensiblity.
  93906. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  93907. */
  93908. gamepadMoveSensibility: number;
  93909. private _onGamepadConnectedObserver;
  93910. private _onGamepadDisconnectedObserver;
  93911. private _cameraTransform;
  93912. private _deltaTransform;
  93913. private _vector3;
  93914. private _vector2;
  93915. /**
  93916. * Attach the input controls to a specific dom element to get the input from.
  93917. * @param element Defines the element the controls should be listened from
  93918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93919. */
  93920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93921. /**
  93922. * Detach the current controls from the specified dom element.
  93923. * @param element Defines the element to stop listening the inputs from
  93924. */
  93925. detachControl(element: Nullable<HTMLElement>): void;
  93926. /**
  93927. * Update the current camera state depending on the inputs that have been used this frame.
  93928. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93929. */
  93930. checkInputs(): void;
  93931. /**
  93932. * Gets the class name of the current intput.
  93933. * @returns the class name
  93934. */
  93935. getClassName(): string;
  93936. /**
  93937. * Get the friendly name associated with the input class.
  93938. * @returns the input friendly name
  93939. */
  93940. getSimpleName(): string;
  93941. }
  93942. }
  93943. declare module BABYLON {
  93944. /**
  93945. * Defines the potential axis of a Joystick
  93946. */
  93947. export enum JoystickAxis {
  93948. /** X axis */
  93949. X = 0,
  93950. /** Y axis */
  93951. Y = 1,
  93952. /** Z axis */
  93953. Z = 2
  93954. }
  93955. /**
  93956. * Class used to define virtual joystick (used in touch mode)
  93957. */
  93958. export class VirtualJoystick {
  93959. /**
  93960. * Gets or sets a boolean indicating that left and right values must be inverted
  93961. */
  93962. reverseLeftRight: boolean;
  93963. /**
  93964. * Gets or sets a boolean indicating that up and down values must be inverted
  93965. */
  93966. reverseUpDown: boolean;
  93967. /**
  93968. * Gets the offset value for the position (ie. the change of the position value)
  93969. */
  93970. deltaPosition: Vector3;
  93971. /**
  93972. * Gets a boolean indicating if the virtual joystick was pressed
  93973. */
  93974. pressed: boolean;
  93975. /**
  93976. * Canvas the virtual joystick will render onto, default z-index of this is 5
  93977. */
  93978. static Canvas: Nullable<HTMLCanvasElement>;
  93979. private static _globalJoystickIndex;
  93980. private static vjCanvasContext;
  93981. private static vjCanvasWidth;
  93982. private static vjCanvasHeight;
  93983. private static halfWidth;
  93984. private _action;
  93985. private _axisTargetedByLeftAndRight;
  93986. private _axisTargetedByUpAndDown;
  93987. private _joystickSensibility;
  93988. private _inversedSensibility;
  93989. private _joystickPointerID;
  93990. private _joystickColor;
  93991. private _joystickPointerPos;
  93992. private _joystickPreviousPointerPos;
  93993. private _joystickPointerStartPos;
  93994. private _deltaJoystickVector;
  93995. private _leftJoystick;
  93996. private _touches;
  93997. private _onPointerDownHandlerRef;
  93998. private _onPointerMoveHandlerRef;
  93999. private _onPointerUpHandlerRef;
  94000. private _onResize;
  94001. /**
  94002. * Creates a new virtual joystick
  94003. * @param leftJoystick defines that the joystick is for left hand (false by default)
  94004. */
  94005. constructor(leftJoystick?: boolean);
  94006. /**
  94007. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  94008. * @param newJoystickSensibility defines the new sensibility
  94009. */
  94010. setJoystickSensibility(newJoystickSensibility: number): void;
  94011. private _onPointerDown;
  94012. private _onPointerMove;
  94013. private _onPointerUp;
  94014. /**
  94015. * Change the color of the virtual joystick
  94016. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  94017. */
  94018. setJoystickColor(newColor: string): void;
  94019. /**
  94020. * Defines a callback to call when the joystick is touched
  94021. * @param action defines the callback
  94022. */
  94023. setActionOnTouch(action: () => any): void;
  94024. /**
  94025. * Defines which axis you'd like to control for left & right
  94026. * @param axis defines the axis to use
  94027. */
  94028. setAxisForLeftRight(axis: JoystickAxis): void;
  94029. /**
  94030. * Defines which axis you'd like to control for up & down
  94031. * @param axis defines the axis to use
  94032. */
  94033. setAxisForUpDown(axis: JoystickAxis): void;
  94034. private _drawVirtualJoystick;
  94035. /**
  94036. * Release internal HTML canvas
  94037. */
  94038. releaseCanvas(): void;
  94039. }
  94040. }
  94041. declare module BABYLON {
  94042. interface FreeCameraInputsManager {
  94043. /**
  94044. * Add virtual joystick input support to the input manager.
  94045. * @returns the current input manager
  94046. */
  94047. addVirtualJoystick(): FreeCameraInputsManager;
  94048. }
  94049. /**
  94050. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  94051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94052. */
  94053. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  94054. /**
  94055. * Defines the camera the input is attached to.
  94056. */
  94057. camera: FreeCamera;
  94058. private _leftjoystick;
  94059. private _rightjoystick;
  94060. /**
  94061. * Gets the left stick of the virtual joystick.
  94062. * @returns The virtual Joystick
  94063. */
  94064. getLeftJoystick(): VirtualJoystick;
  94065. /**
  94066. * Gets the right stick of the virtual joystick.
  94067. * @returns The virtual Joystick
  94068. */
  94069. getRightJoystick(): VirtualJoystick;
  94070. /**
  94071. * Update the current camera state depending on the inputs that have been used this frame.
  94072. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94073. */
  94074. checkInputs(): void;
  94075. /**
  94076. * Attach the input controls to a specific dom element to get the input from.
  94077. * @param element Defines the element the controls should be listened from
  94078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94079. */
  94080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94081. /**
  94082. * Detach the current controls from the specified dom element.
  94083. * @param element Defines the element to stop listening the inputs from
  94084. */
  94085. detachControl(element: Nullable<HTMLElement>): void;
  94086. /**
  94087. * Gets the class name of the current intput.
  94088. * @returns the class name
  94089. */
  94090. getClassName(): string;
  94091. /**
  94092. * Get the friendly name associated with the input class.
  94093. * @returns the input friendly name
  94094. */
  94095. getSimpleName(): string;
  94096. }
  94097. }
  94098. declare module BABYLON {
  94099. /**
  94100. * This represents a FPS type of camera controlled by touch.
  94101. * This is like a universal camera minus the Gamepad controls.
  94102. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94103. */
  94104. export class TouchCamera extends FreeCamera {
  94105. /**
  94106. * Defines the touch sensibility for rotation.
  94107. * The higher the faster.
  94108. */
  94109. touchAngularSensibility: number;
  94110. /**
  94111. * Defines the touch sensibility for move.
  94112. * The higher the faster.
  94113. */
  94114. touchMoveSensibility: number;
  94115. /**
  94116. * Instantiates a new touch camera.
  94117. * This represents a FPS type of camera controlled by touch.
  94118. * This is like a universal camera minus the Gamepad controls.
  94119. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94120. * @param name Define the name of the camera in the scene
  94121. * @param position Define the start position of the camera in the scene
  94122. * @param scene Define the scene the camera belongs to
  94123. */
  94124. constructor(name: string, position: Vector3, scene: Scene);
  94125. /**
  94126. * Gets the current object class name.
  94127. * @return the class name
  94128. */
  94129. getClassName(): string;
  94130. /** @hidden */
  94131. _setupInputs(): void;
  94132. }
  94133. }
  94134. declare module BABYLON {
  94135. /**
  94136. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  94137. * being tilted forward or back and left or right.
  94138. */
  94139. export class DeviceOrientationCamera extends FreeCamera {
  94140. private _initialQuaternion;
  94141. private _quaternionCache;
  94142. /**
  94143. * Creates a new device orientation camera
  94144. * @param name The name of the camera
  94145. * @param position The start position camera
  94146. * @param scene The scene the camera belongs to
  94147. */
  94148. constructor(name: string, position: Vector3, scene: Scene);
  94149. /**
  94150. * Gets the current instance class name ("DeviceOrientationCamera").
  94151. * This helps avoiding instanceof at run time.
  94152. * @returns the class name
  94153. */
  94154. getClassName(): string;
  94155. /**
  94156. * @hidden
  94157. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  94158. */
  94159. _checkInputs(): void;
  94160. /**
  94161. * Reset the camera to its default orientation on the specified axis only.
  94162. * @param axis The axis to reset
  94163. */
  94164. resetToCurrentRotation(axis?: Axis): void;
  94165. }
  94166. }
  94167. declare module BABYLON {
  94168. /**
  94169. * 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,
  94170. * which still works and will still be found in many Playgrounds.
  94171. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94172. */
  94173. export class UniversalCamera extends TouchCamera {
  94174. /**
  94175. * Defines the gamepad rotation sensiblity.
  94176. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94177. */
  94178. gamepadAngularSensibility: number;
  94179. /**
  94180. * Defines the gamepad move sensiblity.
  94181. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94182. */
  94183. gamepadMoveSensibility: number;
  94184. /**
  94185. * 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,
  94186. * which still works and will still be found in many Playgrounds.
  94187. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94188. * @param name Define the name of the camera in the scene
  94189. * @param position Define the start position of the camera in the scene
  94190. * @param scene Define the scene the camera belongs to
  94191. */
  94192. constructor(name: string, position: Vector3, scene: Scene);
  94193. /**
  94194. * Gets the current object class name.
  94195. * @return the class name
  94196. */
  94197. getClassName(): string;
  94198. }
  94199. }
  94200. declare module BABYLON {
  94201. /**
  94202. * This represents a FPS type of camera. This is only here for back compat purpose.
  94203. * Please use the UniversalCamera instead as both are identical.
  94204. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94205. */
  94206. export class GamepadCamera extends UniversalCamera {
  94207. /**
  94208. * Instantiates a new Gamepad Camera
  94209. * This represents a FPS type of camera. This is only here for back compat purpose.
  94210. * Please use the UniversalCamera instead as both are identical.
  94211. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  94212. * @param name Define the name of the camera in the scene
  94213. * @param position Define the start position of the camera in the scene
  94214. * @param scene Define the scene the camera belongs to
  94215. */
  94216. constructor(name: string, position: Vector3, scene: Scene);
  94217. /**
  94218. * Gets the current object class name.
  94219. * @return the class name
  94220. */
  94221. getClassName(): string;
  94222. }
  94223. }
  94224. declare module BABYLON {
  94225. /** @hidden */
  94226. export var passPixelShader: {
  94227. name: string;
  94228. shader: string;
  94229. };
  94230. }
  94231. declare module BABYLON {
  94232. /** @hidden */
  94233. export var passCubePixelShader: {
  94234. name: string;
  94235. shader: string;
  94236. };
  94237. }
  94238. declare module BABYLON {
  94239. /**
  94240. * PassPostProcess which produces an output the same as it's input
  94241. */
  94242. export class PassPostProcess extends PostProcess {
  94243. /**
  94244. * Creates the PassPostProcess
  94245. * @param name The name of the effect.
  94246. * @param options The required width/height ratio to downsize to before computing the render pass.
  94247. * @param camera The camera to apply the render pass to.
  94248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94249. * @param engine The engine which the post process will be applied. (default: current engine)
  94250. * @param reusable If the post process can be reused on the same frame. (default: false)
  94251. * @param textureType The type of texture to be used when performing the post processing.
  94252. * @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)
  94253. */
  94254. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94255. }
  94256. /**
  94257. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  94258. */
  94259. export class PassCubePostProcess extends PostProcess {
  94260. private _face;
  94261. /**
  94262. * Gets or sets the cube face to display.
  94263. * * 0 is +X
  94264. * * 1 is -X
  94265. * * 2 is +Y
  94266. * * 3 is -Y
  94267. * * 4 is +Z
  94268. * * 5 is -Z
  94269. */
  94270. face: number;
  94271. /**
  94272. * Creates the PassCubePostProcess
  94273. * @param name The name of the effect.
  94274. * @param options The required width/height ratio to downsize to before computing the render pass.
  94275. * @param camera The camera to apply the render pass to.
  94276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94277. * @param engine The engine which the post process will be applied. (default: current engine)
  94278. * @param reusable If the post process can be reused on the same frame. (default: false)
  94279. * @param textureType The type of texture to be used when performing the post processing.
  94280. * @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)
  94281. */
  94282. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  94283. }
  94284. }
  94285. declare module BABYLON {
  94286. /** @hidden */
  94287. export var anaglyphPixelShader: {
  94288. name: string;
  94289. shader: string;
  94290. };
  94291. }
  94292. declare module BABYLON {
  94293. /**
  94294. * Postprocess used to generate anaglyphic rendering
  94295. */
  94296. export class AnaglyphPostProcess extends PostProcess {
  94297. private _passedProcess;
  94298. /**
  94299. * Creates a new AnaglyphPostProcess
  94300. * @param name defines postprocess name
  94301. * @param options defines creation options or target ratio scale
  94302. * @param rigCameras defines cameras using this postprocess
  94303. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  94304. * @param engine defines hosting engine
  94305. * @param reusable defines if the postprocess will be reused multiple times per frame
  94306. */
  94307. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  94308. }
  94309. }
  94310. declare module BABYLON {
  94311. /**
  94312. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  94313. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94314. */
  94315. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  94316. /**
  94317. * Creates a new AnaglyphArcRotateCamera
  94318. * @param name defines camera name
  94319. * @param alpha defines alpha angle (in radians)
  94320. * @param beta defines beta angle (in radians)
  94321. * @param radius defines radius
  94322. * @param target defines camera target
  94323. * @param interaxialDistance defines distance between each color axis
  94324. * @param scene defines the hosting scene
  94325. */
  94326. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  94327. /**
  94328. * Gets camera class name
  94329. * @returns AnaglyphArcRotateCamera
  94330. */
  94331. getClassName(): string;
  94332. }
  94333. }
  94334. declare module BABYLON {
  94335. /**
  94336. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  94337. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94338. */
  94339. export class AnaglyphFreeCamera extends FreeCamera {
  94340. /**
  94341. * Creates a new AnaglyphFreeCamera
  94342. * @param name defines camera name
  94343. * @param position defines initial position
  94344. * @param interaxialDistance defines distance between each color axis
  94345. * @param scene defines the hosting scene
  94346. */
  94347. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94348. /**
  94349. * Gets camera class name
  94350. * @returns AnaglyphFreeCamera
  94351. */
  94352. getClassName(): string;
  94353. }
  94354. }
  94355. declare module BABYLON {
  94356. /**
  94357. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  94358. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94359. */
  94360. export class AnaglyphGamepadCamera extends GamepadCamera {
  94361. /**
  94362. * Creates a new AnaglyphGamepadCamera
  94363. * @param name defines camera name
  94364. * @param position defines initial position
  94365. * @param interaxialDistance defines distance between each color axis
  94366. * @param scene defines the hosting scene
  94367. */
  94368. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94369. /**
  94370. * Gets camera class name
  94371. * @returns AnaglyphGamepadCamera
  94372. */
  94373. getClassName(): string;
  94374. }
  94375. }
  94376. declare module BABYLON {
  94377. /**
  94378. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  94379. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  94380. */
  94381. export class AnaglyphUniversalCamera extends UniversalCamera {
  94382. /**
  94383. * Creates a new AnaglyphUniversalCamera
  94384. * @param name defines camera name
  94385. * @param position defines initial position
  94386. * @param interaxialDistance defines distance between each color axis
  94387. * @param scene defines the hosting scene
  94388. */
  94389. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  94390. /**
  94391. * Gets camera class name
  94392. * @returns AnaglyphUniversalCamera
  94393. */
  94394. getClassName(): string;
  94395. }
  94396. }
  94397. declare module BABYLON {
  94398. /** @hidden */
  94399. export var stereoscopicInterlacePixelShader: {
  94400. name: string;
  94401. shader: string;
  94402. };
  94403. }
  94404. declare module BABYLON {
  94405. /**
  94406. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  94407. */
  94408. export class StereoscopicInterlacePostProcess extends PostProcess {
  94409. private _stepSize;
  94410. private _passedProcess;
  94411. /**
  94412. * Initializes a StereoscopicInterlacePostProcess
  94413. * @param name The name of the effect.
  94414. * @param rigCameras The rig cameras to be appled to the post process
  94415. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  94416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94417. * @param engine The engine which the post process will be applied. (default: current engine)
  94418. * @param reusable If the post process can be reused on the same frame. (default: false)
  94419. */
  94420. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  94421. }
  94422. }
  94423. declare module BABYLON {
  94424. /**
  94425. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  94426. * @see http://doc.babylonjs.com/features/cameras
  94427. */
  94428. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  94429. /**
  94430. * Creates a new StereoscopicArcRotateCamera
  94431. * @param name defines camera name
  94432. * @param alpha defines alpha angle (in radians)
  94433. * @param beta defines beta angle (in radians)
  94434. * @param radius defines radius
  94435. * @param target defines camera target
  94436. * @param interaxialDistance defines distance between each color axis
  94437. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94438. * @param scene defines the hosting scene
  94439. */
  94440. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94441. /**
  94442. * Gets camera class name
  94443. * @returns StereoscopicArcRotateCamera
  94444. */
  94445. getClassName(): string;
  94446. }
  94447. }
  94448. declare module BABYLON {
  94449. /**
  94450. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  94451. * @see http://doc.babylonjs.com/features/cameras
  94452. */
  94453. export class StereoscopicFreeCamera extends FreeCamera {
  94454. /**
  94455. * Creates a new StereoscopicFreeCamera
  94456. * @param name defines camera name
  94457. * @param position defines initial position
  94458. * @param interaxialDistance defines distance between each color axis
  94459. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94460. * @param scene defines the hosting scene
  94461. */
  94462. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94463. /**
  94464. * Gets camera class name
  94465. * @returns StereoscopicFreeCamera
  94466. */
  94467. getClassName(): string;
  94468. }
  94469. }
  94470. declare module BABYLON {
  94471. /**
  94472. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  94473. * @see http://doc.babylonjs.com/features/cameras
  94474. */
  94475. export class StereoscopicGamepadCamera extends GamepadCamera {
  94476. /**
  94477. * Creates a new StereoscopicGamepadCamera
  94478. * @param name defines camera name
  94479. * @param position defines initial position
  94480. * @param interaxialDistance defines distance between each color axis
  94481. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94482. * @param scene defines the hosting scene
  94483. */
  94484. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94485. /**
  94486. * Gets camera class name
  94487. * @returns StereoscopicGamepadCamera
  94488. */
  94489. getClassName(): string;
  94490. }
  94491. }
  94492. declare module BABYLON {
  94493. /**
  94494. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  94495. * @see http://doc.babylonjs.com/features/cameras
  94496. */
  94497. export class StereoscopicUniversalCamera extends UniversalCamera {
  94498. /**
  94499. * Creates a new StereoscopicUniversalCamera
  94500. * @param name defines camera name
  94501. * @param position defines initial position
  94502. * @param interaxialDistance defines distance between each color axis
  94503. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  94504. * @param scene defines the hosting scene
  94505. */
  94506. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  94507. /**
  94508. * Gets camera class name
  94509. * @returns StereoscopicUniversalCamera
  94510. */
  94511. getClassName(): string;
  94512. }
  94513. }
  94514. declare module BABYLON {
  94515. /**
  94516. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  94517. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94518. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94519. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94520. */
  94521. export class VirtualJoysticksCamera extends FreeCamera {
  94522. /**
  94523. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  94524. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  94525. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  94526. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  94527. * @param name Define the name of the camera in the scene
  94528. * @param position Define the start position of the camera in the scene
  94529. * @param scene Define the scene the camera belongs to
  94530. */
  94531. constructor(name: string, position: Vector3, scene: Scene);
  94532. /**
  94533. * Gets the current object class name.
  94534. * @return the class name
  94535. */
  94536. getClassName(): string;
  94537. }
  94538. }
  94539. declare module BABYLON {
  94540. /**
  94541. * This represents all the required metrics to create a VR camera.
  94542. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  94543. */
  94544. export class VRCameraMetrics {
  94545. /**
  94546. * Define the horizontal resolution off the screen.
  94547. */
  94548. hResolution: number;
  94549. /**
  94550. * Define the vertical resolution off the screen.
  94551. */
  94552. vResolution: number;
  94553. /**
  94554. * Define the horizontal screen size.
  94555. */
  94556. hScreenSize: number;
  94557. /**
  94558. * Define the vertical screen size.
  94559. */
  94560. vScreenSize: number;
  94561. /**
  94562. * Define the vertical screen center position.
  94563. */
  94564. vScreenCenter: number;
  94565. /**
  94566. * Define the distance of the eyes to the screen.
  94567. */
  94568. eyeToScreenDistance: number;
  94569. /**
  94570. * Define the distance between both lenses
  94571. */
  94572. lensSeparationDistance: number;
  94573. /**
  94574. * Define the distance between both viewer's eyes.
  94575. */
  94576. interpupillaryDistance: number;
  94577. /**
  94578. * Define the distortion factor of the VR postprocess.
  94579. * Please, touch with care.
  94580. */
  94581. distortionK: number[];
  94582. /**
  94583. * Define the chromatic aberration correction factors for the VR post process.
  94584. */
  94585. chromaAbCorrection: number[];
  94586. /**
  94587. * Define the scale factor of the post process.
  94588. * The smaller the better but the slower.
  94589. */
  94590. postProcessScaleFactor: number;
  94591. /**
  94592. * Define an offset for the lens center.
  94593. */
  94594. lensCenterOffset: number;
  94595. /**
  94596. * Define if the current vr camera should compensate the distortion of the lense or not.
  94597. */
  94598. compensateDistortion: boolean;
  94599. /**
  94600. * Gets the rendering aspect ratio based on the provided resolutions.
  94601. */
  94602. readonly aspectRatio: number;
  94603. /**
  94604. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  94605. */
  94606. readonly aspectRatioFov: number;
  94607. /**
  94608. * @hidden
  94609. */
  94610. readonly leftHMatrix: Matrix;
  94611. /**
  94612. * @hidden
  94613. */
  94614. readonly rightHMatrix: Matrix;
  94615. /**
  94616. * @hidden
  94617. */
  94618. readonly leftPreViewMatrix: Matrix;
  94619. /**
  94620. * @hidden
  94621. */
  94622. readonly rightPreViewMatrix: Matrix;
  94623. /**
  94624. * Get the default VRMetrics based on the most generic setup.
  94625. * @returns the default vr metrics
  94626. */
  94627. static GetDefault(): VRCameraMetrics;
  94628. }
  94629. }
  94630. declare module BABYLON {
  94631. /** @hidden */
  94632. export var vrDistortionCorrectionPixelShader: {
  94633. name: string;
  94634. shader: string;
  94635. };
  94636. }
  94637. declare module BABYLON {
  94638. /**
  94639. * VRDistortionCorrectionPostProcess used for mobile VR
  94640. */
  94641. export class VRDistortionCorrectionPostProcess extends PostProcess {
  94642. private _isRightEye;
  94643. private _distortionFactors;
  94644. private _postProcessScaleFactor;
  94645. private _lensCenterOffset;
  94646. private _scaleIn;
  94647. private _scaleFactor;
  94648. private _lensCenter;
  94649. /**
  94650. * Initializes the VRDistortionCorrectionPostProcess
  94651. * @param name The name of the effect.
  94652. * @param camera The camera to apply the render pass to.
  94653. * @param isRightEye If this is for the right eye distortion
  94654. * @param vrMetrics All the required metrics for the VR camera
  94655. */
  94656. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  94657. }
  94658. }
  94659. declare module BABYLON {
  94660. /**
  94661. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  94662. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94663. */
  94664. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  94665. /**
  94666. * Creates a new VRDeviceOrientationArcRotateCamera
  94667. * @param name defines camera name
  94668. * @param alpha defines the camera rotation along the logitudinal axis
  94669. * @param beta defines the camera rotation along the latitudinal axis
  94670. * @param radius defines the camera distance from its target
  94671. * @param target defines the camera target
  94672. * @param scene defines the scene the camera belongs to
  94673. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94674. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94675. */
  94676. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94677. /**
  94678. * Gets camera class name
  94679. * @returns VRDeviceOrientationArcRotateCamera
  94680. */
  94681. getClassName(): string;
  94682. }
  94683. }
  94684. declare module BABYLON {
  94685. /**
  94686. * Camera used to simulate VR rendering (based on FreeCamera)
  94687. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94688. */
  94689. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  94690. /**
  94691. * Creates a new VRDeviceOrientationFreeCamera
  94692. * @param name defines camera name
  94693. * @param position defines the start position of the camera
  94694. * @param scene defines the scene the camera belongs to
  94695. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94696. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94697. */
  94698. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94699. /**
  94700. * Gets camera class name
  94701. * @returns VRDeviceOrientationFreeCamera
  94702. */
  94703. getClassName(): string;
  94704. }
  94705. }
  94706. declare module BABYLON {
  94707. /**
  94708. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  94709. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  94710. */
  94711. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  94712. /**
  94713. * Creates a new VRDeviceOrientationGamepadCamera
  94714. * @param name defines camera name
  94715. * @param position defines the start position of the camera
  94716. * @param scene defines the scene the camera belongs to
  94717. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  94718. * @param vrCameraMetrics defines the vr metrics associated to the camera
  94719. */
  94720. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  94721. /**
  94722. * Gets camera class name
  94723. * @returns VRDeviceOrientationGamepadCamera
  94724. */
  94725. getClassName(): string;
  94726. }
  94727. }
  94728. declare module BABYLON {
  94729. /**
  94730. * Defines supported buttons for XBox360 compatible gamepads
  94731. */
  94732. export enum Xbox360Button {
  94733. /** A */
  94734. A = 0,
  94735. /** B */
  94736. B = 1,
  94737. /** X */
  94738. X = 2,
  94739. /** Y */
  94740. Y = 3,
  94741. /** Start */
  94742. Start = 4,
  94743. /** Back */
  94744. Back = 5,
  94745. /** Left button */
  94746. LB = 6,
  94747. /** Right button */
  94748. RB = 7,
  94749. /** Left stick */
  94750. LeftStick = 8,
  94751. /** Right stick */
  94752. RightStick = 9
  94753. }
  94754. /** Defines values for XBox360 DPad */
  94755. export enum Xbox360Dpad {
  94756. /** Up */
  94757. Up = 0,
  94758. /** Down */
  94759. Down = 1,
  94760. /** Left */
  94761. Left = 2,
  94762. /** Right */
  94763. Right = 3
  94764. }
  94765. /**
  94766. * Defines a XBox360 gamepad
  94767. */
  94768. export class Xbox360Pad extends Gamepad {
  94769. private _leftTrigger;
  94770. private _rightTrigger;
  94771. private _onlefttriggerchanged;
  94772. private _onrighttriggerchanged;
  94773. private _onbuttondown;
  94774. private _onbuttonup;
  94775. private _ondpaddown;
  94776. private _ondpadup;
  94777. /** Observable raised when a button is pressed */
  94778. onButtonDownObservable: Observable<Xbox360Button>;
  94779. /** Observable raised when a button is released */
  94780. onButtonUpObservable: Observable<Xbox360Button>;
  94781. /** Observable raised when a pad is pressed */
  94782. onPadDownObservable: Observable<Xbox360Dpad>;
  94783. /** Observable raised when a pad is released */
  94784. onPadUpObservable: Observable<Xbox360Dpad>;
  94785. private _buttonA;
  94786. private _buttonB;
  94787. private _buttonX;
  94788. private _buttonY;
  94789. private _buttonBack;
  94790. private _buttonStart;
  94791. private _buttonLB;
  94792. private _buttonRB;
  94793. private _buttonLeftStick;
  94794. private _buttonRightStick;
  94795. private _dPadUp;
  94796. private _dPadDown;
  94797. private _dPadLeft;
  94798. private _dPadRight;
  94799. private _isXboxOnePad;
  94800. /**
  94801. * Creates a new XBox360 gamepad object
  94802. * @param id defines the id of this gamepad
  94803. * @param index defines its index
  94804. * @param gamepad defines the internal HTML gamepad object
  94805. * @param xboxOne defines if it is a XBox One gamepad
  94806. */
  94807. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  94808. /**
  94809. * Defines the callback to call when left trigger is pressed
  94810. * @param callback defines the callback to use
  94811. */
  94812. onlefttriggerchanged(callback: (value: number) => void): void;
  94813. /**
  94814. * Defines the callback to call when right trigger is pressed
  94815. * @param callback defines the callback to use
  94816. */
  94817. onrighttriggerchanged(callback: (value: number) => void): void;
  94818. /**
  94819. * Gets the left trigger value
  94820. */
  94821. /**
  94822. * Sets the left trigger value
  94823. */
  94824. leftTrigger: number;
  94825. /**
  94826. * Gets the right trigger value
  94827. */
  94828. /**
  94829. * Sets the right trigger value
  94830. */
  94831. rightTrigger: number;
  94832. /**
  94833. * Defines the callback to call when a button is pressed
  94834. * @param callback defines the callback to use
  94835. */
  94836. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  94837. /**
  94838. * Defines the callback to call when a button is released
  94839. * @param callback defines the callback to use
  94840. */
  94841. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  94842. /**
  94843. * Defines the callback to call when a pad is pressed
  94844. * @param callback defines the callback to use
  94845. */
  94846. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  94847. /**
  94848. * Defines the callback to call when a pad is released
  94849. * @param callback defines the callback to use
  94850. */
  94851. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  94852. private _setButtonValue;
  94853. private _setDPadValue;
  94854. /**
  94855. * Gets the value of the `A` button
  94856. */
  94857. /**
  94858. * Sets the value of the `A` button
  94859. */
  94860. buttonA: number;
  94861. /**
  94862. * Gets the value of the `B` button
  94863. */
  94864. /**
  94865. * Sets the value of the `B` button
  94866. */
  94867. buttonB: number;
  94868. /**
  94869. * Gets the value of the `X` button
  94870. */
  94871. /**
  94872. * Sets the value of the `X` button
  94873. */
  94874. buttonX: number;
  94875. /**
  94876. * Gets the value of the `Y` button
  94877. */
  94878. /**
  94879. * Sets the value of the `Y` button
  94880. */
  94881. buttonY: number;
  94882. /**
  94883. * Gets the value of the `Start` button
  94884. */
  94885. /**
  94886. * Sets the value of the `Start` button
  94887. */
  94888. buttonStart: number;
  94889. /**
  94890. * Gets the value of the `Back` button
  94891. */
  94892. /**
  94893. * Sets the value of the `Back` button
  94894. */
  94895. buttonBack: number;
  94896. /**
  94897. * Gets the value of the `Left` button
  94898. */
  94899. /**
  94900. * Sets the value of the `Left` button
  94901. */
  94902. buttonLB: number;
  94903. /**
  94904. * Gets the value of the `Right` button
  94905. */
  94906. /**
  94907. * Sets the value of the `Right` button
  94908. */
  94909. buttonRB: number;
  94910. /**
  94911. * Gets the value of the Left joystick
  94912. */
  94913. /**
  94914. * Sets the value of the Left joystick
  94915. */
  94916. buttonLeftStick: number;
  94917. /**
  94918. * Gets the value of the Right joystick
  94919. */
  94920. /**
  94921. * Sets the value of the Right joystick
  94922. */
  94923. buttonRightStick: number;
  94924. /**
  94925. * Gets the value of D-pad up
  94926. */
  94927. /**
  94928. * Sets the value of D-pad up
  94929. */
  94930. dPadUp: number;
  94931. /**
  94932. * Gets the value of D-pad down
  94933. */
  94934. /**
  94935. * Sets the value of D-pad down
  94936. */
  94937. dPadDown: number;
  94938. /**
  94939. * Gets the value of D-pad left
  94940. */
  94941. /**
  94942. * Sets the value of D-pad left
  94943. */
  94944. dPadLeft: number;
  94945. /**
  94946. * Gets the value of D-pad right
  94947. */
  94948. /**
  94949. * Sets the value of D-pad right
  94950. */
  94951. dPadRight: number;
  94952. /**
  94953. * Force the gamepad to synchronize with device values
  94954. */
  94955. update(): void;
  94956. /**
  94957. * Disposes the gamepad
  94958. */
  94959. dispose(): void;
  94960. }
  94961. }
  94962. declare module BABYLON {
  94963. /**
  94964. * Base class of materials working in push mode in babylon JS
  94965. * @hidden
  94966. */
  94967. export class PushMaterial extends Material {
  94968. protected _activeEffect: Effect;
  94969. protected _normalMatrix: Matrix;
  94970. /**
  94971. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94972. * This means that the material can keep using a previous shader while a new one is being compiled.
  94973. * This is mostly used when shader parallel compilation is supported (true by default)
  94974. */
  94975. allowShaderHotSwapping: boolean;
  94976. constructor(name: string, scene: Scene);
  94977. getEffect(): Effect;
  94978. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94979. /**
  94980. * Binds the given world matrix to the active effect
  94981. *
  94982. * @param world the matrix to bind
  94983. */
  94984. bindOnlyWorldMatrix(world: Matrix): void;
  94985. /**
  94986. * Binds the given normal matrix to the active effect
  94987. *
  94988. * @param normalMatrix the matrix to bind
  94989. */
  94990. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94991. bind(world: Matrix, mesh?: Mesh): void;
  94992. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94993. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94994. }
  94995. }
  94996. declare module BABYLON {
  94997. /**
  94998. * This groups all the flags used to control the materials channel.
  94999. */
  95000. export class MaterialFlags {
  95001. private static _DiffuseTextureEnabled;
  95002. /**
  95003. * Are diffuse textures enabled in the application.
  95004. */
  95005. static DiffuseTextureEnabled: boolean;
  95006. private static _AmbientTextureEnabled;
  95007. /**
  95008. * Are ambient textures enabled in the application.
  95009. */
  95010. static AmbientTextureEnabled: boolean;
  95011. private static _OpacityTextureEnabled;
  95012. /**
  95013. * Are opacity textures enabled in the application.
  95014. */
  95015. static OpacityTextureEnabled: boolean;
  95016. private static _ReflectionTextureEnabled;
  95017. /**
  95018. * Are reflection textures enabled in the application.
  95019. */
  95020. static ReflectionTextureEnabled: boolean;
  95021. private static _EmissiveTextureEnabled;
  95022. /**
  95023. * Are emissive textures enabled in the application.
  95024. */
  95025. static EmissiveTextureEnabled: boolean;
  95026. private static _SpecularTextureEnabled;
  95027. /**
  95028. * Are specular textures enabled in the application.
  95029. */
  95030. static SpecularTextureEnabled: boolean;
  95031. private static _BumpTextureEnabled;
  95032. /**
  95033. * Are bump textures enabled in the application.
  95034. */
  95035. static BumpTextureEnabled: boolean;
  95036. private static _LightmapTextureEnabled;
  95037. /**
  95038. * Are lightmap textures enabled in the application.
  95039. */
  95040. static LightmapTextureEnabled: boolean;
  95041. private static _RefractionTextureEnabled;
  95042. /**
  95043. * Are refraction textures enabled in the application.
  95044. */
  95045. static RefractionTextureEnabled: boolean;
  95046. private static _ColorGradingTextureEnabled;
  95047. /**
  95048. * Are color grading textures enabled in the application.
  95049. */
  95050. static ColorGradingTextureEnabled: boolean;
  95051. private static _FresnelEnabled;
  95052. /**
  95053. * Are fresnels enabled in the application.
  95054. */
  95055. static FresnelEnabled: boolean;
  95056. private static _ClearCoatTextureEnabled;
  95057. /**
  95058. * Are clear coat textures enabled in the application.
  95059. */
  95060. static ClearCoatTextureEnabled: boolean;
  95061. private static _ClearCoatBumpTextureEnabled;
  95062. /**
  95063. * Are clear coat bump textures enabled in the application.
  95064. */
  95065. static ClearCoatBumpTextureEnabled: boolean;
  95066. private static _ClearCoatTintTextureEnabled;
  95067. /**
  95068. * Are clear coat tint textures enabled in the application.
  95069. */
  95070. static ClearCoatTintTextureEnabled: boolean;
  95071. private static _SheenTextureEnabled;
  95072. /**
  95073. * Are sheen textures enabled in the application.
  95074. */
  95075. static SheenTextureEnabled: boolean;
  95076. private static _AnisotropicTextureEnabled;
  95077. /**
  95078. * Are anisotropic textures enabled in the application.
  95079. */
  95080. static AnisotropicTextureEnabled: boolean;
  95081. }
  95082. }
  95083. declare module BABYLON {
  95084. /** @hidden */
  95085. export var defaultFragmentDeclaration: {
  95086. name: string;
  95087. shader: string;
  95088. };
  95089. }
  95090. declare module BABYLON {
  95091. /** @hidden */
  95092. export var defaultUboDeclaration: {
  95093. name: string;
  95094. shader: string;
  95095. };
  95096. }
  95097. declare module BABYLON {
  95098. /** @hidden */
  95099. export var lightFragmentDeclaration: {
  95100. name: string;
  95101. shader: string;
  95102. };
  95103. }
  95104. declare module BABYLON {
  95105. /** @hidden */
  95106. export var lightUboDeclaration: {
  95107. name: string;
  95108. shader: string;
  95109. };
  95110. }
  95111. declare module BABYLON {
  95112. /** @hidden */
  95113. export var lightsFragmentFunctions: {
  95114. name: string;
  95115. shader: string;
  95116. };
  95117. }
  95118. declare module BABYLON {
  95119. /** @hidden */
  95120. export var shadowsFragmentFunctions: {
  95121. name: string;
  95122. shader: string;
  95123. };
  95124. }
  95125. declare module BABYLON {
  95126. /** @hidden */
  95127. export var fresnelFunction: {
  95128. name: string;
  95129. shader: string;
  95130. };
  95131. }
  95132. declare module BABYLON {
  95133. /** @hidden */
  95134. export var reflectionFunction: {
  95135. name: string;
  95136. shader: string;
  95137. };
  95138. }
  95139. declare module BABYLON {
  95140. /** @hidden */
  95141. export var bumpFragmentFunctions: {
  95142. name: string;
  95143. shader: string;
  95144. };
  95145. }
  95146. declare module BABYLON {
  95147. /** @hidden */
  95148. export var logDepthDeclaration: {
  95149. name: string;
  95150. shader: string;
  95151. };
  95152. }
  95153. declare module BABYLON {
  95154. /** @hidden */
  95155. export var bumpFragment: {
  95156. name: string;
  95157. shader: string;
  95158. };
  95159. }
  95160. declare module BABYLON {
  95161. /** @hidden */
  95162. export var depthPrePass: {
  95163. name: string;
  95164. shader: string;
  95165. };
  95166. }
  95167. declare module BABYLON {
  95168. /** @hidden */
  95169. export var lightFragment: {
  95170. name: string;
  95171. shader: string;
  95172. };
  95173. }
  95174. declare module BABYLON {
  95175. /** @hidden */
  95176. export var logDepthFragment: {
  95177. name: string;
  95178. shader: string;
  95179. };
  95180. }
  95181. declare module BABYLON {
  95182. /** @hidden */
  95183. export var defaultPixelShader: {
  95184. name: string;
  95185. shader: string;
  95186. };
  95187. }
  95188. declare module BABYLON {
  95189. /** @hidden */
  95190. export var defaultVertexDeclaration: {
  95191. name: string;
  95192. shader: string;
  95193. };
  95194. }
  95195. declare module BABYLON {
  95196. /** @hidden */
  95197. export var bumpVertexDeclaration: {
  95198. name: string;
  95199. shader: string;
  95200. };
  95201. }
  95202. declare module BABYLON {
  95203. /** @hidden */
  95204. export var bumpVertex: {
  95205. name: string;
  95206. shader: string;
  95207. };
  95208. }
  95209. declare module BABYLON {
  95210. /** @hidden */
  95211. export var fogVertex: {
  95212. name: string;
  95213. shader: string;
  95214. };
  95215. }
  95216. declare module BABYLON {
  95217. /** @hidden */
  95218. export var shadowsVertex: {
  95219. name: string;
  95220. shader: string;
  95221. };
  95222. }
  95223. declare module BABYLON {
  95224. /** @hidden */
  95225. export var pointCloudVertex: {
  95226. name: string;
  95227. shader: string;
  95228. };
  95229. }
  95230. declare module BABYLON {
  95231. /** @hidden */
  95232. export var logDepthVertex: {
  95233. name: string;
  95234. shader: string;
  95235. };
  95236. }
  95237. declare module BABYLON {
  95238. /** @hidden */
  95239. export var defaultVertexShader: {
  95240. name: string;
  95241. shader: string;
  95242. };
  95243. }
  95244. declare module BABYLON {
  95245. /** @hidden */
  95246. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95247. MAINUV1: boolean;
  95248. MAINUV2: boolean;
  95249. DIFFUSE: boolean;
  95250. DIFFUSEDIRECTUV: number;
  95251. AMBIENT: boolean;
  95252. AMBIENTDIRECTUV: number;
  95253. OPACITY: boolean;
  95254. OPACITYDIRECTUV: number;
  95255. OPACITYRGB: boolean;
  95256. REFLECTION: boolean;
  95257. EMISSIVE: boolean;
  95258. EMISSIVEDIRECTUV: number;
  95259. SPECULAR: boolean;
  95260. SPECULARDIRECTUV: number;
  95261. BUMP: boolean;
  95262. BUMPDIRECTUV: number;
  95263. PARALLAX: boolean;
  95264. PARALLAXOCCLUSION: boolean;
  95265. SPECULAROVERALPHA: boolean;
  95266. CLIPPLANE: boolean;
  95267. CLIPPLANE2: boolean;
  95268. CLIPPLANE3: boolean;
  95269. CLIPPLANE4: boolean;
  95270. ALPHATEST: boolean;
  95271. DEPTHPREPASS: boolean;
  95272. ALPHAFROMDIFFUSE: boolean;
  95273. POINTSIZE: boolean;
  95274. FOG: boolean;
  95275. SPECULARTERM: boolean;
  95276. DIFFUSEFRESNEL: boolean;
  95277. OPACITYFRESNEL: boolean;
  95278. REFLECTIONFRESNEL: boolean;
  95279. REFRACTIONFRESNEL: boolean;
  95280. EMISSIVEFRESNEL: boolean;
  95281. FRESNEL: boolean;
  95282. NORMAL: boolean;
  95283. UV1: boolean;
  95284. UV2: boolean;
  95285. VERTEXCOLOR: boolean;
  95286. VERTEXALPHA: boolean;
  95287. NUM_BONE_INFLUENCERS: number;
  95288. BonesPerMesh: number;
  95289. BONETEXTURE: boolean;
  95290. INSTANCES: boolean;
  95291. GLOSSINESS: boolean;
  95292. ROUGHNESS: boolean;
  95293. EMISSIVEASILLUMINATION: boolean;
  95294. LINKEMISSIVEWITHDIFFUSE: boolean;
  95295. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95296. LIGHTMAP: boolean;
  95297. LIGHTMAPDIRECTUV: number;
  95298. OBJECTSPACE_NORMALMAP: boolean;
  95299. USELIGHTMAPASSHADOWMAP: boolean;
  95300. REFLECTIONMAP_3D: boolean;
  95301. REFLECTIONMAP_SPHERICAL: boolean;
  95302. REFLECTIONMAP_PLANAR: boolean;
  95303. REFLECTIONMAP_CUBIC: boolean;
  95304. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95305. REFLECTIONMAP_PROJECTION: boolean;
  95306. REFLECTIONMAP_SKYBOX: boolean;
  95307. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95308. REFLECTIONMAP_EXPLICIT: boolean;
  95309. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95310. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95311. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95312. INVERTCUBICMAP: boolean;
  95313. LOGARITHMICDEPTH: boolean;
  95314. REFRACTION: boolean;
  95315. REFRACTIONMAP_3D: boolean;
  95316. REFLECTIONOVERALPHA: boolean;
  95317. TWOSIDEDLIGHTING: boolean;
  95318. SHADOWFLOAT: boolean;
  95319. MORPHTARGETS: boolean;
  95320. MORPHTARGETS_NORMAL: boolean;
  95321. MORPHTARGETS_TANGENT: boolean;
  95322. NUM_MORPH_INFLUENCERS: number;
  95323. NONUNIFORMSCALING: boolean;
  95324. PREMULTIPLYALPHA: boolean;
  95325. IMAGEPROCESSING: boolean;
  95326. VIGNETTE: boolean;
  95327. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95328. VIGNETTEBLENDMODEOPAQUE: boolean;
  95329. TONEMAPPING: boolean;
  95330. TONEMAPPING_ACES: boolean;
  95331. CONTRAST: boolean;
  95332. COLORCURVES: boolean;
  95333. COLORGRADING: boolean;
  95334. COLORGRADING3D: boolean;
  95335. SAMPLER3DGREENDEPTH: boolean;
  95336. SAMPLER3DBGRMAP: boolean;
  95337. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95338. /**
  95339. * If the reflection texture on this material is in linear color space
  95340. * @hidden
  95341. */
  95342. IS_REFLECTION_LINEAR: boolean;
  95343. /**
  95344. * If the refraction texture on this material is in linear color space
  95345. * @hidden
  95346. */
  95347. IS_REFRACTION_LINEAR: boolean;
  95348. EXPOSURE: boolean;
  95349. constructor();
  95350. setReflectionMode(modeToEnable: string): void;
  95351. }
  95352. /**
  95353. * This is the default material used in Babylon. It is the best trade off between quality
  95354. * and performances.
  95355. * @see http://doc.babylonjs.com/babylon101/materials
  95356. */
  95357. export class StandardMaterial extends PushMaterial {
  95358. private _diffuseTexture;
  95359. /**
  95360. * The basic texture of the material as viewed under a light.
  95361. */
  95362. diffuseTexture: Nullable<BaseTexture>;
  95363. private _ambientTexture;
  95364. /**
  95365. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95366. */
  95367. ambientTexture: Nullable<BaseTexture>;
  95368. private _opacityTexture;
  95369. /**
  95370. * Define the transparency of the material from a texture.
  95371. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95372. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95373. */
  95374. opacityTexture: Nullable<BaseTexture>;
  95375. private _reflectionTexture;
  95376. /**
  95377. * Define the texture used to display the reflection.
  95378. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95379. */
  95380. reflectionTexture: Nullable<BaseTexture>;
  95381. private _emissiveTexture;
  95382. /**
  95383. * Define texture of the material as if self lit.
  95384. * This will be mixed in the final result even in the absence of light.
  95385. */
  95386. emissiveTexture: Nullable<BaseTexture>;
  95387. private _specularTexture;
  95388. /**
  95389. * Define how the color and intensity of the highlight given by the light in the material.
  95390. */
  95391. specularTexture: Nullable<BaseTexture>;
  95392. private _bumpTexture;
  95393. /**
  95394. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95395. * 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.
  95396. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95397. */
  95398. bumpTexture: Nullable<BaseTexture>;
  95399. private _lightmapTexture;
  95400. /**
  95401. * Complex lighting can be computationally expensive to compute at runtime.
  95402. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95403. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95404. */
  95405. lightmapTexture: Nullable<BaseTexture>;
  95406. private _refractionTexture;
  95407. /**
  95408. * Define the texture used to display the refraction.
  95409. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95410. */
  95411. refractionTexture: Nullable<BaseTexture>;
  95412. /**
  95413. * The color of the material lit by the environmental background lighting.
  95414. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95415. */
  95416. ambientColor: Color3;
  95417. /**
  95418. * The basic color of the material as viewed under a light.
  95419. */
  95420. diffuseColor: Color3;
  95421. /**
  95422. * Define how the color and intensity of the highlight given by the light in the material.
  95423. */
  95424. specularColor: Color3;
  95425. /**
  95426. * Define the color of the material as if self lit.
  95427. * This will be mixed in the final result even in the absence of light.
  95428. */
  95429. emissiveColor: Color3;
  95430. /**
  95431. * Defines how sharp are the highlights in the material.
  95432. * The bigger the value the sharper giving a more glossy feeling to the result.
  95433. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95434. */
  95435. specularPower: number;
  95436. private _useAlphaFromDiffuseTexture;
  95437. /**
  95438. * Does the transparency come from the diffuse texture alpha channel.
  95439. */
  95440. useAlphaFromDiffuseTexture: boolean;
  95441. private _useEmissiveAsIllumination;
  95442. /**
  95443. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95444. */
  95445. useEmissiveAsIllumination: boolean;
  95446. private _linkEmissiveWithDiffuse;
  95447. /**
  95448. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95449. * the emissive level when the final color is close to one.
  95450. */
  95451. linkEmissiveWithDiffuse: boolean;
  95452. private _useSpecularOverAlpha;
  95453. /**
  95454. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95455. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95456. */
  95457. useSpecularOverAlpha: boolean;
  95458. private _useReflectionOverAlpha;
  95459. /**
  95460. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95461. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95462. */
  95463. useReflectionOverAlpha: boolean;
  95464. private _disableLighting;
  95465. /**
  95466. * Does lights from the scene impacts this material.
  95467. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95468. */
  95469. disableLighting: boolean;
  95470. private _useObjectSpaceNormalMap;
  95471. /**
  95472. * Allows using an object space normal map (instead of tangent space).
  95473. */
  95474. useObjectSpaceNormalMap: boolean;
  95475. private _useParallax;
  95476. /**
  95477. * Is parallax enabled or not.
  95478. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95479. */
  95480. useParallax: boolean;
  95481. private _useParallaxOcclusion;
  95482. /**
  95483. * Is parallax occlusion enabled or not.
  95484. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95485. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95486. */
  95487. useParallaxOcclusion: boolean;
  95488. /**
  95489. * 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.
  95490. */
  95491. parallaxScaleBias: number;
  95492. private _roughness;
  95493. /**
  95494. * Helps to define how blurry the reflections should appears in the material.
  95495. */
  95496. roughness: number;
  95497. /**
  95498. * In case of refraction, define the value of the indice of refraction.
  95499. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95500. */
  95501. indexOfRefraction: number;
  95502. /**
  95503. * Invert the refraction texture alongside the y axis.
  95504. * It can be useful with procedural textures or probe for instance.
  95505. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95506. */
  95507. invertRefractionY: boolean;
  95508. /**
  95509. * Defines the alpha limits in alpha test mode.
  95510. */
  95511. alphaCutOff: number;
  95512. private _useLightmapAsShadowmap;
  95513. /**
  95514. * In case of light mapping, define whether the map contains light or shadow informations.
  95515. */
  95516. useLightmapAsShadowmap: boolean;
  95517. private _diffuseFresnelParameters;
  95518. /**
  95519. * Define the diffuse fresnel parameters of the material.
  95520. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95521. */
  95522. diffuseFresnelParameters: FresnelParameters;
  95523. private _opacityFresnelParameters;
  95524. /**
  95525. * Define the opacity fresnel parameters of the material.
  95526. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95527. */
  95528. opacityFresnelParameters: FresnelParameters;
  95529. private _reflectionFresnelParameters;
  95530. /**
  95531. * Define the reflection fresnel parameters of the material.
  95532. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95533. */
  95534. reflectionFresnelParameters: FresnelParameters;
  95535. private _refractionFresnelParameters;
  95536. /**
  95537. * Define the refraction fresnel parameters of the material.
  95538. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95539. */
  95540. refractionFresnelParameters: FresnelParameters;
  95541. private _emissiveFresnelParameters;
  95542. /**
  95543. * Define the emissive fresnel parameters of the material.
  95544. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95545. */
  95546. emissiveFresnelParameters: FresnelParameters;
  95547. private _useReflectionFresnelFromSpecular;
  95548. /**
  95549. * If true automatically deducts the fresnels values from the material specularity.
  95550. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95551. */
  95552. useReflectionFresnelFromSpecular: boolean;
  95553. private _useGlossinessFromSpecularMapAlpha;
  95554. /**
  95555. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95556. */
  95557. useGlossinessFromSpecularMapAlpha: boolean;
  95558. private _maxSimultaneousLights;
  95559. /**
  95560. * Defines the maximum number of lights that can be used in the material
  95561. */
  95562. maxSimultaneousLights: number;
  95563. private _invertNormalMapX;
  95564. /**
  95565. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95566. */
  95567. invertNormalMapX: boolean;
  95568. private _invertNormalMapY;
  95569. /**
  95570. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95571. */
  95572. invertNormalMapY: boolean;
  95573. private _twoSidedLighting;
  95574. /**
  95575. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95576. */
  95577. twoSidedLighting: boolean;
  95578. /**
  95579. * Default configuration related to image processing available in the standard Material.
  95580. */
  95581. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95582. /**
  95583. * Gets the image processing configuration used either in this material.
  95584. */
  95585. /**
  95586. * Sets the Default image processing configuration used either in the this material.
  95587. *
  95588. * If sets to null, the scene one is in use.
  95589. */
  95590. imageProcessingConfiguration: ImageProcessingConfiguration;
  95591. /**
  95592. * Keep track of the image processing observer to allow dispose and replace.
  95593. */
  95594. private _imageProcessingObserver;
  95595. /**
  95596. * Attaches a new image processing configuration to the Standard Material.
  95597. * @param configuration
  95598. */
  95599. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95600. /**
  95601. * Gets wether the color curves effect is enabled.
  95602. */
  95603. /**
  95604. * Sets wether the color curves effect is enabled.
  95605. */
  95606. cameraColorCurvesEnabled: boolean;
  95607. /**
  95608. * Gets wether the color grading effect is enabled.
  95609. */
  95610. /**
  95611. * Gets wether the color grading effect is enabled.
  95612. */
  95613. cameraColorGradingEnabled: boolean;
  95614. /**
  95615. * Gets wether tonemapping is enabled or not.
  95616. */
  95617. /**
  95618. * Sets wether tonemapping is enabled or not
  95619. */
  95620. cameraToneMappingEnabled: boolean;
  95621. /**
  95622. * The camera exposure used on this material.
  95623. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95624. * This corresponds to a photographic exposure.
  95625. */
  95626. /**
  95627. * The camera exposure used on this material.
  95628. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95629. * This corresponds to a photographic exposure.
  95630. */
  95631. cameraExposure: number;
  95632. /**
  95633. * Gets The camera contrast used on this material.
  95634. */
  95635. /**
  95636. * Sets The camera contrast used on this material.
  95637. */
  95638. cameraContrast: number;
  95639. /**
  95640. * Gets the Color Grading 2D Lookup Texture.
  95641. */
  95642. /**
  95643. * Sets the Color Grading 2D Lookup Texture.
  95644. */
  95645. cameraColorGradingTexture: Nullable<BaseTexture>;
  95646. /**
  95647. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95648. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95649. * 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;
  95650. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95651. */
  95652. /**
  95653. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95654. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95655. * 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;
  95656. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95657. */
  95658. cameraColorCurves: Nullable<ColorCurves>;
  95659. /**
  95660. * Custom callback helping to override the default shader used in the material.
  95661. */
  95662. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95663. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95664. protected _worldViewProjectionMatrix: Matrix;
  95665. protected _globalAmbientColor: Color3;
  95666. protected _useLogarithmicDepth: boolean;
  95667. /**
  95668. * Instantiates a new standard material.
  95669. * This is the default material used in Babylon. It is the best trade off between quality
  95670. * and performances.
  95671. * @see http://doc.babylonjs.com/babylon101/materials
  95672. * @param name Define the name of the material in the scene
  95673. * @param scene Define the scene the material belong to
  95674. */
  95675. constructor(name: string, scene: Scene);
  95676. /**
  95677. * Gets a boolean indicating that current material needs to register RTT
  95678. */
  95679. readonly hasRenderTargetTextures: boolean;
  95680. /**
  95681. * Gets the current class name of the material e.g. "StandardMaterial"
  95682. * Mainly use in serialization.
  95683. * @returns the class name
  95684. */
  95685. getClassName(): string;
  95686. /**
  95687. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95688. * You can try switching to logarithmic depth.
  95689. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95690. */
  95691. useLogarithmicDepth: boolean;
  95692. /**
  95693. * Specifies if the material will require alpha blending
  95694. * @returns a boolean specifying if alpha blending is needed
  95695. */
  95696. needAlphaBlending(): boolean;
  95697. /**
  95698. * Specifies if this material should be rendered in alpha test mode
  95699. * @returns a boolean specifying if an alpha test is needed.
  95700. */
  95701. needAlphaTesting(): boolean;
  95702. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95703. /**
  95704. * Get the texture used for alpha test purpose.
  95705. * @returns the diffuse texture in case of the standard material.
  95706. */
  95707. getAlphaTestTexture(): Nullable<BaseTexture>;
  95708. /**
  95709. * Get if the submesh is ready to be used and all its information available.
  95710. * Child classes can use it to update shaders
  95711. * @param mesh defines the mesh to check
  95712. * @param subMesh defines which submesh to check
  95713. * @param useInstances specifies that instances should be used
  95714. * @returns a boolean indicating that the submesh is ready or not
  95715. */
  95716. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95717. /**
  95718. * Builds the material UBO layouts.
  95719. * Used internally during the effect preparation.
  95720. */
  95721. buildUniformLayout(): void;
  95722. /**
  95723. * Unbinds the material from the mesh
  95724. */
  95725. unbind(): void;
  95726. /**
  95727. * Binds the submesh to this material by preparing the effect and shader to draw
  95728. * @param world defines the world transformation matrix
  95729. * @param mesh defines the mesh containing the submesh
  95730. * @param subMesh defines the submesh to bind the material to
  95731. */
  95732. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95733. /**
  95734. * Get the list of animatables in the material.
  95735. * @returns the list of animatables object used in the material
  95736. */
  95737. getAnimatables(): IAnimatable[];
  95738. /**
  95739. * Gets the active textures from the material
  95740. * @returns an array of textures
  95741. */
  95742. getActiveTextures(): BaseTexture[];
  95743. /**
  95744. * Specifies if the material uses a texture
  95745. * @param texture defines the texture to check against the material
  95746. * @returns a boolean specifying if the material uses the texture
  95747. */
  95748. hasTexture(texture: BaseTexture): boolean;
  95749. /**
  95750. * Disposes the material
  95751. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95752. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95753. */
  95754. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95755. /**
  95756. * Makes a duplicate of the material, and gives it a new name
  95757. * @param name defines the new name for the duplicated material
  95758. * @returns the cloned material
  95759. */
  95760. clone(name: string): StandardMaterial;
  95761. /**
  95762. * Serializes this material in a JSON representation
  95763. * @returns the serialized material object
  95764. */
  95765. serialize(): any;
  95766. /**
  95767. * Creates a standard material from parsed material data
  95768. * @param source defines the JSON representation of the material
  95769. * @param scene defines the hosting scene
  95770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95771. * @returns a new standard material
  95772. */
  95773. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95774. /**
  95775. * Are diffuse textures enabled in the application.
  95776. */
  95777. static DiffuseTextureEnabled: boolean;
  95778. /**
  95779. * Are ambient textures enabled in the application.
  95780. */
  95781. static AmbientTextureEnabled: boolean;
  95782. /**
  95783. * Are opacity textures enabled in the application.
  95784. */
  95785. static OpacityTextureEnabled: boolean;
  95786. /**
  95787. * Are reflection textures enabled in the application.
  95788. */
  95789. static ReflectionTextureEnabled: boolean;
  95790. /**
  95791. * Are emissive textures enabled in the application.
  95792. */
  95793. static EmissiveTextureEnabled: boolean;
  95794. /**
  95795. * Are specular textures enabled in the application.
  95796. */
  95797. static SpecularTextureEnabled: boolean;
  95798. /**
  95799. * Are bump textures enabled in the application.
  95800. */
  95801. static BumpTextureEnabled: boolean;
  95802. /**
  95803. * Are lightmap textures enabled in the application.
  95804. */
  95805. static LightmapTextureEnabled: boolean;
  95806. /**
  95807. * Are refraction textures enabled in the application.
  95808. */
  95809. static RefractionTextureEnabled: boolean;
  95810. /**
  95811. * Are color grading textures enabled in the application.
  95812. */
  95813. static ColorGradingTextureEnabled: boolean;
  95814. /**
  95815. * Are fresnels enabled in the application.
  95816. */
  95817. static FresnelEnabled: boolean;
  95818. }
  95819. }
  95820. declare module BABYLON {
  95821. /**
  95822. * A class extending Texture allowing drawing on a texture
  95823. * @see http://doc.babylonjs.com/how_to/dynamictexture
  95824. */
  95825. export class DynamicTexture extends Texture {
  95826. private _generateMipMaps;
  95827. private _canvas;
  95828. private _context;
  95829. private _engine;
  95830. /**
  95831. * Creates a DynamicTexture
  95832. * @param name defines the name of the texture
  95833. * @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
  95834. * @param scene defines the scene where you want the texture
  95835. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  95836. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  95837. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  95838. */
  95839. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  95840. /**
  95841. * Get the current class name of the texture useful for serialization or dynamic coding.
  95842. * @returns "DynamicTexture"
  95843. */
  95844. getClassName(): string;
  95845. /**
  95846. * Gets the current state of canRescale
  95847. */
  95848. readonly canRescale: boolean;
  95849. private _recreate;
  95850. /**
  95851. * Scales the texture
  95852. * @param ratio the scale factor to apply to both width and height
  95853. */
  95854. scale(ratio: number): void;
  95855. /**
  95856. * Resizes the texture
  95857. * @param width the new width
  95858. * @param height the new height
  95859. */
  95860. scaleTo(width: number, height: number): void;
  95861. /**
  95862. * Gets the context of the canvas used by the texture
  95863. * @returns the canvas context of the dynamic texture
  95864. */
  95865. getContext(): CanvasRenderingContext2D;
  95866. /**
  95867. * Clears the texture
  95868. */
  95869. clear(): void;
  95870. /**
  95871. * Updates the texture
  95872. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95873. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  95874. */
  95875. update(invertY?: boolean, premulAlpha?: boolean): void;
  95876. /**
  95877. * Draws text onto the texture
  95878. * @param text defines the text to be drawn
  95879. * @param x defines the placement of the text from the left
  95880. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  95881. * @param font defines the font to be used with font-style, font-size, font-name
  95882. * @param color defines the color used for the text
  95883. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  95884. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  95885. * @param update defines whether texture is immediately update (default is true)
  95886. */
  95887. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  95888. /**
  95889. * Clones the texture
  95890. * @returns the clone of the texture.
  95891. */
  95892. clone(): DynamicTexture;
  95893. /**
  95894. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  95895. * @returns a serialized dynamic texture object
  95896. */
  95897. serialize(): any;
  95898. /** @hidden */
  95899. _rebuild(): void;
  95900. }
  95901. }
  95902. declare module BABYLON {
  95903. /** @hidden */
  95904. export var imageProcessingPixelShader: {
  95905. name: string;
  95906. shader: string;
  95907. };
  95908. }
  95909. declare module BABYLON {
  95910. /**
  95911. * ImageProcessingPostProcess
  95912. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  95913. */
  95914. export class ImageProcessingPostProcess extends PostProcess {
  95915. /**
  95916. * Default configuration related to image processing available in the PBR Material.
  95917. */
  95918. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95919. /**
  95920. * Gets the image processing configuration used either in this material.
  95921. */
  95922. /**
  95923. * Sets the Default image processing configuration used either in the this material.
  95924. *
  95925. * If sets to null, the scene one is in use.
  95926. */
  95927. imageProcessingConfiguration: ImageProcessingConfiguration;
  95928. /**
  95929. * Keep track of the image processing observer to allow dispose and replace.
  95930. */
  95931. private _imageProcessingObserver;
  95932. /**
  95933. * Attaches a new image processing configuration to the PBR Material.
  95934. * @param configuration
  95935. */
  95936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  95937. /**
  95938. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95939. */
  95940. /**
  95941. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  95942. */
  95943. colorCurves: Nullable<ColorCurves>;
  95944. /**
  95945. * Gets wether the color curves effect is enabled.
  95946. */
  95947. /**
  95948. * Sets wether the color curves effect is enabled.
  95949. */
  95950. colorCurvesEnabled: boolean;
  95951. /**
  95952. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95953. */
  95954. /**
  95955. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  95956. */
  95957. colorGradingTexture: Nullable<BaseTexture>;
  95958. /**
  95959. * Gets wether the color grading effect is enabled.
  95960. */
  95961. /**
  95962. * Gets wether the color grading effect is enabled.
  95963. */
  95964. colorGradingEnabled: boolean;
  95965. /**
  95966. * Gets exposure used in the effect.
  95967. */
  95968. /**
  95969. * Sets exposure used in the effect.
  95970. */
  95971. exposure: number;
  95972. /**
  95973. * Gets wether tonemapping is enabled or not.
  95974. */
  95975. /**
  95976. * Sets wether tonemapping is enabled or not
  95977. */
  95978. toneMappingEnabled: boolean;
  95979. /**
  95980. * Gets the type of tone mapping effect.
  95981. */
  95982. /**
  95983. * Sets the type of tone mapping effect.
  95984. */
  95985. toneMappingType: number;
  95986. /**
  95987. * Gets contrast used in the effect.
  95988. */
  95989. /**
  95990. * Sets contrast used in the effect.
  95991. */
  95992. contrast: number;
  95993. /**
  95994. * Gets Vignette stretch size.
  95995. */
  95996. /**
  95997. * Sets Vignette stretch size.
  95998. */
  95999. vignetteStretch: number;
  96000. /**
  96001. * Gets Vignette centre X Offset.
  96002. */
  96003. /**
  96004. * Sets Vignette centre X Offset.
  96005. */
  96006. vignetteCentreX: number;
  96007. /**
  96008. * Gets Vignette centre Y Offset.
  96009. */
  96010. /**
  96011. * Sets Vignette centre Y Offset.
  96012. */
  96013. vignetteCentreY: number;
  96014. /**
  96015. * Gets Vignette weight or intensity of the vignette effect.
  96016. */
  96017. /**
  96018. * Sets Vignette weight or intensity of the vignette effect.
  96019. */
  96020. vignetteWeight: number;
  96021. /**
  96022. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96023. * if vignetteEnabled is set to true.
  96024. */
  96025. /**
  96026. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  96027. * if vignetteEnabled is set to true.
  96028. */
  96029. vignetteColor: Color4;
  96030. /**
  96031. * Gets Camera field of view used by the Vignette effect.
  96032. */
  96033. /**
  96034. * Sets Camera field of view used by the Vignette effect.
  96035. */
  96036. vignetteCameraFov: number;
  96037. /**
  96038. * Gets the vignette blend mode allowing different kind of effect.
  96039. */
  96040. /**
  96041. * Sets the vignette blend mode allowing different kind of effect.
  96042. */
  96043. vignetteBlendMode: number;
  96044. /**
  96045. * Gets wether the vignette effect is enabled.
  96046. */
  96047. /**
  96048. * Sets wether the vignette effect is enabled.
  96049. */
  96050. vignetteEnabled: boolean;
  96051. private _fromLinearSpace;
  96052. /**
  96053. * Gets wether the input of the processing is in Gamma or Linear Space.
  96054. */
  96055. /**
  96056. * Sets wether the input of the processing is in Gamma or Linear Space.
  96057. */
  96058. fromLinearSpace: boolean;
  96059. /**
  96060. * Defines cache preventing GC.
  96061. */
  96062. private _defines;
  96063. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  96064. /**
  96065. * "ImageProcessingPostProcess"
  96066. * @returns "ImageProcessingPostProcess"
  96067. */
  96068. getClassName(): string;
  96069. protected _updateParameters(): void;
  96070. dispose(camera?: Camera): void;
  96071. }
  96072. }
  96073. declare module BABYLON {
  96074. /**
  96075. * Class containing static functions to help procedurally build meshes
  96076. */
  96077. export class GroundBuilder {
  96078. /**
  96079. * Creates a ground mesh
  96080. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  96081. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  96082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96083. * @param name defines the name of the mesh
  96084. * @param options defines the options used to create the mesh
  96085. * @param scene defines the hosting scene
  96086. * @returns the ground mesh
  96087. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  96088. */
  96089. static CreateGround(name: string, options: {
  96090. width?: number;
  96091. height?: number;
  96092. subdivisions?: number;
  96093. subdivisionsX?: number;
  96094. subdivisionsY?: number;
  96095. updatable?: boolean;
  96096. }, scene: any): Mesh;
  96097. /**
  96098. * Creates a tiled ground mesh
  96099. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  96100. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  96101. * * 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
  96102. * * 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
  96103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96104. * @param name defines the name of the mesh
  96105. * @param options defines the options used to create the mesh
  96106. * @param scene defines the hosting scene
  96107. * @returns the tiled ground mesh
  96108. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  96109. */
  96110. static CreateTiledGround(name: string, options: {
  96111. xmin: number;
  96112. zmin: number;
  96113. xmax: number;
  96114. zmax: number;
  96115. subdivisions?: {
  96116. w: number;
  96117. h: number;
  96118. };
  96119. precision?: {
  96120. w: number;
  96121. h: number;
  96122. };
  96123. updatable?: boolean;
  96124. }, scene: Scene): Mesh;
  96125. /**
  96126. * Creates a ground mesh from a height map
  96127. * * The parameter `url` sets the URL of the height map image resource.
  96128. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  96129. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  96130. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  96131. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  96132. * * 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.
  96133. * * 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).
  96134. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96136. * @param name defines the name of the mesh
  96137. * @param url defines the url to the height map
  96138. * @param options defines the options used to create the mesh
  96139. * @param scene defines the hosting scene
  96140. * @returns the ground mesh
  96141. * @see https://doc.babylonjs.com/babylon101/height_map
  96142. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  96143. */
  96144. static CreateGroundFromHeightMap(name: string, url: string, options: {
  96145. width?: number;
  96146. height?: number;
  96147. subdivisions?: number;
  96148. minHeight?: number;
  96149. maxHeight?: number;
  96150. colorFilter?: Color3;
  96151. alphaFilter?: number;
  96152. updatable?: boolean;
  96153. onReady?: (mesh: GroundMesh) => void;
  96154. }, scene: Scene): GroundMesh;
  96155. }
  96156. }
  96157. declare module BABYLON {
  96158. /**
  96159. * Class containing static functions to help procedurally build meshes
  96160. */
  96161. export class TorusBuilder {
  96162. /**
  96163. * Creates a torus mesh
  96164. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  96165. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  96166. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  96167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96170. * @param name defines the name of the mesh
  96171. * @param options defines the options used to create the mesh
  96172. * @param scene defines the hosting scene
  96173. * @returns the torus mesh
  96174. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  96175. */
  96176. static CreateTorus(name: string, options: {
  96177. diameter?: number;
  96178. thickness?: number;
  96179. tessellation?: number;
  96180. updatable?: boolean;
  96181. sideOrientation?: number;
  96182. frontUVs?: Vector4;
  96183. backUVs?: Vector4;
  96184. }, scene: any): Mesh;
  96185. }
  96186. }
  96187. declare module BABYLON {
  96188. /**
  96189. * Class containing static functions to help procedurally build meshes
  96190. */
  96191. export class CylinderBuilder {
  96192. /**
  96193. * Creates a cylinder or a cone mesh
  96194. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  96195. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  96196. * * 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.
  96197. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  96198. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  96199. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  96200. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  96201. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  96202. * * 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).
  96203. * * 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
  96204. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  96205. * * 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
  96206. * * 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.
  96207. * * If `enclose` is false, a ring surface is one element.
  96208. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  96209. * * 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
  96210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96213. * @param name defines the name of the mesh
  96214. * @param options defines the options used to create the mesh
  96215. * @param scene defines the hosting scene
  96216. * @returns the cylinder mesh
  96217. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  96218. */
  96219. static CreateCylinder(name: string, options: {
  96220. height?: number;
  96221. diameterTop?: number;
  96222. diameterBottom?: number;
  96223. diameter?: number;
  96224. tessellation?: number;
  96225. subdivisions?: number;
  96226. arc?: number;
  96227. faceColors?: Color4[];
  96228. faceUV?: Vector4[];
  96229. updatable?: boolean;
  96230. hasRings?: boolean;
  96231. enclose?: boolean;
  96232. sideOrientation?: number;
  96233. frontUVs?: Vector4;
  96234. backUVs?: Vector4;
  96235. }, scene: any): Mesh;
  96236. }
  96237. }
  96238. declare module BABYLON {
  96239. /**
  96240. * Manager for handling gamepads
  96241. */
  96242. export class GamepadManager {
  96243. private _scene?;
  96244. private _babylonGamepads;
  96245. private _oneGamepadConnected;
  96246. /** @hidden */
  96247. _isMonitoring: boolean;
  96248. private _gamepadEventSupported;
  96249. private _gamepadSupport;
  96250. /**
  96251. * observable to be triggered when the gamepad controller has been connected
  96252. */
  96253. onGamepadConnectedObservable: Observable<Gamepad>;
  96254. /**
  96255. * observable to be triggered when the gamepad controller has been disconnected
  96256. */
  96257. onGamepadDisconnectedObservable: Observable<Gamepad>;
  96258. private _onGamepadConnectedEvent;
  96259. private _onGamepadDisconnectedEvent;
  96260. /**
  96261. * Initializes the gamepad manager
  96262. * @param _scene BabylonJS scene
  96263. */
  96264. constructor(_scene?: Scene | undefined);
  96265. /**
  96266. * The gamepads in the game pad manager
  96267. */
  96268. readonly gamepads: Gamepad[];
  96269. /**
  96270. * Get the gamepad controllers based on type
  96271. * @param type The type of gamepad controller
  96272. * @returns Nullable gamepad
  96273. */
  96274. getGamepadByType(type?: number): Nullable<Gamepad>;
  96275. /**
  96276. * Disposes the gamepad manager
  96277. */
  96278. dispose(): void;
  96279. private _addNewGamepad;
  96280. private _startMonitoringGamepads;
  96281. private _stopMonitoringGamepads;
  96282. /** @hidden */
  96283. _checkGamepadsStatus(): void;
  96284. private _updateGamepadObjects;
  96285. }
  96286. }
  96287. declare module BABYLON {
  96288. interface Scene {
  96289. /** @hidden */
  96290. _gamepadManager: Nullable<GamepadManager>;
  96291. /**
  96292. * Gets the gamepad manager associated with the scene
  96293. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  96294. */
  96295. gamepadManager: GamepadManager;
  96296. }
  96297. /**
  96298. * Interface representing a free camera inputs manager
  96299. */
  96300. interface FreeCameraInputsManager {
  96301. /**
  96302. * Adds gamepad input support to the FreeCameraInputsManager.
  96303. * @returns the FreeCameraInputsManager
  96304. */
  96305. addGamepad(): FreeCameraInputsManager;
  96306. }
  96307. /**
  96308. * Interface representing an arc rotate camera inputs manager
  96309. */
  96310. interface ArcRotateCameraInputsManager {
  96311. /**
  96312. * Adds gamepad input support to the ArcRotateCamera InputManager.
  96313. * @returns the camera inputs manager
  96314. */
  96315. addGamepad(): ArcRotateCameraInputsManager;
  96316. }
  96317. /**
  96318. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  96319. */
  96320. export class GamepadSystemSceneComponent implements ISceneComponent {
  96321. /**
  96322. * The component name helpfull to identify the component in the list of scene components.
  96323. */
  96324. readonly name: string;
  96325. /**
  96326. * The scene the component belongs to.
  96327. */
  96328. scene: Scene;
  96329. /**
  96330. * Creates a new instance of the component for the given scene
  96331. * @param scene Defines the scene to register the component in
  96332. */
  96333. constructor(scene: Scene);
  96334. /**
  96335. * Registers the component in a given scene
  96336. */
  96337. register(): void;
  96338. /**
  96339. * Rebuilds the elements related to this component in case of
  96340. * context lost for instance.
  96341. */
  96342. rebuild(): void;
  96343. /**
  96344. * Disposes the component and the associated ressources
  96345. */
  96346. dispose(): void;
  96347. private _beforeCameraUpdate;
  96348. }
  96349. }
  96350. declare module BABYLON {
  96351. /**
  96352. * Options to modify the vr teleportation behavior.
  96353. */
  96354. export interface VRTeleportationOptions {
  96355. /**
  96356. * The name of the mesh which should be used as the teleportation floor. (default: null)
  96357. */
  96358. floorMeshName?: string;
  96359. /**
  96360. * A list of meshes to be used as the teleportation floor. (default: empty)
  96361. */
  96362. floorMeshes?: Mesh[];
  96363. }
  96364. /**
  96365. * Options to modify the vr experience helper's behavior.
  96366. */
  96367. export interface VRExperienceHelperOptions extends WebVROptions {
  96368. /**
  96369. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  96370. */
  96371. createDeviceOrientationCamera?: boolean;
  96372. /**
  96373. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  96374. */
  96375. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  96376. /**
  96377. * Uses the main button on the controller to toggle the laser casted. (default: true)
  96378. */
  96379. laserToggle?: boolean;
  96380. /**
  96381. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  96382. */
  96383. floorMeshes?: Mesh[];
  96384. /**
  96385. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  96386. */
  96387. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  96388. }
  96389. /**
  96390. * Event containing information after VR has been entered
  96391. */
  96392. export class OnAfterEnteringVRObservableEvent {
  96393. /**
  96394. * If entering vr was successful
  96395. */
  96396. success: boolean;
  96397. }
  96398. /**
  96399. * Helps to quickly add VR support to an existing scene.
  96400. * See http://doc.babylonjs.com/how_to/webvr_helper
  96401. */
  96402. export class VRExperienceHelper {
  96403. /** Options to modify the vr experience helper's behavior. */
  96404. webVROptions: VRExperienceHelperOptions;
  96405. private _scene;
  96406. private _position;
  96407. private _btnVR;
  96408. private _btnVRDisplayed;
  96409. private _webVRsupported;
  96410. private _webVRready;
  96411. private _webVRrequesting;
  96412. private _webVRpresenting;
  96413. private _hasEnteredVR;
  96414. private _fullscreenVRpresenting;
  96415. private _canvas;
  96416. private _webVRCamera;
  96417. private _vrDeviceOrientationCamera;
  96418. private _deviceOrientationCamera;
  96419. private _existingCamera;
  96420. private _onKeyDown;
  96421. private _onVrDisplayPresentChange;
  96422. private _onVRDisplayChanged;
  96423. private _onVRRequestPresentStart;
  96424. private _onVRRequestPresentComplete;
  96425. /**
  96426. * Observable raised right before entering VR.
  96427. */
  96428. onEnteringVRObservable: Observable<VRExperienceHelper>;
  96429. /**
  96430. * Observable raised when entering VR has completed.
  96431. */
  96432. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  96433. /**
  96434. * Observable raised when exiting VR.
  96435. */
  96436. onExitingVRObservable: Observable<VRExperienceHelper>;
  96437. /**
  96438. * Observable raised when controller mesh is loaded.
  96439. */
  96440. onControllerMeshLoadedObservable: Observable<WebVRController>;
  96441. /** Return this.onEnteringVRObservable
  96442. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  96443. */
  96444. readonly onEnteringVR: Observable<VRExperienceHelper>;
  96445. /** Return this.onExitingVRObservable
  96446. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  96447. */
  96448. readonly onExitingVR: Observable<VRExperienceHelper>;
  96449. /** Return this.onControllerMeshLoadedObservable
  96450. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  96451. */
  96452. readonly onControllerMeshLoaded: Observable<WebVRController>;
  96453. private _rayLength;
  96454. private _useCustomVRButton;
  96455. private _teleportationRequested;
  96456. private _teleportActive;
  96457. private _floorMeshName;
  96458. private _floorMeshesCollection;
  96459. private _rotationAllowed;
  96460. private _teleportBackwardsVector;
  96461. private _teleportationTarget;
  96462. private _isDefaultTeleportationTarget;
  96463. private _postProcessMove;
  96464. private _teleportationFillColor;
  96465. private _teleportationBorderColor;
  96466. private _rotationAngle;
  96467. private _haloCenter;
  96468. private _cameraGazer;
  96469. private _padSensibilityUp;
  96470. private _padSensibilityDown;
  96471. private _leftController;
  96472. private _rightController;
  96473. /**
  96474. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  96475. */
  96476. onNewMeshSelected: Observable<AbstractMesh>;
  96477. /**
  96478. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  96479. */
  96480. onNewMeshPicked: Observable<PickingInfo>;
  96481. private _circleEase;
  96482. /**
  96483. * Observable raised before camera teleportation
  96484. */
  96485. onBeforeCameraTeleport: Observable<Vector3>;
  96486. /**
  96487. * Observable raised after camera teleportation
  96488. */
  96489. onAfterCameraTeleport: Observable<Vector3>;
  96490. /**
  96491. * Observable raised when current selected mesh gets unselected
  96492. */
  96493. onSelectedMeshUnselected: Observable<AbstractMesh>;
  96494. private _raySelectionPredicate;
  96495. /**
  96496. * To be optionaly changed by user to define custom ray selection
  96497. */
  96498. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  96499. /**
  96500. * To be optionaly changed by user to define custom selection logic (after ray selection)
  96501. */
  96502. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  96503. /**
  96504. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  96505. */
  96506. teleportationEnabled: boolean;
  96507. private _defaultHeight;
  96508. private _teleportationInitialized;
  96509. private _interactionsEnabled;
  96510. private _interactionsRequested;
  96511. private _displayGaze;
  96512. private _displayLaserPointer;
  96513. /**
  96514. * The mesh used to display where the user is going to teleport.
  96515. */
  96516. /**
  96517. * Sets the mesh to be used to display where the user is going to teleport.
  96518. */
  96519. teleportationTarget: Mesh;
  96520. /**
  96521. * 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
  96522. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  96523. * See http://doc.babylonjs.com/resources/baking_transformations
  96524. */
  96525. gazeTrackerMesh: Mesh;
  96526. /**
  96527. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  96528. */
  96529. updateGazeTrackerScale: boolean;
  96530. /**
  96531. * If the gaze trackers color should be updated when selecting meshes
  96532. */
  96533. updateGazeTrackerColor: boolean;
  96534. /**
  96535. * The gaze tracking mesh corresponding to the left controller
  96536. */
  96537. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  96538. /**
  96539. * The gaze tracking mesh corresponding to the right controller
  96540. */
  96541. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  96542. /**
  96543. * If the ray of the gaze should be displayed.
  96544. */
  96545. /**
  96546. * Sets if the ray of the gaze should be displayed.
  96547. */
  96548. displayGaze: boolean;
  96549. /**
  96550. * If the ray of the LaserPointer should be displayed.
  96551. */
  96552. /**
  96553. * Sets if the ray of the LaserPointer should be displayed.
  96554. */
  96555. displayLaserPointer: boolean;
  96556. /**
  96557. * The deviceOrientationCamera used as the camera when not in VR.
  96558. */
  96559. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  96560. /**
  96561. * Based on the current WebVR support, returns the current VR camera used.
  96562. */
  96563. readonly currentVRCamera: Nullable<Camera>;
  96564. /**
  96565. * The webVRCamera which is used when in VR.
  96566. */
  96567. readonly webVRCamera: WebVRFreeCamera;
  96568. /**
  96569. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  96570. */
  96571. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  96572. private readonly _teleportationRequestInitiated;
  96573. /**
  96574. * Defines wether or not Pointer lock should be requested when switching to
  96575. * full screen.
  96576. */
  96577. requestPointerLockOnFullScreen: boolean;
  96578. /**
  96579. * Instantiates a VRExperienceHelper.
  96580. * Helps to quickly add VR support to an existing scene.
  96581. * @param scene The scene the VRExperienceHelper belongs to.
  96582. * @param webVROptions Options to modify the vr experience helper's behavior.
  96583. */
  96584. constructor(scene: Scene,
  96585. /** Options to modify the vr experience helper's behavior. */
  96586. webVROptions?: VRExperienceHelperOptions);
  96587. private _onDefaultMeshLoaded;
  96588. private _onResize;
  96589. private _onFullscreenChange;
  96590. /**
  96591. * Gets a value indicating if we are currently in VR mode.
  96592. */
  96593. readonly isInVRMode: boolean;
  96594. private onVrDisplayPresentChange;
  96595. private onVRDisplayChanged;
  96596. private moveButtonToBottomRight;
  96597. private displayVRButton;
  96598. private updateButtonVisibility;
  96599. private _cachedAngularSensibility;
  96600. /**
  96601. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  96602. * Otherwise, will use the fullscreen API.
  96603. */
  96604. enterVR(): void;
  96605. /**
  96606. * Attempt to exit VR, or fullscreen.
  96607. */
  96608. exitVR(): void;
  96609. /**
  96610. * The position of the vr experience helper.
  96611. */
  96612. /**
  96613. * Sets the position of the vr experience helper.
  96614. */
  96615. position: Vector3;
  96616. /**
  96617. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  96618. */
  96619. enableInteractions(): void;
  96620. private readonly _noControllerIsActive;
  96621. private beforeRender;
  96622. private _isTeleportationFloor;
  96623. /**
  96624. * Adds a floor mesh to be used for teleportation.
  96625. * @param floorMesh the mesh to be used for teleportation.
  96626. */
  96627. addFloorMesh(floorMesh: Mesh): void;
  96628. /**
  96629. * Removes a floor mesh from being used for teleportation.
  96630. * @param floorMesh the mesh to be removed.
  96631. */
  96632. removeFloorMesh(floorMesh: Mesh): void;
  96633. /**
  96634. * Enables interactions and teleportation using the VR controllers and gaze.
  96635. * @param vrTeleportationOptions options to modify teleportation behavior.
  96636. */
  96637. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  96638. private _onNewGamepadConnected;
  96639. private _tryEnableInteractionOnController;
  96640. private _onNewGamepadDisconnected;
  96641. private _enableInteractionOnController;
  96642. private _checkTeleportWithRay;
  96643. private _checkRotate;
  96644. private _checkTeleportBackwards;
  96645. private _enableTeleportationOnController;
  96646. private _createTeleportationCircles;
  96647. private _displayTeleportationTarget;
  96648. private _hideTeleportationTarget;
  96649. private _rotateCamera;
  96650. private _moveTeleportationSelectorTo;
  96651. private _workingVector;
  96652. private _workingQuaternion;
  96653. private _workingMatrix;
  96654. /**
  96655. * Teleports the users feet to the desired location
  96656. * @param location The location where the user's feet should be placed
  96657. */
  96658. teleportCamera(location: Vector3): void;
  96659. private _convertNormalToDirectionOfRay;
  96660. private _castRayAndSelectObject;
  96661. private _notifySelectedMeshUnselected;
  96662. /**
  96663. * Sets the color of the laser ray from the vr controllers.
  96664. * @param color new color for the ray.
  96665. */
  96666. changeLaserColor(color: Color3): void;
  96667. /**
  96668. * Sets the color of the ray from the vr headsets gaze.
  96669. * @param color new color for the ray.
  96670. */
  96671. changeGazeColor(color: Color3): void;
  96672. /**
  96673. * Exits VR and disposes of the vr experience helper
  96674. */
  96675. dispose(): void;
  96676. /**
  96677. * Gets the name of the VRExperienceHelper class
  96678. * @returns "VRExperienceHelper"
  96679. */
  96680. getClassName(): string;
  96681. }
  96682. }
  96683. declare module BABYLON {
  96684. /**
  96685. * Manages an XRSession
  96686. * @see https://doc.babylonjs.com/how_to/webxr
  96687. */
  96688. export class WebXRSessionManager implements IDisposable {
  96689. private scene;
  96690. /**
  96691. * Fires every time a new xrFrame arrives which can be used to update the camera
  96692. */
  96693. onXRFrameObservable: Observable<any>;
  96694. /**
  96695. * Fires when the xr session is ended either by the device or manually done
  96696. */
  96697. onXRSessionEnded: Observable<any>;
  96698. /** @hidden */
  96699. _xrSession: XRSession;
  96700. /** @hidden */
  96701. _frameOfReference: XRFrameOfReference;
  96702. /** @hidden */
  96703. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  96704. /** @hidden */
  96705. _currentXRFrame: Nullable<XRFrame>;
  96706. private _xrNavigator;
  96707. private _xrDevice;
  96708. private _tmpMatrix;
  96709. /**
  96710. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  96711. * @param scene The scene which the session should be created for
  96712. */
  96713. constructor(scene: Scene);
  96714. /**
  96715. * Initializes the manager
  96716. * After initialization enterXR can be called to start an XR session
  96717. * @returns Promise which resolves after it is initialized
  96718. */
  96719. initializeAsync(): Promise<void>;
  96720. /**
  96721. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  96722. * @param sessionCreationOptions xr options to create the session with
  96723. * @param frameOfReferenceType option to configure how the xr pose is expressed
  96724. * @returns Promise which resolves after it enters XR
  96725. */
  96726. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  96727. /**
  96728. * Stops the xrSession and restores the renderloop
  96729. * @returns Promise which resolves after it exits XR
  96730. */
  96731. exitXRAsync(): Promise<void>;
  96732. /**
  96733. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96734. * @param ray ray to cast into the environment
  96735. * @returns Promise which resolves with a collision point in the environment if it exists
  96736. */
  96737. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96738. /**
  96739. * Checks if a session would be supported for the creation options specified
  96740. * @param options creation options to check if they are supported
  96741. * @returns true if supported
  96742. */
  96743. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96744. /**
  96745. * @hidden
  96746. * Converts the render layer of xrSession to a render target
  96747. * @param session session to create render target for
  96748. * @param scene scene the new render target should be created for
  96749. */
  96750. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  96751. /**
  96752. * Disposes of the session manager
  96753. */
  96754. dispose(): void;
  96755. }
  96756. }
  96757. declare module BABYLON {
  96758. /**
  96759. * WebXR Camera which holds the views for the xrSession
  96760. * @see https://doc.babylonjs.com/how_to/webxr
  96761. */
  96762. export class WebXRCamera extends FreeCamera {
  96763. private static _TmpMatrix;
  96764. /**
  96765. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  96766. * @param name the name of the camera
  96767. * @param scene the scene to add the camera to
  96768. */
  96769. constructor(name: string, scene: Scene);
  96770. private _updateNumberOfRigCameras;
  96771. /** @hidden */
  96772. _updateForDualEyeDebugging(pupilDistance?: number): void;
  96773. /**
  96774. * Updates the cameras position from the current pose information of the XR session
  96775. * @param xrSessionManager the session containing pose information
  96776. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  96777. */
  96778. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  96779. }
  96780. }
  96781. declare module BABYLON {
  96782. /**
  96783. * States of the webXR experience
  96784. */
  96785. export enum WebXRState {
  96786. /**
  96787. * Transitioning to being in XR mode
  96788. */
  96789. ENTERING_XR = 0,
  96790. /**
  96791. * Transitioning to non XR mode
  96792. */
  96793. EXITING_XR = 1,
  96794. /**
  96795. * In XR mode and presenting
  96796. */
  96797. IN_XR = 2,
  96798. /**
  96799. * Not entered XR mode
  96800. */
  96801. NOT_IN_XR = 3
  96802. }
  96803. /**
  96804. * Helper class used to enable XR
  96805. * @see https://doc.babylonjs.com/how_to/webxr
  96806. */
  96807. export class WebXRExperienceHelper implements IDisposable {
  96808. private scene;
  96809. /**
  96810. * 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
  96811. */
  96812. container: AbstractMesh;
  96813. /**
  96814. * Camera used to render xr content
  96815. */
  96816. camera: WebXRCamera;
  96817. /**
  96818. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  96819. */
  96820. state: WebXRState;
  96821. private _setState;
  96822. private static _TmpVector;
  96823. /**
  96824. * Fires when the state of the experience helper has changed
  96825. */
  96826. onStateChangedObservable: Observable<WebXRState>;
  96827. /** @hidden */
  96828. _sessionManager: WebXRSessionManager;
  96829. private _nonVRCamera;
  96830. private _originalSceneAutoClear;
  96831. private _supported;
  96832. /**
  96833. * Creates the experience helper
  96834. * @param scene the scene to attach the experience helper to
  96835. * @returns a promise for the experience helper
  96836. */
  96837. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  96838. /**
  96839. * Creates a WebXRExperienceHelper
  96840. * @param scene The scene the helper should be created in
  96841. */
  96842. private constructor();
  96843. /**
  96844. * Exits XR mode and returns the scene to its original state
  96845. * @returns promise that resolves after xr mode has exited
  96846. */
  96847. exitXRAsync(): Promise<void>;
  96848. /**
  96849. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  96850. * @param sessionCreationOptions options for the XR session
  96851. * @param frameOfReference frame of reference of the XR session
  96852. * @returns promise that resolves after xr mode has entered
  96853. */
  96854. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  96855. /**
  96856. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  96857. * @param ray ray to cast into the environment
  96858. * @returns Promise which resolves with a collision point in the environment if it exists
  96859. */
  96860. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  96861. /**
  96862. * Updates the global position of the camera by moving the camera's container
  96863. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  96864. * @param position The desired global position of the camera
  96865. */
  96866. setPositionOfCameraUsingContainer(position: Vector3): void;
  96867. /**
  96868. * Rotates the xr camera by rotating the camera's container around the camera's position
  96869. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  96870. * @param rotation the desired quaternion rotation to apply to the camera
  96871. */
  96872. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  96873. /**
  96874. * Checks if the creation options are supported by the xr session
  96875. * @param options creation options
  96876. * @returns true if supported
  96877. */
  96878. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  96879. /**
  96880. * Disposes of the experience helper
  96881. */
  96882. dispose(): void;
  96883. }
  96884. }
  96885. declare module BABYLON {
  96886. /**
  96887. * Button which can be used to enter a different mode of XR
  96888. */
  96889. export class WebXREnterExitUIButton {
  96890. /** button element */
  96891. element: HTMLElement;
  96892. /** XR initialization options for the button */
  96893. initializationOptions: XRSessionCreationOptions;
  96894. /**
  96895. * Creates a WebXREnterExitUIButton
  96896. * @param element button element
  96897. * @param initializationOptions XR initialization options for the button
  96898. */
  96899. constructor(
  96900. /** button element */
  96901. element: HTMLElement,
  96902. /** XR initialization options for the button */
  96903. initializationOptions: XRSessionCreationOptions);
  96904. /**
  96905. * Overwritable function which can be used to update the button's visuals when the state changes
  96906. * @param activeButton the current active button in the UI
  96907. */
  96908. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  96909. }
  96910. /**
  96911. * Options to create the webXR UI
  96912. */
  96913. export class WebXREnterExitUIOptions {
  96914. /**
  96915. * Context to enter xr with
  96916. */
  96917. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  96918. /**
  96919. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  96920. */
  96921. customButtons?: Array<WebXREnterExitUIButton>;
  96922. }
  96923. /**
  96924. * UI to allow the user to enter/exit XR mode
  96925. */
  96926. export class WebXREnterExitUI implements IDisposable {
  96927. private scene;
  96928. private _overlay;
  96929. private _buttons;
  96930. private _activeButton;
  96931. /**
  96932. * Fired every time the active button is changed.
  96933. *
  96934. * When xr is entered via a button that launches xr that button will be the callback parameter
  96935. *
  96936. * When exiting xr the callback parameter will be null)
  96937. */
  96938. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  96939. /**
  96940. * Creates UI to allow the user to enter/exit XR mode
  96941. * @param scene the scene to add the ui to
  96942. * @param helper the xr experience helper to enter/exit xr with
  96943. * @param options options to configure the UI
  96944. * @returns the created ui
  96945. */
  96946. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  96947. private constructor();
  96948. private _updateButtons;
  96949. /**
  96950. * Disposes of the object
  96951. */
  96952. dispose(): void;
  96953. }
  96954. }
  96955. declare module BABYLON {
  96956. /**
  96957. * Represents an XR input
  96958. */
  96959. export class WebXRController {
  96960. /**
  96961. * 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
  96962. */
  96963. grip?: AbstractMesh;
  96964. /**
  96965. * Pointer which can be used to select objects or attach a visible laser to
  96966. */
  96967. pointer: AbstractMesh;
  96968. /**
  96969. * Creates the controller
  96970. * @see https://doc.babylonjs.com/how_to/webxr
  96971. * @param scene the scene which the controller should be associated to
  96972. */
  96973. constructor(scene: Scene);
  96974. /**
  96975. * Disposes of the object
  96976. */
  96977. dispose(): void;
  96978. }
  96979. /**
  96980. * XR input used to track XR inputs such as controllers/rays
  96981. */
  96982. export class WebXRInput implements IDisposable {
  96983. private helper;
  96984. /**
  96985. * XR controllers being tracked
  96986. */
  96987. controllers: Array<WebXRController>;
  96988. private _tmpMatrix;
  96989. private _frameObserver;
  96990. /**
  96991. * Initializes the WebXRInput
  96992. * @param helper experience helper which the input should be created for
  96993. */
  96994. constructor(helper: WebXRExperienceHelper);
  96995. /**
  96996. * Disposes of the object
  96997. */
  96998. dispose(): void;
  96999. }
  97000. }
  97001. declare module BABYLON {
  97002. /**
  97003. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  97004. */
  97005. export class WebXRManagedOutputCanvas implements IDisposable {
  97006. private _canvas;
  97007. /**
  97008. * xrpresent context of the canvas which can be used to display/mirror xr content
  97009. */
  97010. canvasContext: Nullable<WebGLRenderingContext>;
  97011. /**
  97012. * Initializes the canvas to be added/removed upon entering/exiting xr
  97013. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  97014. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  97015. */
  97016. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  97017. /**
  97018. * Disposes of the object
  97019. */
  97020. dispose(): void;
  97021. private _setManagedOutputCanvas;
  97022. private _addCanvas;
  97023. private _removeCanvas;
  97024. }
  97025. }
  97026. declare module BABYLON {
  97027. /**
  97028. * Contains an array of blocks representing the octree
  97029. */
  97030. export interface IOctreeContainer<T> {
  97031. /**
  97032. * Blocks within the octree
  97033. */
  97034. blocks: Array<OctreeBlock<T>>;
  97035. }
  97036. /**
  97037. * Class used to store a cell in an octree
  97038. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97039. */
  97040. export class OctreeBlock<T> {
  97041. /**
  97042. * Gets the content of the current block
  97043. */
  97044. entries: T[];
  97045. /**
  97046. * Gets the list of block children
  97047. */
  97048. blocks: Array<OctreeBlock<T>>;
  97049. private _depth;
  97050. private _maxDepth;
  97051. private _capacity;
  97052. private _minPoint;
  97053. private _maxPoint;
  97054. private _boundingVectors;
  97055. private _creationFunc;
  97056. /**
  97057. * Creates a new block
  97058. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  97059. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  97060. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97061. * @param depth defines the current depth of this block in the octree
  97062. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  97063. * @param creationFunc defines a callback to call when an element is added to the block
  97064. */
  97065. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  97066. /**
  97067. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  97068. */
  97069. readonly capacity: number;
  97070. /**
  97071. * Gets the minimum vector (in world space) of the block's bounding box
  97072. */
  97073. readonly minPoint: Vector3;
  97074. /**
  97075. * Gets the maximum vector (in world space) of the block's bounding box
  97076. */
  97077. readonly maxPoint: Vector3;
  97078. /**
  97079. * Add a new element to this block
  97080. * @param entry defines the element to add
  97081. */
  97082. addEntry(entry: T): void;
  97083. /**
  97084. * Remove an element from this block
  97085. * @param entry defines the element to remove
  97086. */
  97087. removeEntry(entry: T): void;
  97088. /**
  97089. * Add an array of elements to this block
  97090. * @param entries defines the array of elements to add
  97091. */
  97092. addEntries(entries: T[]): void;
  97093. /**
  97094. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  97095. * @param frustumPlanes defines the frustum planes to test
  97096. * @param selection defines the array to store current content if selection is positive
  97097. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97098. */
  97099. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97100. /**
  97101. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  97102. * @param sphereCenter defines the bounding sphere center
  97103. * @param sphereRadius defines the bounding sphere radius
  97104. * @param selection defines the array to store current content if selection is positive
  97105. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97106. */
  97107. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  97108. /**
  97109. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  97110. * @param ray defines the ray to test with
  97111. * @param selection defines the array to store current content if selection is positive
  97112. */
  97113. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  97114. /**
  97115. * Subdivide the content into child blocks (this block will then be empty)
  97116. */
  97117. createInnerBlocks(): void;
  97118. /**
  97119. * @hidden
  97120. */
  97121. 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;
  97122. }
  97123. }
  97124. declare module BABYLON {
  97125. /**
  97126. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  97127. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97128. */
  97129. export class Octree<T> {
  97130. /** 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.) */
  97131. maxDepth: number;
  97132. /**
  97133. * Blocks within the octree containing objects
  97134. */
  97135. blocks: Array<OctreeBlock<T>>;
  97136. /**
  97137. * Content stored in the octree
  97138. */
  97139. dynamicContent: T[];
  97140. private _maxBlockCapacity;
  97141. private _selectionContent;
  97142. private _creationFunc;
  97143. /**
  97144. * Creates a octree
  97145. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97146. * @param creationFunc function to be used to instatiate the octree
  97147. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  97148. * @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.)
  97149. */
  97150. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  97151. /** 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.) */
  97152. maxDepth?: number);
  97153. /**
  97154. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  97155. * @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);
  97156. * @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);
  97157. * @param entries meshes to be added to the octree blocks
  97158. */
  97159. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  97160. /**
  97161. * Adds a mesh to the octree
  97162. * @param entry Mesh to add to the octree
  97163. */
  97164. addMesh(entry: T): void;
  97165. /**
  97166. * Remove an element from the octree
  97167. * @param entry defines the element to remove
  97168. */
  97169. removeMesh(entry: T): void;
  97170. /**
  97171. * Selects an array of meshes within the frustum
  97172. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  97173. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  97174. * @returns array of meshes within the frustum
  97175. */
  97176. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  97177. /**
  97178. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  97179. * @param sphereCenter defines the bounding sphere center
  97180. * @param sphereRadius defines the bounding sphere radius
  97181. * @param allowDuplicate defines if the selection array can contains duplicated entries
  97182. * @returns an array of objects that intersect the sphere
  97183. */
  97184. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  97185. /**
  97186. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  97187. * @param ray defines the ray to test with
  97188. * @returns array of intersected objects
  97189. */
  97190. intersectsRay(ray: Ray): SmartArray<T>;
  97191. /**
  97192. * Adds a mesh into the octree block if it intersects the block
  97193. */
  97194. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  97195. /**
  97196. * Adds a submesh into the octree block if it intersects the block
  97197. */
  97198. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  97199. }
  97200. }
  97201. declare module BABYLON {
  97202. interface Scene {
  97203. /**
  97204. * @hidden
  97205. * Backing Filed
  97206. */
  97207. _selectionOctree: Octree<AbstractMesh>;
  97208. /**
  97209. * Gets the octree used to boost mesh selection (picking)
  97210. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97211. */
  97212. selectionOctree: Octree<AbstractMesh>;
  97213. /**
  97214. * Creates or updates the octree used to boost selection (picking)
  97215. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97216. * @param maxCapacity defines the maximum capacity per leaf
  97217. * @param maxDepth defines the maximum depth of the octree
  97218. * @returns an octree of AbstractMesh
  97219. */
  97220. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  97221. }
  97222. interface AbstractMesh {
  97223. /**
  97224. * @hidden
  97225. * Backing Field
  97226. */
  97227. _submeshesOctree: Octree<SubMesh>;
  97228. /**
  97229. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  97230. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97231. * @param maxCapacity defines the maximum size of each block (64 by default)
  97232. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  97233. * @returns the new octree
  97234. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  97235. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  97236. */
  97237. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  97238. }
  97239. /**
  97240. * Defines the octree scene component responsible to manage any octrees
  97241. * in a given scene.
  97242. */
  97243. export class OctreeSceneComponent {
  97244. /**
  97245. * The component name helpfull to identify the component in the list of scene components.
  97246. */
  97247. readonly name: string;
  97248. /**
  97249. * The scene the component belongs to.
  97250. */
  97251. scene: Scene;
  97252. /**
  97253. * Indicates if the meshes have been checked to make sure they are isEnabled()
  97254. */
  97255. readonly checksIsEnabled: boolean;
  97256. /**
  97257. * Creates a new instance of the component for the given scene
  97258. * @param scene Defines the scene to register the component in
  97259. */
  97260. constructor(scene: Scene);
  97261. /**
  97262. * Registers the component in a given scene
  97263. */
  97264. register(): void;
  97265. /**
  97266. * Return the list of active meshes
  97267. * @returns the list of active meshes
  97268. */
  97269. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97270. /**
  97271. * Return the list of active sub meshes
  97272. * @param mesh The mesh to get the candidates sub meshes from
  97273. * @returns the list of active sub meshes
  97274. */
  97275. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97276. private _tempRay;
  97277. /**
  97278. * Return the list of sub meshes intersecting with a given local ray
  97279. * @param mesh defines the mesh to find the submesh for
  97280. * @param localRay defines the ray in local space
  97281. * @returns the list of intersecting sub meshes
  97282. */
  97283. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  97284. /**
  97285. * Return the list of sub meshes colliding with a collider
  97286. * @param mesh defines the mesh to find the submesh for
  97287. * @param collider defines the collider to evaluate the collision against
  97288. * @returns the list of colliding sub meshes
  97289. */
  97290. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  97291. /**
  97292. * Rebuilds the elements related to this component in case of
  97293. * context lost for instance.
  97294. */
  97295. rebuild(): void;
  97296. /**
  97297. * Disposes the component and the associated ressources.
  97298. */
  97299. dispose(): void;
  97300. }
  97301. }
  97302. declare module BABYLON {
  97303. /**
  97304. * Class containing static functions to help procedurally build meshes
  97305. */
  97306. export class LinesBuilder {
  97307. /**
  97308. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  97309. * * 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
  97310. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  97311. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  97312. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  97313. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  97314. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  97315. * * 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
  97316. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  97317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  97319. * @param name defines the name of the new line system
  97320. * @param options defines the options used to create the line system
  97321. * @param scene defines the hosting scene
  97322. * @returns a new line system mesh
  97323. */
  97324. static CreateLineSystem(name: string, options: {
  97325. lines: Vector3[][];
  97326. updatable?: boolean;
  97327. instance?: Nullable<LinesMesh>;
  97328. colors?: Nullable<Color4[][]>;
  97329. useVertexAlpha?: boolean;
  97330. }, scene: Nullable<Scene>): LinesMesh;
  97331. /**
  97332. * Creates a line mesh
  97333. * 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
  97334. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97335. * * The parameter `points` is an array successive Vector3
  97336. * * 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
  97337. * * The optional parameter `colors` is an array of successive Color4, one per line point
  97338. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  97339. * * When updating an instance, remember that only point positions can change, not the number of points
  97340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  97342. * @param name defines the name of the new line system
  97343. * @param options defines the options used to create the line system
  97344. * @param scene defines the hosting scene
  97345. * @returns a new line mesh
  97346. */
  97347. static CreateLines(name: string, options: {
  97348. points: Vector3[];
  97349. updatable?: boolean;
  97350. instance?: Nullable<LinesMesh>;
  97351. colors?: Color4[];
  97352. useVertexAlpha?: boolean;
  97353. }, scene?: Nullable<Scene>): LinesMesh;
  97354. /**
  97355. * Creates a dashed line mesh
  97356. * * 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
  97357. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  97358. * * The parameter `points` is an array successive Vector3
  97359. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  97360. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  97361. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  97362. * * 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
  97363. * * When updating an instance, remember that only point positions can change, not the number of points
  97364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97365. * @param name defines the name of the mesh
  97366. * @param options defines the options used to create the mesh
  97367. * @param scene defines the hosting scene
  97368. * @returns the dashed line mesh
  97369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  97370. */
  97371. static CreateDashedLines(name: string, options: {
  97372. points: Vector3[];
  97373. dashSize?: number;
  97374. gapSize?: number;
  97375. dashNb?: number;
  97376. updatable?: boolean;
  97377. instance?: LinesMesh;
  97378. }, scene?: Nullable<Scene>): LinesMesh;
  97379. }
  97380. }
  97381. declare module BABYLON {
  97382. /**
  97383. * Renders a layer on top of an existing scene
  97384. */
  97385. export class UtilityLayerRenderer implements IDisposable {
  97386. /** the original scene that will be rendered on top of */
  97387. originalScene: Scene;
  97388. private _pointerCaptures;
  97389. private _lastPointerEvents;
  97390. private static _DefaultUtilityLayer;
  97391. private static _DefaultKeepDepthUtilityLayer;
  97392. /**
  97393. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  97394. */
  97395. pickUtilitySceneFirst: boolean;
  97396. /**
  97397. * 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)
  97398. */
  97399. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  97400. /**
  97401. * 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)
  97402. */
  97403. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  97404. /**
  97405. * The scene that is rendered on top of the original scene
  97406. */
  97407. utilityLayerScene: Scene;
  97408. /**
  97409. * If the utility layer should automatically be rendered on top of existing scene
  97410. */
  97411. shouldRender: boolean;
  97412. /**
  97413. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  97414. */
  97415. onlyCheckPointerDownEvents: boolean;
  97416. /**
  97417. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  97418. */
  97419. processAllEvents: boolean;
  97420. /**
  97421. * Observable raised when the pointer move from the utility layer scene to the main scene
  97422. */
  97423. onPointerOutObservable: Observable<number>;
  97424. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  97425. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  97426. private _afterRenderObserver;
  97427. private _sceneDisposeObserver;
  97428. private _originalPointerObserver;
  97429. /**
  97430. * Instantiates a UtilityLayerRenderer
  97431. * @param originalScene the original scene that will be rendered on top of
  97432. * @param handleEvents boolean indicating if the utility layer should handle events
  97433. */
  97434. constructor(
  97435. /** the original scene that will be rendered on top of */
  97436. originalScene: Scene, handleEvents?: boolean);
  97437. private _notifyObservers;
  97438. /**
  97439. * Renders the utility layers scene on top of the original scene
  97440. */
  97441. render(): void;
  97442. /**
  97443. * Disposes of the renderer
  97444. */
  97445. dispose(): void;
  97446. private _updateCamera;
  97447. }
  97448. }
  97449. declare module BABYLON {
  97450. /**
  97451. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  97452. */
  97453. export class Gizmo implements IDisposable {
  97454. /** The utility layer the gizmo will be added to */
  97455. gizmoLayer: UtilityLayerRenderer;
  97456. /**
  97457. * The root mesh of the gizmo
  97458. */
  97459. _rootMesh: Mesh;
  97460. private _attachedMesh;
  97461. /**
  97462. * Ratio for the scale of the gizmo (Default: 1)
  97463. */
  97464. scaleRatio: number;
  97465. private _tmpMatrix;
  97466. /**
  97467. * If a custom mesh has been set (Default: false)
  97468. */
  97469. protected _customMeshSet: boolean;
  97470. /**
  97471. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  97472. * * When set, interactions will be enabled
  97473. */
  97474. attachedMesh: Nullable<AbstractMesh>;
  97475. /**
  97476. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97477. * @param mesh The mesh to replace the default mesh of the gizmo
  97478. */
  97479. setCustomMesh(mesh: Mesh): void;
  97480. /**
  97481. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  97482. */
  97483. updateGizmoRotationToMatchAttachedMesh: boolean;
  97484. /**
  97485. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  97486. */
  97487. updateGizmoPositionToMatchAttachedMesh: boolean;
  97488. /**
  97489. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  97490. */
  97491. protected _updateScale: boolean;
  97492. protected _interactionsEnabled: boolean;
  97493. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97494. private _beforeRenderObserver;
  97495. /**
  97496. * Creates a gizmo
  97497. * @param gizmoLayer The utility layer the gizmo will be added to
  97498. */
  97499. constructor(
  97500. /** The utility layer the gizmo will be added to */
  97501. gizmoLayer?: UtilityLayerRenderer);
  97502. private _tempVector;
  97503. /**
  97504. * @hidden
  97505. * Updates the gizmo to match the attached mesh's position/rotation
  97506. */
  97507. protected _update(): void;
  97508. /**
  97509. * Disposes of the gizmo
  97510. */
  97511. dispose(): void;
  97512. }
  97513. }
  97514. declare module BABYLON {
  97515. /**
  97516. * Single axis drag gizmo
  97517. */
  97518. export class AxisDragGizmo extends Gizmo {
  97519. /**
  97520. * Drag behavior responsible for the gizmos dragging interactions
  97521. */
  97522. dragBehavior: PointerDragBehavior;
  97523. private _pointerObserver;
  97524. /**
  97525. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97526. */
  97527. snapDistance: number;
  97528. /**
  97529. * Event that fires each time the gizmo snaps to a new location.
  97530. * * snapDistance is the the change in distance
  97531. */
  97532. onSnapObservable: Observable<{
  97533. snapDistance: number;
  97534. }>;
  97535. /** @hidden */
  97536. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  97537. /** @hidden */
  97538. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  97539. /**
  97540. * Creates an AxisDragGizmo
  97541. * @param gizmoLayer The utility layer the gizmo will be added to
  97542. * @param dragAxis The axis which the gizmo will be able to drag on
  97543. * @param color The color of the gizmo
  97544. */
  97545. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97546. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97547. /**
  97548. * Disposes of the gizmo
  97549. */
  97550. dispose(): void;
  97551. }
  97552. }
  97553. declare module BABYLON.Debug {
  97554. /**
  97555. * The Axes viewer will show 3 axes in a specific point in space
  97556. */
  97557. export class AxesViewer {
  97558. private _xAxis;
  97559. private _yAxis;
  97560. private _zAxis;
  97561. private _scaleLinesFactor;
  97562. private _instanced;
  97563. /**
  97564. * Gets the hosting scene
  97565. */
  97566. scene: Scene;
  97567. /**
  97568. * Gets or sets a number used to scale line length
  97569. */
  97570. scaleLines: number;
  97571. /** Gets the node hierarchy used to render x-axis */
  97572. readonly xAxis: TransformNode;
  97573. /** Gets the node hierarchy used to render y-axis */
  97574. readonly yAxis: TransformNode;
  97575. /** Gets the node hierarchy used to render z-axis */
  97576. readonly zAxis: TransformNode;
  97577. /**
  97578. * Creates a new AxesViewer
  97579. * @param scene defines the hosting scene
  97580. * @param scaleLines defines a number used to scale line length (1 by default)
  97581. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  97582. * @param xAxis defines the node hierarchy used to render the x-axis
  97583. * @param yAxis defines the node hierarchy used to render the y-axis
  97584. * @param zAxis defines the node hierarchy used to render the z-axis
  97585. */
  97586. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  97587. /**
  97588. * Force the viewer to update
  97589. * @param position defines the position of the viewer
  97590. * @param xaxis defines the x axis of the viewer
  97591. * @param yaxis defines the y axis of the viewer
  97592. * @param zaxis defines the z axis of the viewer
  97593. */
  97594. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  97595. /**
  97596. * Creates an instance of this axes viewer.
  97597. * @returns a new axes viewer with instanced meshes
  97598. */
  97599. createInstance(): AxesViewer;
  97600. /** Releases resources */
  97601. dispose(): void;
  97602. private static _SetRenderingGroupId;
  97603. }
  97604. }
  97605. declare module BABYLON.Debug {
  97606. /**
  97607. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  97608. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  97609. */
  97610. export class BoneAxesViewer extends AxesViewer {
  97611. /**
  97612. * Gets or sets the target mesh where to display the axes viewer
  97613. */
  97614. mesh: Nullable<Mesh>;
  97615. /**
  97616. * Gets or sets the target bone where to display the axes viewer
  97617. */
  97618. bone: Nullable<Bone>;
  97619. /** Gets current position */
  97620. pos: Vector3;
  97621. /** Gets direction of X axis */
  97622. xaxis: Vector3;
  97623. /** Gets direction of Y axis */
  97624. yaxis: Vector3;
  97625. /** Gets direction of Z axis */
  97626. zaxis: Vector3;
  97627. /**
  97628. * Creates a new BoneAxesViewer
  97629. * @param scene defines the hosting scene
  97630. * @param bone defines the target bone
  97631. * @param mesh defines the target mesh
  97632. * @param scaleLines defines a scaling factor for line length (1 by default)
  97633. */
  97634. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  97635. /**
  97636. * Force the viewer to update
  97637. */
  97638. update(): void;
  97639. /** Releases resources */
  97640. dispose(): void;
  97641. }
  97642. }
  97643. declare module BABYLON {
  97644. /**
  97645. * Interface used to define scene explorer extensibility option
  97646. */
  97647. export interface IExplorerExtensibilityOption {
  97648. /**
  97649. * Define the option label
  97650. */
  97651. label: string;
  97652. /**
  97653. * Defines the action to execute on click
  97654. */
  97655. action: (entity: any) => void;
  97656. }
  97657. /**
  97658. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  97659. */
  97660. export interface IExplorerExtensibilityGroup {
  97661. /**
  97662. * Defines a predicate to test if a given type mut be extended
  97663. */
  97664. predicate: (entity: any) => boolean;
  97665. /**
  97666. * Gets the list of options added to a type
  97667. */
  97668. entries: IExplorerExtensibilityOption[];
  97669. }
  97670. /**
  97671. * Interface used to define the options to use to create the Inspector
  97672. */
  97673. export interface IInspectorOptions {
  97674. /**
  97675. * Display in overlay mode (default: false)
  97676. */
  97677. overlay?: boolean;
  97678. /**
  97679. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  97680. */
  97681. globalRoot?: HTMLElement;
  97682. /**
  97683. * Display the Scene explorer
  97684. */
  97685. showExplorer?: boolean;
  97686. /**
  97687. * Display the property inspector
  97688. */
  97689. showInspector?: boolean;
  97690. /**
  97691. * Display in embed mode (both panes on the right)
  97692. */
  97693. embedMode?: boolean;
  97694. /**
  97695. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  97696. */
  97697. handleResize?: boolean;
  97698. /**
  97699. * Allow the panes to popup (default: true)
  97700. */
  97701. enablePopup?: boolean;
  97702. /**
  97703. * Allow the panes to be closed by users (default: true)
  97704. */
  97705. enableClose?: boolean;
  97706. /**
  97707. * Optional list of extensibility entries
  97708. */
  97709. explorerExtensibility?: IExplorerExtensibilityGroup[];
  97710. /**
  97711. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  97712. */
  97713. inspectorURL?: string;
  97714. }
  97715. interface Scene {
  97716. /**
  97717. * @hidden
  97718. * Backing field
  97719. */
  97720. _debugLayer: DebugLayer;
  97721. /**
  97722. * Gets the debug layer (aka Inspector) associated with the scene
  97723. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97724. */
  97725. debugLayer: DebugLayer;
  97726. }
  97727. /**
  97728. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97729. * what is happening in your scene
  97730. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97731. */
  97732. export class DebugLayer {
  97733. /**
  97734. * Define the url to get the inspector script from.
  97735. * By default it uses the babylonjs CDN.
  97736. * @ignoreNaming
  97737. */
  97738. static InspectorURL: string;
  97739. private _scene;
  97740. private BJSINSPECTOR;
  97741. /**
  97742. * Observable triggered when a property is changed through the inspector.
  97743. */
  97744. onPropertyChangedObservable: Observable<{
  97745. object: any;
  97746. property: string;
  97747. value: any;
  97748. initialValue: any;
  97749. }>;
  97750. /**
  97751. * Instantiates a new debug layer.
  97752. * The debug layer (aka Inspector) is the go to tool in order to better understand
  97753. * what is happening in your scene
  97754. * @see http://doc.babylonjs.com/features/playground_debuglayer
  97755. * @param scene Defines the scene to inspect
  97756. */
  97757. constructor(scene: Scene);
  97758. /** Creates the inspector window. */
  97759. private _createInspector;
  97760. /**
  97761. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  97762. * @param entity defines the entity to select
  97763. * @param lineContainerTitle defines the specific block to highlight
  97764. */
  97765. select(entity: any, lineContainerTitle?: string): void;
  97766. /** Get the inspector from bundle or global */
  97767. private _getGlobalInspector;
  97768. /**
  97769. * Get if the inspector is visible or not.
  97770. * @returns true if visible otherwise, false
  97771. */
  97772. isVisible(): boolean;
  97773. /**
  97774. * Hide the inspector and close its window.
  97775. */
  97776. hide(): void;
  97777. /**
  97778. * Launch the debugLayer.
  97779. * @param config Define the configuration of the inspector
  97780. * @return a promise fulfilled when the debug layer is visible
  97781. */
  97782. show(config?: IInspectorOptions): Promise<DebugLayer>;
  97783. }
  97784. }
  97785. declare module BABYLON {
  97786. /**
  97787. * Class containing static functions to help procedurally build meshes
  97788. */
  97789. export class BoxBuilder {
  97790. /**
  97791. * Creates a box mesh
  97792. * * The parameter `size` sets the size (float) of each box side (default 1)
  97793. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  97794. * * 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)
  97795. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  97796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97799. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  97800. * @param name defines the name of the mesh
  97801. * @param options defines the options used to create the mesh
  97802. * @param scene defines the hosting scene
  97803. * @returns the box mesh
  97804. */
  97805. static CreateBox(name: string, options: {
  97806. size?: number;
  97807. width?: number;
  97808. height?: number;
  97809. depth?: number;
  97810. faceUV?: Vector4[];
  97811. faceColors?: Color4[];
  97812. sideOrientation?: number;
  97813. frontUVs?: Vector4;
  97814. backUVs?: Vector4;
  97815. updatable?: boolean;
  97816. }, scene?: Nullable<Scene>): Mesh;
  97817. }
  97818. }
  97819. declare module BABYLON {
  97820. /**
  97821. * Class containing static functions to help procedurally build meshes
  97822. */
  97823. export class SphereBuilder {
  97824. /**
  97825. * Creates a sphere mesh
  97826. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  97827. * * 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`)
  97828. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  97829. * * 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
  97830. * * 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)
  97831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97832. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97834. * @param name defines the name of the mesh
  97835. * @param options defines the options used to create the mesh
  97836. * @param scene defines the hosting scene
  97837. * @returns the sphere mesh
  97838. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  97839. */
  97840. static CreateSphere(name: string, options: {
  97841. segments?: number;
  97842. diameter?: number;
  97843. diameterX?: number;
  97844. diameterY?: number;
  97845. diameterZ?: number;
  97846. arc?: number;
  97847. slice?: number;
  97848. sideOrientation?: number;
  97849. frontUVs?: Vector4;
  97850. backUVs?: Vector4;
  97851. updatable?: boolean;
  97852. }, scene: any): Mesh;
  97853. }
  97854. }
  97855. declare module BABYLON.Debug {
  97856. /**
  97857. * Used to show the physics impostor around the specific mesh
  97858. */
  97859. export class PhysicsViewer {
  97860. /** @hidden */
  97861. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  97862. /** @hidden */
  97863. protected _meshes: Array<Nullable<AbstractMesh>>;
  97864. /** @hidden */
  97865. protected _scene: Nullable<Scene>;
  97866. /** @hidden */
  97867. protected _numMeshes: number;
  97868. /** @hidden */
  97869. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  97870. private _renderFunction;
  97871. private _utilityLayer;
  97872. private _debugBoxMesh;
  97873. private _debugSphereMesh;
  97874. private _debugMaterial;
  97875. /**
  97876. * Creates a new PhysicsViewer
  97877. * @param scene defines the hosting scene
  97878. */
  97879. constructor(scene: Scene);
  97880. /** @hidden */
  97881. protected _updateDebugMeshes(): void;
  97882. /**
  97883. * Renders a specified physic impostor
  97884. * @param impostor defines the impostor to render
  97885. * @returns the new debug mesh used to render the impostor
  97886. */
  97887. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  97888. /**
  97889. * Hides a specified physic impostor
  97890. * @param impostor defines the impostor to hide
  97891. */
  97892. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  97893. private _getDebugMaterial;
  97894. private _getDebugBoxMesh;
  97895. private _getDebugSphereMesh;
  97896. private _getDebugMesh;
  97897. /** Releases all resources */
  97898. dispose(): void;
  97899. }
  97900. }
  97901. declare module BABYLON {
  97902. /**
  97903. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97904. * in order to better appreciate the issue one might have.
  97905. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97906. */
  97907. export class RayHelper {
  97908. /**
  97909. * Defines the ray we are currently tryin to visualize.
  97910. */
  97911. ray: Nullable<Ray>;
  97912. private _renderPoints;
  97913. private _renderLine;
  97914. private _renderFunction;
  97915. private _scene;
  97916. private _updateToMeshFunction;
  97917. private _attachedToMesh;
  97918. private _meshSpaceDirection;
  97919. private _meshSpaceOrigin;
  97920. /**
  97921. * Helper function to create a colored helper in a scene in one line.
  97922. * @param ray Defines the ray we are currently tryin to visualize
  97923. * @param scene Defines the scene the ray is used in
  97924. * @param color Defines the color we want to see the ray in
  97925. * @returns The newly created ray helper.
  97926. */
  97927. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  97928. /**
  97929. * Instantiate a new ray helper.
  97930. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  97931. * in order to better appreciate the issue one might have.
  97932. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  97933. * @param ray Defines the ray we are currently tryin to visualize
  97934. */
  97935. constructor(ray: Ray);
  97936. /**
  97937. * Shows the ray we are willing to debug.
  97938. * @param scene Defines the scene the ray needs to be rendered in
  97939. * @param color Defines the color the ray needs to be rendered in
  97940. */
  97941. show(scene: Scene, color?: Color3): void;
  97942. /**
  97943. * Hides the ray we are debugging.
  97944. */
  97945. hide(): void;
  97946. private _render;
  97947. /**
  97948. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  97949. * @param mesh Defines the mesh we want the helper attached to
  97950. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  97951. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  97952. * @param length Defines the length of the ray
  97953. */
  97954. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  97955. /**
  97956. * Detach the ray helper from the mesh it has previously been attached to.
  97957. */
  97958. detachFromMesh(): void;
  97959. private _updateToMesh;
  97960. /**
  97961. * Dispose the helper and release its associated resources.
  97962. */
  97963. dispose(): void;
  97964. }
  97965. }
  97966. declare module BABYLON.Debug {
  97967. /**
  97968. * Class used to render a debug view of a given skeleton
  97969. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  97970. */
  97971. export class SkeletonViewer {
  97972. /** defines the skeleton to render */
  97973. skeleton: Skeleton;
  97974. /** defines the mesh attached to the skeleton */
  97975. mesh: AbstractMesh;
  97976. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  97977. autoUpdateBonesMatrices: boolean;
  97978. /** defines the rendering group id to use with the viewer */
  97979. renderingGroupId: number;
  97980. /** Gets or sets the color used to render the skeleton */
  97981. color: Color3;
  97982. private _scene;
  97983. private _debugLines;
  97984. private _debugMesh;
  97985. private _isEnabled;
  97986. private _renderFunction;
  97987. private _utilityLayer;
  97988. /**
  97989. * Returns the mesh used to render the bones
  97990. */
  97991. readonly debugMesh: Nullable<LinesMesh>;
  97992. /**
  97993. * Creates a new SkeletonViewer
  97994. * @param skeleton defines the skeleton to render
  97995. * @param mesh defines the mesh attached to the skeleton
  97996. * @param scene defines the hosting scene
  97997. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  97998. * @param renderingGroupId defines the rendering group id to use with the viewer
  97999. */
  98000. constructor(
  98001. /** defines the skeleton to render */
  98002. skeleton: Skeleton,
  98003. /** defines the mesh attached to the skeleton */
  98004. mesh: AbstractMesh, scene: Scene,
  98005. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  98006. autoUpdateBonesMatrices?: boolean,
  98007. /** defines the rendering group id to use with the viewer */
  98008. renderingGroupId?: number);
  98009. /** Gets or sets a boolean indicating if the viewer is enabled */
  98010. isEnabled: boolean;
  98011. private _getBonePosition;
  98012. private _getLinesForBonesWithLength;
  98013. private _getLinesForBonesNoLength;
  98014. /** Update the viewer to sync with current skeleton state */
  98015. update(): void;
  98016. /** Release associated resources */
  98017. dispose(): void;
  98018. }
  98019. }
  98020. declare module BABYLON {
  98021. /**
  98022. * Options to create the null engine
  98023. */
  98024. export class NullEngineOptions {
  98025. /**
  98026. * Render width (Default: 512)
  98027. */
  98028. renderWidth: number;
  98029. /**
  98030. * Render height (Default: 256)
  98031. */
  98032. renderHeight: number;
  98033. /**
  98034. * Texture size (Default: 512)
  98035. */
  98036. textureSize: number;
  98037. /**
  98038. * If delta time between frames should be constant
  98039. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98040. */
  98041. deterministicLockstep: boolean;
  98042. /**
  98043. * Maximum about of steps between frames (Default: 4)
  98044. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98045. */
  98046. lockstepMaxSteps: number;
  98047. }
  98048. /**
  98049. * The null engine class provides support for headless version of babylon.js.
  98050. * This can be used in server side scenario or for testing purposes
  98051. */
  98052. export class NullEngine extends Engine {
  98053. private _options;
  98054. /**
  98055. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98056. */
  98057. isDeterministicLockStep(): boolean;
  98058. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  98059. getLockstepMaxSteps(): number;
  98060. /**
  98061. * Sets hardware scaling, used to save performance if needed
  98062. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  98063. */
  98064. getHardwareScalingLevel(): number;
  98065. constructor(options?: NullEngineOptions);
  98066. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98067. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  98068. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98069. getRenderWidth(useScreen?: boolean): number;
  98070. getRenderHeight(useScreen?: boolean): number;
  98071. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  98072. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  98073. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  98074. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  98075. bindSamplers(effect: Effect): void;
  98076. enableEffect(effect: Effect): void;
  98077. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98078. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  98079. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  98080. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  98081. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  98082. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  98083. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  98084. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  98085. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  98086. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  98087. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  98088. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  98089. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  98090. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  98091. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  98092. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98093. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  98094. setFloat(uniform: WebGLUniformLocation, value: number): void;
  98095. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  98096. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  98097. setBool(uniform: WebGLUniformLocation, bool: number): void;
  98098. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  98099. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  98100. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  98101. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98102. bindBuffers(vertexBuffers: {
  98103. [key: string]: VertexBuffer;
  98104. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  98105. wipeCaches(bruteForce?: boolean): void;
  98106. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98107. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98108. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98109. /** @hidden */
  98110. _createTexture(): WebGLTexture;
  98111. /** @hidden */
  98112. _releaseTexture(texture: InternalTexture): void;
  98113. 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;
  98114. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98115. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98116. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  98117. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98118. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  98119. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  98120. areAllEffectsReady(): boolean;
  98121. /**
  98122. * @hidden
  98123. * Get the current error code of the webGL context
  98124. * @returns the error code
  98125. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98126. */
  98127. getError(): number;
  98128. /** @hidden */
  98129. _getUnpackAlignement(): number;
  98130. /** @hidden */
  98131. _unpackFlipY(value: boolean): void;
  98132. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  98133. /**
  98134. * Updates a dynamic vertex buffer.
  98135. * @param vertexBuffer the vertex buffer to update
  98136. * @param data the data used to update the vertex buffer
  98137. * @param byteOffset the byte offset of the data (optional)
  98138. * @param byteLength the byte length of the data (optional)
  98139. */
  98140. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  98141. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  98142. /** @hidden */
  98143. _bindTexture(channel: number, texture: InternalTexture): void;
  98144. /** @hidden */
  98145. _releaseBuffer(buffer: WebGLBuffer): boolean;
  98146. releaseEffects(): void;
  98147. displayLoadingUI(): void;
  98148. hideLoadingUI(): void;
  98149. /** @hidden */
  98150. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98151. /** @hidden */
  98152. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98153. /** @hidden */
  98154. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98155. /** @hidden */
  98156. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  98157. }
  98158. }
  98159. declare module BABYLON {
  98160. /** @hidden */
  98161. export class _OcclusionDataStorage {
  98162. /** @hidden */
  98163. occlusionInternalRetryCounter: number;
  98164. /** @hidden */
  98165. isOcclusionQueryInProgress: boolean;
  98166. /** @hidden */
  98167. isOccluded: boolean;
  98168. /** @hidden */
  98169. occlusionRetryCount: number;
  98170. /** @hidden */
  98171. occlusionType: number;
  98172. /** @hidden */
  98173. occlusionQueryAlgorithmType: number;
  98174. }
  98175. interface Engine {
  98176. /**
  98177. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  98178. * @return the new query
  98179. */
  98180. createQuery(): WebGLQuery;
  98181. /**
  98182. * Delete and release a webGL query
  98183. * @param query defines the query to delete
  98184. * @return the current engine
  98185. */
  98186. deleteQuery(query: WebGLQuery): Engine;
  98187. /**
  98188. * Check if a given query has resolved and got its value
  98189. * @param query defines the query to check
  98190. * @returns true if the query got its value
  98191. */
  98192. isQueryResultAvailable(query: WebGLQuery): boolean;
  98193. /**
  98194. * Gets the value of a given query
  98195. * @param query defines the query to check
  98196. * @returns the value of the query
  98197. */
  98198. getQueryResult(query: WebGLQuery): number;
  98199. /**
  98200. * Initiates an occlusion query
  98201. * @param algorithmType defines the algorithm to use
  98202. * @param query defines the query to use
  98203. * @returns the current engine
  98204. * @see http://doc.babylonjs.com/features/occlusionquery
  98205. */
  98206. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  98207. /**
  98208. * Ends an occlusion query
  98209. * @see http://doc.babylonjs.com/features/occlusionquery
  98210. * @param algorithmType defines the algorithm to use
  98211. * @returns the current engine
  98212. */
  98213. endOcclusionQuery(algorithmType: number): Engine;
  98214. /**
  98215. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  98216. * Please note that only one query can be issued at a time
  98217. * @returns a time token used to track the time span
  98218. */
  98219. startTimeQuery(): Nullable<_TimeToken>;
  98220. /**
  98221. * Ends a time query
  98222. * @param token defines the token used to measure the time span
  98223. * @returns the time spent (in ns)
  98224. */
  98225. endTimeQuery(token: _TimeToken): int;
  98226. /** @hidden */
  98227. _currentNonTimestampToken: Nullable<_TimeToken>;
  98228. /** @hidden */
  98229. _createTimeQuery(): WebGLQuery;
  98230. /** @hidden */
  98231. _deleteTimeQuery(query: WebGLQuery): void;
  98232. /** @hidden */
  98233. _getGlAlgorithmType(algorithmType: number): number;
  98234. /** @hidden */
  98235. _getTimeQueryResult(query: WebGLQuery): any;
  98236. /** @hidden */
  98237. _getTimeQueryAvailability(query: WebGLQuery): any;
  98238. }
  98239. interface AbstractMesh {
  98240. /**
  98241. * Backing filed
  98242. * @hidden
  98243. */
  98244. __occlusionDataStorage: _OcclusionDataStorage;
  98245. /**
  98246. * Access property
  98247. * @hidden
  98248. */
  98249. _occlusionDataStorage: _OcclusionDataStorage;
  98250. /**
  98251. * 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.
  98252. * The default value is -1 which means don't break the query and wait till the result
  98253. * @see http://doc.babylonjs.com/features/occlusionquery
  98254. */
  98255. occlusionRetryCount: number;
  98256. /**
  98257. * 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:
  98258. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  98259. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  98260. * * 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.
  98261. * @see http://doc.babylonjs.com/features/occlusionquery
  98262. */
  98263. occlusionType: number;
  98264. /**
  98265. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  98266. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  98267. * * 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.
  98268. * @see http://doc.babylonjs.com/features/occlusionquery
  98269. */
  98270. occlusionQueryAlgorithmType: number;
  98271. /**
  98272. * 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
  98273. * @see http://doc.babylonjs.com/features/occlusionquery
  98274. */
  98275. isOccluded: boolean;
  98276. /**
  98277. * Flag to check the progress status of the query
  98278. * @see http://doc.babylonjs.com/features/occlusionquery
  98279. */
  98280. isOcclusionQueryInProgress: boolean;
  98281. }
  98282. }
  98283. declare module BABYLON {
  98284. /** @hidden */
  98285. export var _forceTransformFeedbackToBundle: boolean;
  98286. interface Engine {
  98287. /**
  98288. * Creates a webGL transform feedback object
  98289. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  98290. * @returns the webGL transform feedback object
  98291. */
  98292. createTransformFeedback(): WebGLTransformFeedback;
  98293. /**
  98294. * Delete a webGL transform feedback object
  98295. * @param value defines the webGL transform feedback object to delete
  98296. */
  98297. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  98298. /**
  98299. * Bind a webGL transform feedback object to the webgl context
  98300. * @param value defines the webGL transform feedback object to bind
  98301. */
  98302. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  98303. /**
  98304. * Begins a transform feedback operation
  98305. * @param usePoints defines if points or triangles must be used
  98306. */
  98307. beginTransformFeedback(usePoints: boolean): void;
  98308. /**
  98309. * Ends a transform feedback operation
  98310. */
  98311. endTransformFeedback(): void;
  98312. /**
  98313. * Specify the varyings to use with transform feedback
  98314. * @param program defines the associated webGL program
  98315. * @param value defines the list of strings representing the varying names
  98316. */
  98317. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  98318. /**
  98319. * Bind a webGL buffer for a transform feedback operation
  98320. * @param value defines the webGL buffer to bind
  98321. */
  98322. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  98323. }
  98324. }
  98325. declare module BABYLON {
  98326. /**
  98327. * Gather the list of clipboard event types as constants.
  98328. */
  98329. export class ClipboardEventTypes {
  98330. /**
  98331. * The clipboard event is fired when a copy command is active (pressed).
  98332. */
  98333. static readonly COPY: number;
  98334. /**
  98335. * The clipboard event is fired when a cut command is active (pressed).
  98336. */
  98337. static readonly CUT: number;
  98338. /**
  98339. * The clipboard event is fired when a paste command is active (pressed).
  98340. */
  98341. static readonly PASTE: number;
  98342. }
  98343. /**
  98344. * This class is used to store clipboard related info for the onClipboardObservable event.
  98345. */
  98346. export class ClipboardInfo {
  98347. /**
  98348. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98349. */
  98350. type: number;
  98351. /**
  98352. * Defines the related dom event
  98353. */
  98354. event: ClipboardEvent;
  98355. /**
  98356. *Creates an instance of ClipboardInfo.
  98357. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  98358. * @param event Defines the related dom event
  98359. */
  98360. constructor(
  98361. /**
  98362. * Defines the type of event (BABYLON.ClipboardEventTypes)
  98363. */
  98364. type: number,
  98365. /**
  98366. * Defines the related dom event
  98367. */
  98368. event: ClipboardEvent);
  98369. /**
  98370. * Get the clipboard event's type from the keycode.
  98371. * @param keyCode Defines the keyCode for the current keyboard event.
  98372. * @return {number}
  98373. */
  98374. static GetTypeFromCharacter(keyCode: number): number;
  98375. }
  98376. }
  98377. declare module BABYLON {
  98378. /**
  98379. * Class used to represent data loading progression
  98380. */
  98381. export class SceneLoaderProgressEvent {
  98382. /** defines if data length to load can be evaluated */
  98383. readonly lengthComputable: boolean;
  98384. /** defines the loaded data length */
  98385. readonly loaded: number;
  98386. /** defines the data length to load */
  98387. readonly total: number;
  98388. /**
  98389. * Create a new progress event
  98390. * @param lengthComputable defines if data length to load can be evaluated
  98391. * @param loaded defines the loaded data length
  98392. * @param total defines the data length to load
  98393. */
  98394. constructor(
  98395. /** defines if data length to load can be evaluated */
  98396. lengthComputable: boolean,
  98397. /** defines the loaded data length */
  98398. loaded: number,
  98399. /** defines the data length to load */
  98400. total: number);
  98401. /**
  98402. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  98403. * @param event defines the source event
  98404. * @returns a new SceneLoaderProgressEvent
  98405. */
  98406. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  98407. }
  98408. /**
  98409. * Interface used by SceneLoader plugins to define supported file extensions
  98410. */
  98411. export interface ISceneLoaderPluginExtensions {
  98412. /**
  98413. * Defines the list of supported extensions
  98414. */
  98415. [extension: string]: {
  98416. isBinary: boolean;
  98417. };
  98418. }
  98419. /**
  98420. * Interface used by SceneLoader plugin factory
  98421. */
  98422. export interface ISceneLoaderPluginFactory {
  98423. /**
  98424. * Defines the name of the factory
  98425. */
  98426. name: string;
  98427. /**
  98428. * Function called to create a new plugin
  98429. * @return the new plugin
  98430. */
  98431. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  98432. /**
  98433. * Boolean indicating if the plugin can direct load specific data
  98434. */
  98435. canDirectLoad?: (data: string) => boolean;
  98436. }
  98437. /**
  98438. * Interface used to define a SceneLoader plugin
  98439. */
  98440. export interface ISceneLoaderPlugin {
  98441. /**
  98442. * The friendly name of this plugin.
  98443. */
  98444. name: string;
  98445. /**
  98446. * The file extensions supported by this plugin.
  98447. */
  98448. extensions: string | ISceneLoaderPluginExtensions;
  98449. /**
  98450. * Import meshes into a scene.
  98451. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98452. * @param scene The scene to import into
  98453. * @param data The data to import
  98454. * @param rootUrl The root url for scene and resources
  98455. * @param meshes The meshes array to import into
  98456. * @param particleSystems The particle systems array to import into
  98457. * @param skeletons The skeletons array to import into
  98458. * @param onError The callback when import fails
  98459. * @returns True if successful or false otherwise
  98460. */
  98461. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  98462. /**
  98463. * Load into a scene.
  98464. * @param scene The scene to load into
  98465. * @param data The data to import
  98466. * @param rootUrl The root url for scene and resources
  98467. * @param onError The callback when import fails
  98468. * @returns true if successful or false otherwise
  98469. */
  98470. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  98471. /**
  98472. * The callback that returns true if the data can be directly loaded.
  98473. */
  98474. canDirectLoad?: (data: string) => boolean;
  98475. /**
  98476. * The callback that allows custom handling of the root url based on the response url.
  98477. */
  98478. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98479. /**
  98480. * Load into an asset container.
  98481. * @param scene The scene to load into
  98482. * @param data The data to import
  98483. * @param rootUrl The root url for scene and resources
  98484. * @param onError The callback when import fails
  98485. * @returns The loaded asset container
  98486. */
  98487. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  98488. }
  98489. /**
  98490. * Interface used to define an async SceneLoader plugin
  98491. */
  98492. export interface ISceneLoaderPluginAsync {
  98493. /**
  98494. * The friendly name of this plugin.
  98495. */
  98496. name: string;
  98497. /**
  98498. * The file extensions supported by this plugin.
  98499. */
  98500. extensions: string | ISceneLoaderPluginExtensions;
  98501. /**
  98502. * Import meshes into a scene.
  98503. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98504. * @param scene The scene to import into
  98505. * @param data The data to import
  98506. * @param rootUrl The root url for scene and resources
  98507. * @param onProgress The callback when the load progresses
  98508. * @param fileName Defines the name of the file to load
  98509. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  98510. */
  98511. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  98512. meshes: AbstractMesh[];
  98513. particleSystems: IParticleSystem[];
  98514. skeletons: Skeleton[];
  98515. animationGroups: AnimationGroup[];
  98516. }>;
  98517. /**
  98518. * Load into a scene.
  98519. * @param scene The scene to load into
  98520. * @param data The data to import
  98521. * @param rootUrl The root url for scene and resources
  98522. * @param onProgress The callback when the load progresses
  98523. * @param fileName Defines the name of the file to load
  98524. * @returns Nothing
  98525. */
  98526. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  98527. /**
  98528. * The callback that returns true if the data can be directly loaded.
  98529. */
  98530. canDirectLoad?: (data: string) => boolean;
  98531. /**
  98532. * The callback that allows custom handling of the root url based on the response url.
  98533. */
  98534. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  98535. /**
  98536. * Load into an asset container.
  98537. * @param scene The scene to load into
  98538. * @param data The data to import
  98539. * @param rootUrl The root url for scene and resources
  98540. * @param onProgress The callback when the load progresses
  98541. * @param fileName Defines the name of the file to load
  98542. * @returns The loaded asset container
  98543. */
  98544. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  98545. }
  98546. /**
  98547. * Class used to load scene from various file formats using registered plugins
  98548. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  98549. */
  98550. export class SceneLoader {
  98551. /**
  98552. * No logging while loading
  98553. */
  98554. static readonly NO_LOGGING: number;
  98555. /**
  98556. * Minimal logging while loading
  98557. */
  98558. static readonly MINIMAL_LOGGING: number;
  98559. /**
  98560. * Summary logging while loading
  98561. */
  98562. static readonly SUMMARY_LOGGING: number;
  98563. /**
  98564. * Detailled logging while loading
  98565. */
  98566. static readonly DETAILED_LOGGING: number;
  98567. /**
  98568. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  98569. */
  98570. static ForceFullSceneLoadingForIncremental: boolean;
  98571. /**
  98572. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  98573. */
  98574. static ShowLoadingScreen: boolean;
  98575. /**
  98576. * Defines the current logging level (while loading the scene)
  98577. * @ignorenaming
  98578. */
  98579. static loggingLevel: number;
  98580. /**
  98581. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  98582. */
  98583. static CleanBoneMatrixWeights: boolean;
  98584. /**
  98585. * Event raised when a plugin is used to load a scene
  98586. */
  98587. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  98588. private static _registeredPlugins;
  98589. private static _getDefaultPlugin;
  98590. private static _getPluginForExtension;
  98591. private static _getPluginForDirectLoad;
  98592. private static _getPluginForFilename;
  98593. private static _getDirectLoad;
  98594. private static _loadData;
  98595. private static _getFileInfo;
  98596. /**
  98597. * Gets a plugin that can load the given extension
  98598. * @param extension defines the extension to load
  98599. * @returns a plugin or null if none works
  98600. */
  98601. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  98602. /**
  98603. * Gets a boolean indicating that the given extension can be loaded
  98604. * @param extension defines the extension to load
  98605. * @returns true if the extension is supported
  98606. */
  98607. static IsPluginForExtensionAvailable(extension: string): boolean;
  98608. /**
  98609. * Adds a new plugin to the list of registered plugins
  98610. * @param plugin defines the plugin to add
  98611. */
  98612. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  98613. /**
  98614. * Import meshes into a scene
  98615. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98616. * @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)
  98617. * @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)
  98618. * @param scene the instance of BABYLON.Scene to append to
  98619. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  98620. * @param onProgress a callback with a progress event for each file being loaded
  98621. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98622. * @param pluginExtension the extension used to determine the plugin
  98623. * @returns The loaded plugin
  98624. */
  98625. 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>;
  98626. /**
  98627. * Import meshes into a scene
  98628. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  98629. * @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)
  98630. * @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)
  98631. * @param scene the instance of BABYLON.Scene to append to
  98632. * @param onProgress a callback with a progress event for each file being loaded
  98633. * @param pluginExtension the extension used to determine the plugin
  98634. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  98635. */
  98636. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  98637. meshes: AbstractMesh[];
  98638. particleSystems: IParticleSystem[];
  98639. skeletons: Skeleton[];
  98640. animationGroups: AnimationGroup[];
  98641. }>;
  98642. /**
  98643. * Load a scene
  98644. * @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)
  98645. * @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)
  98646. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98647. * @param onSuccess a callback with the scene when import succeeds
  98648. * @param onProgress a callback with a progress event for each file being loaded
  98649. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98650. * @param pluginExtension the extension used to determine the plugin
  98651. * @returns The loaded plugin
  98652. */
  98653. 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>;
  98654. /**
  98655. * Load a scene
  98656. * @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)
  98657. * @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)
  98658. * @param engine is the instance of BABYLON.Engine to use to create the scene
  98659. * @param onProgress a callback with a progress event for each file being loaded
  98660. * @param pluginExtension the extension used to determine the plugin
  98661. * @returns The loaded scene
  98662. */
  98663. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98664. /**
  98665. * Append a scene
  98666. * @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)
  98667. * @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)
  98668. * @param scene is the instance of BABYLON.Scene to append to
  98669. * @param onSuccess a callback with the scene when import succeeds
  98670. * @param onProgress a callback with a progress event for each file being loaded
  98671. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98672. * @param pluginExtension the extension used to determine the plugin
  98673. * @returns The loaded plugin
  98674. */
  98675. 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>;
  98676. /**
  98677. * Append a scene
  98678. * @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)
  98679. * @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)
  98680. * @param scene is the instance of BABYLON.Scene to append to
  98681. * @param onProgress a callback with a progress event for each file being loaded
  98682. * @param pluginExtension the extension used to determine the plugin
  98683. * @returns The given scene
  98684. */
  98685. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  98686. /**
  98687. * Load a scene into an asset container
  98688. * @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)
  98689. * @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)
  98690. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  98691. * @param onSuccess a callback with the scene when import succeeds
  98692. * @param onProgress a callback with a progress event for each file being loaded
  98693. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  98694. * @param pluginExtension the extension used to determine the plugin
  98695. * @returns The loaded plugin
  98696. */
  98697. 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>;
  98698. /**
  98699. * Load a scene into an asset container
  98700. * @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)
  98701. * @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)
  98702. * @param scene is the instance of Scene to append to
  98703. * @param onProgress a callback with a progress event for each file being loaded
  98704. * @param pluginExtension the extension used to determine the plugin
  98705. * @returns The loaded asset container
  98706. */
  98707. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  98708. }
  98709. }
  98710. declare module BABYLON {
  98711. /**
  98712. * Google Daydream controller
  98713. */
  98714. export class DaydreamController extends WebVRController {
  98715. /**
  98716. * Base Url for the controller model.
  98717. */
  98718. static MODEL_BASE_URL: string;
  98719. /**
  98720. * File name for the controller model.
  98721. */
  98722. static MODEL_FILENAME: string;
  98723. /**
  98724. * Gamepad Id prefix used to identify Daydream Controller.
  98725. */
  98726. static readonly GAMEPAD_ID_PREFIX: string;
  98727. /**
  98728. * Creates a new DaydreamController from a gamepad
  98729. * @param vrGamepad the gamepad that the controller should be created from
  98730. */
  98731. constructor(vrGamepad: any);
  98732. /**
  98733. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98734. * @param scene scene in which to add meshes
  98735. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98736. */
  98737. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98738. /**
  98739. * Called once for each button that changed state since the last frame
  98740. * @param buttonIdx Which button index changed
  98741. * @param state New state of the button
  98742. * @param changes Which properties on the state changed since last frame
  98743. */
  98744. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98745. }
  98746. }
  98747. declare module BABYLON {
  98748. /**
  98749. * Gear VR Controller
  98750. */
  98751. export class GearVRController extends WebVRController {
  98752. /**
  98753. * Base Url for the controller model.
  98754. */
  98755. static MODEL_BASE_URL: string;
  98756. /**
  98757. * File name for the controller model.
  98758. */
  98759. static MODEL_FILENAME: string;
  98760. /**
  98761. * Gamepad Id prefix used to identify this controller.
  98762. */
  98763. static readonly GAMEPAD_ID_PREFIX: string;
  98764. private readonly _buttonIndexToObservableNameMap;
  98765. /**
  98766. * Creates a new GearVRController from a gamepad
  98767. * @param vrGamepad the gamepad that the controller should be created from
  98768. */
  98769. constructor(vrGamepad: any);
  98770. /**
  98771. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98772. * @param scene scene in which to add meshes
  98773. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98774. */
  98775. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98776. /**
  98777. * Called once for each button that changed state since the last frame
  98778. * @param buttonIdx Which button index changed
  98779. * @param state New state of the button
  98780. * @param changes Which properties on the state changed since last frame
  98781. */
  98782. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98783. }
  98784. }
  98785. declare module BABYLON {
  98786. /**
  98787. * Generic Controller
  98788. */
  98789. export class GenericController extends WebVRController {
  98790. /**
  98791. * Base Url for the controller model.
  98792. */
  98793. static readonly MODEL_BASE_URL: string;
  98794. /**
  98795. * File name for the controller model.
  98796. */
  98797. static readonly MODEL_FILENAME: string;
  98798. /**
  98799. * Creates a new GenericController from a gamepad
  98800. * @param vrGamepad the gamepad that the controller should be created from
  98801. */
  98802. constructor(vrGamepad: any);
  98803. /**
  98804. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98805. * @param scene scene in which to add meshes
  98806. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98807. */
  98808. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98809. /**
  98810. * Called once for each button that changed state since the last frame
  98811. * @param buttonIdx Which button index changed
  98812. * @param state New state of the button
  98813. * @param changes Which properties on the state changed since last frame
  98814. */
  98815. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98816. }
  98817. }
  98818. declare module BABYLON {
  98819. /**
  98820. * Oculus Touch Controller
  98821. */
  98822. export class OculusTouchController extends WebVRController {
  98823. /**
  98824. * Base Url for the controller model.
  98825. */
  98826. static MODEL_BASE_URL: string;
  98827. /**
  98828. * File name for the left controller model.
  98829. */
  98830. static MODEL_LEFT_FILENAME: string;
  98831. /**
  98832. * File name for the right controller model.
  98833. */
  98834. static MODEL_RIGHT_FILENAME: string;
  98835. /**
  98836. * Fired when the secondary trigger on this controller is modified
  98837. */
  98838. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98839. /**
  98840. * Fired when the thumb rest on this controller is modified
  98841. */
  98842. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  98843. /**
  98844. * Creates a new OculusTouchController from a gamepad
  98845. * @param vrGamepad the gamepad that the controller should be created from
  98846. */
  98847. constructor(vrGamepad: any);
  98848. /**
  98849. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98850. * @param scene scene in which to add meshes
  98851. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98852. */
  98853. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98854. /**
  98855. * Fired when the A button on this controller is modified
  98856. */
  98857. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98858. /**
  98859. * Fired when the B button on this controller is modified
  98860. */
  98861. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98862. /**
  98863. * Fired when the X button on this controller is modified
  98864. */
  98865. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98866. /**
  98867. * Fired when the Y button on this controller is modified
  98868. */
  98869. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98870. /**
  98871. * Called once for each button that changed state since the last frame
  98872. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  98873. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  98874. * 2) secondary trigger (same)
  98875. * 3) A (right) X (left), touch, pressed = value
  98876. * 4) B / Y
  98877. * 5) thumb rest
  98878. * @param buttonIdx Which button index changed
  98879. * @param state New state of the button
  98880. * @param changes Which properties on the state changed since last frame
  98881. */
  98882. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98883. }
  98884. }
  98885. declare module BABYLON {
  98886. /**
  98887. * Vive Controller
  98888. */
  98889. export class ViveController extends WebVRController {
  98890. /**
  98891. * Base Url for the controller model.
  98892. */
  98893. static MODEL_BASE_URL: string;
  98894. /**
  98895. * File name for the controller model.
  98896. */
  98897. static MODEL_FILENAME: string;
  98898. /**
  98899. * Creates a new ViveController from a gamepad
  98900. * @param vrGamepad the gamepad that the controller should be created from
  98901. */
  98902. constructor(vrGamepad: any);
  98903. /**
  98904. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  98905. * @param scene scene in which to add meshes
  98906. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  98907. */
  98908. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98909. /**
  98910. * Fired when the left button on this controller is modified
  98911. */
  98912. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98913. /**
  98914. * Fired when the right button on this controller is modified
  98915. */
  98916. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98917. /**
  98918. * Fired when the menu button on this controller is modified
  98919. */
  98920. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98921. /**
  98922. * Called once for each button that changed state since the last frame
  98923. * Vive mapping:
  98924. * 0: touchpad
  98925. * 1: trigger
  98926. * 2: left AND right buttons
  98927. * 3: menu button
  98928. * @param buttonIdx Which button index changed
  98929. * @param state New state of the button
  98930. * @param changes Which properties on the state changed since last frame
  98931. */
  98932. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98933. }
  98934. }
  98935. declare module BABYLON {
  98936. /**
  98937. * Defines the WindowsMotionController object that the state of the windows motion controller
  98938. */
  98939. export class WindowsMotionController extends WebVRController {
  98940. /**
  98941. * The base url used to load the left and right controller models
  98942. */
  98943. static MODEL_BASE_URL: string;
  98944. /**
  98945. * The name of the left controller model file
  98946. */
  98947. static MODEL_LEFT_FILENAME: string;
  98948. /**
  98949. * The name of the right controller model file
  98950. */
  98951. static MODEL_RIGHT_FILENAME: string;
  98952. /**
  98953. * The controller name prefix for this controller type
  98954. */
  98955. static readonly GAMEPAD_ID_PREFIX: string;
  98956. /**
  98957. * The controller id pattern for this controller type
  98958. */
  98959. private static readonly GAMEPAD_ID_PATTERN;
  98960. private _loadedMeshInfo;
  98961. private readonly _mapping;
  98962. /**
  98963. * Fired when the trackpad on this controller is clicked
  98964. */
  98965. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  98966. /**
  98967. * Fired when the trackpad on this controller is modified
  98968. */
  98969. onTrackpadValuesChangedObservable: Observable<StickValues>;
  98970. /**
  98971. * The current x and y values of this controller's trackpad
  98972. */
  98973. trackpad: StickValues;
  98974. /**
  98975. * Creates a new WindowsMotionController from a gamepad
  98976. * @param vrGamepad the gamepad that the controller should be created from
  98977. */
  98978. constructor(vrGamepad: any);
  98979. /**
  98980. * Fired when the trigger on this controller is modified
  98981. */
  98982. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98983. /**
  98984. * Fired when the menu button on this controller is modified
  98985. */
  98986. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98987. /**
  98988. * Fired when the grip button on this controller is modified
  98989. */
  98990. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98991. /**
  98992. * Fired when the thumbstick button on this controller is modified
  98993. */
  98994. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98995. /**
  98996. * Fired when the touchpad button on this controller is modified
  98997. */
  98998. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98999. /**
  99000. * Fired when the touchpad values on this controller are modified
  99001. */
  99002. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  99003. private _updateTrackpad;
  99004. /**
  99005. * Called once per frame by the engine.
  99006. */
  99007. update(): void;
  99008. /**
  99009. * Called once for each button that changed state since the last frame
  99010. * @param buttonIdx Which button index changed
  99011. * @param state New state of the button
  99012. * @param changes Which properties on the state changed since last frame
  99013. */
  99014. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99015. /**
  99016. * Moves the buttons on the controller mesh based on their current state
  99017. * @param buttonName the name of the button to move
  99018. * @param buttonValue the value of the button which determines the buttons new position
  99019. */
  99020. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  99021. /**
  99022. * Moves the axis on the controller mesh based on its current state
  99023. * @param axis the index of the axis
  99024. * @param axisValue the value of the axis which determines the meshes new position
  99025. * @hidden
  99026. */
  99027. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  99028. /**
  99029. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99030. * @param scene scene in which to add meshes
  99031. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99032. */
  99033. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  99034. /**
  99035. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  99036. * can be transformed by button presses and axes values, based on this._mapping.
  99037. *
  99038. * @param scene scene in which the meshes exist
  99039. * @param meshes list of meshes that make up the controller model to process
  99040. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  99041. */
  99042. private processModel;
  99043. private createMeshInfo;
  99044. /**
  99045. * Gets the ray of the controller in the direction the controller is pointing
  99046. * @param length the length the resulting ray should be
  99047. * @returns a ray in the direction the controller is pointing
  99048. */
  99049. getForwardRay(length?: number): Ray;
  99050. /**
  99051. * Disposes of the controller
  99052. */
  99053. dispose(): void;
  99054. }
  99055. }
  99056. declare module BABYLON {
  99057. /**
  99058. * Single axis scale gizmo
  99059. */
  99060. export class AxisScaleGizmo extends Gizmo {
  99061. private _coloredMaterial;
  99062. /**
  99063. * Drag behavior responsible for the gizmos dragging interactions
  99064. */
  99065. dragBehavior: PointerDragBehavior;
  99066. private _pointerObserver;
  99067. /**
  99068. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99069. */
  99070. snapDistance: number;
  99071. /**
  99072. * Event that fires each time the gizmo snaps to a new location.
  99073. * * snapDistance is the the change in distance
  99074. */
  99075. onSnapObservable: Observable<{
  99076. snapDistance: number;
  99077. }>;
  99078. /**
  99079. * If the scaling operation should be done on all axis (default: false)
  99080. */
  99081. uniformScaling: boolean;
  99082. /**
  99083. * Creates an AxisScaleGizmo
  99084. * @param gizmoLayer The utility layer the gizmo will be added to
  99085. * @param dragAxis The axis which the gizmo will be able to scale on
  99086. * @param color The color of the gizmo
  99087. */
  99088. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99089. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99090. /**
  99091. * Disposes of the gizmo
  99092. */
  99093. dispose(): void;
  99094. /**
  99095. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99096. * @param mesh The mesh to replace the default mesh of the gizmo
  99097. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  99098. */
  99099. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  99100. }
  99101. }
  99102. declare module BABYLON {
  99103. /**
  99104. * Bounding box gizmo
  99105. */
  99106. export class BoundingBoxGizmo extends Gizmo {
  99107. private _lineBoundingBox;
  99108. private _rotateSpheresParent;
  99109. private _scaleBoxesParent;
  99110. private _boundingDimensions;
  99111. private _renderObserver;
  99112. private _pointerObserver;
  99113. private _scaleDragSpeed;
  99114. private _tmpQuaternion;
  99115. private _tmpVector;
  99116. private _tmpRotationMatrix;
  99117. /**
  99118. * 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)
  99119. */
  99120. ignoreChildren: boolean;
  99121. /**
  99122. * 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)
  99123. */
  99124. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  99125. /**
  99126. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  99127. */
  99128. rotationSphereSize: number;
  99129. /**
  99130. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  99131. */
  99132. scaleBoxSize: number;
  99133. /**
  99134. * 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)
  99135. */
  99136. fixedDragMeshScreenSize: boolean;
  99137. /**
  99138. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  99139. */
  99140. fixedDragMeshScreenSizeDistanceFactor: number;
  99141. /**
  99142. * Fired when a rotation sphere or scale box is dragged
  99143. */
  99144. onDragStartObservable: Observable<{}>;
  99145. /**
  99146. * Fired when a scale box is dragged
  99147. */
  99148. onScaleBoxDragObservable: Observable<{}>;
  99149. /**
  99150. * Fired when a scale box drag is ended
  99151. */
  99152. onScaleBoxDragEndObservable: Observable<{}>;
  99153. /**
  99154. * Fired when a rotation sphere is dragged
  99155. */
  99156. onRotationSphereDragObservable: Observable<{}>;
  99157. /**
  99158. * Fired when a rotation sphere drag is ended
  99159. */
  99160. onRotationSphereDragEndObservable: Observable<{}>;
  99161. /**
  99162. * 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)
  99163. */
  99164. scalePivot: Nullable<Vector3>;
  99165. private _anchorMesh;
  99166. private _existingMeshScale;
  99167. private _dragMesh;
  99168. private pointerDragBehavior;
  99169. private coloredMaterial;
  99170. private hoverColoredMaterial;
  99171. /**
  99172. * Sets the color of the bounding box gizmo
  99173. * @param color the color to set
  99174. */
  99175. setColor(color: Color3): void;
  99176. /**
  99177. * Creates an BoundingBoxGizmo
  99178. * @param gizmoLayer The utility layer the gizmo will be added to
  99179. * @param color The color of the gizmo
  99180. */
  99181. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99182. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99183. private _selectNode;
  99184. /**
  99185. * Updates the bounding box information for the Gizmo
  99186. */
  99187. updateBoundingBox(): void;
  99188. private _updateRotationSpheres;
  99189. private _updateScaleBoxes;
  99190. /**
  99191. * Enables rotation on the specified axis and disables rotation on the others
  99192. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  99193. */
  99194. setEnabledRotationAxis(axis: string): void;
  99195. /**
  99196. * Enables/disables scaling
  99197. * @param enable if scaling should be enabled
  99198. */
  99199. setEnabledScaling(enable: boolean): void;
  99200. private _updateDummy;
  99201. /**
  99202. * Enables a pointer drag behavior on the bounding box of the gizmo
  99203. */
  99204. enableDragBehavior(): void;
  99205. /**
  99206. * Disposes of the gizmo
  99207. */
  99208. dispose(): void;
  99209. /**
  99210. * 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)
  99211. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  99212. * @returns the bounding box mesh with the passed in mesh as a child
  99213. */
  99214. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  99215. /**
  99216. * CustomMeshes are not supported by this gizmo
  99217. * @param mesh The mesh to replace the default mesh of the gizmo
  99218. */
  99219. setCustomMesh(mesh: Mesh): void;
  99220. }
  99221. }
  99222. declare module BABYLON {
  99223. /**
  99224. * Single plane rotation gizmo
  99225. */
  99226. export class PlaneRotationGizmo extends Gizmo {
  99227. /**
  99228. * Drag behavior responsible for the gizmos dragging interactions
  99229. */
  99230. dragBehavior: PointerDragBehavior;
  99231. private _pointerObserver;
  99232. /**
  99233. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  99234. */
  99235. snapDistance: number;
  99236. /**
  99237. * Event that fires each time the gizmo snaps to a new location.
  99238. * * snapDistance is the the change in distance
  99239. */
  99240. onSnapObservable: Observable<{
  99241. snapDistance: number;
  99242. }>;
  99243. /**
  99244. * Creates a PlaneRotationGizmo
  99245. * @param gizmoLayer The utility layer the gizmo will be added to
  99246. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  99247. * @param color The color of the gizmo
  99248. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99249. */
  99250. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99251. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99252. /**
  99253. * Disposes of the gizmo
  99254. */
  99255. dispose(): void;
  99256. }
  99257. }
  99258. declare module BABYLON {
  99259. /**
  99260. * Gizmo that enables rotating a mesh along 3 axis
  99261. */
  99262. export class RotationGizmo extends Gizmo {
  99263. /**
  99264. * Internal gizmo used for interactions on the x axis
  99265. */
  99266. xGizmo: PlaneRotationGizmo;
  99267. /**
  99268. * Internal gizmo used for interactions on the y axis
  99269. */
  99270. yGizmo: PlaneRotationGizmo;
  99271. /**
  99272. * Internal gizmo used for interactions on the z axis
  99273. */
  99274. zGizmo: PlaneRotationGizmo;
  99275. /** Fires an event when any of it's sub gizmos are dragged */
  99276. onDragStartObservable: Observable<{}>;
  99277. /** Fires an event when any of it's sub gizmos are released from dragging */
  99278. onDragEndObservable: Observable<{}>;
  99279. attachedMesh: Nullable<AbstractMesh>;
  99280. /**
  99281. * Creates a RotationGizmo
  99282. * @param gizmoLayer The utility layer the gizmo will be added to
  99283. * @param tessellation Amount of tessellation to be used when creating rotation circles
  99284. */
  99285. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  99286. updateGizmoRotationToMatchAttachedMesh: boolean;
  99287. /**
  99288. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99289. */
  99290. snapDistance: number;
  99291. /**
  99292. * Ratio for the scale of the gizmo (Default: 1)
  99293. */
  99294. scaleRatio: number;
  99295. /**
  99296. * Disposes of the gizmo
  99297. */
  99298. dispose(): void;
  99299. /**
  99300. * CustomMeshes are not supported by this gizmo
  99301. * @param mesh The mesh to replace the default mesh of the gizmo
  99302. */
  99303. setCustomMesh(mesh: Mesh): void;
  99304. }
  99305. }
  99306. declare module BABYLON {
  99307. /**
  99308. * Gizmo that enables dragging a mesh along 3 axis
  99309. */
  99310. export class PositionGizmo extends Gizmo {
  99311. /**
  99312. * Internal gizmo used for interactions on the x axis
  99313. */
  99314. xGizmo: AxisDragGizmo;
  99315. /**
  99316. * Internal gizmo used for interactions on the y axis
  99317. */
  99318. yGizmo: AxisDragGizmo;
  99319. /**
  99320. * Internal gizmo used for interactions on the z axis
  99321. */
  99322. zGizmo: AxisDragGizmo;
  99323. /** Fires an event when any of it's sub gizmos are dragged */
  99324. onDragStartObservable: Observable<{}>;
  99325. /** Fires an event when any of it's sub gizmos are released from dragging */
  99326. onDragEndObservable: Observable<{}>;
  99327. attachedMesh: Nullable<AbstractMesh>;
  99328. /**
  99329. * Creates a PositionGizmo
  99330. * @param gizmoLayer The utility layer the gizmo will be added to
  99331. */
  99332. constructor(gizmoLayer?: UtilityLayerRenderer);
  99333. updateGizmoRotationToMatchAttachedMesh: boolean;
  99334. /**
  99335. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99336. */
  99337. snapDistance: number;
  99338. /**
  99339. * Ratio for the scale of the gizmo (Default: 1)
  99340. */
  99341. scaleRatio: number;
  99342. /**
  99343. * Disposes of the gizmo
  99344. */
  99345. dispose(): void;
  99346. /**
  99347. * CustomMeshes are not supported by this gizmo
  99348. * @param mesh The mesh to replace the default mesh of the gizmo
  99349. */
  99350. setCustomMesh(mesh: Mesh): void;
  99351. }
  99352. }
  99353. declare module BABYLON {
  99354. /**
  99355. * Class containing static functions to help procedurally build meshes
  99356. */
  99357. export class PolyhedronBuilder {
  99358. /**
  99359. * Creates a polyhedron mesh
  99360. * * 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
  99361. * * The parameter `size` (positive float, default 1) sets the polygon size
  99362. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99363. * * 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`
  99364. * * 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
  99365. * * 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)`)
  99366. * * 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
  99367. * * 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
  99368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99369. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99371. * @param name defines the name of the mesh
  99372. * @param options defines the options used to create the mesh
  99373. * @param scene defines the hosting scene
  99374. * @returns the polyhedron mesh
  99375. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  99376. */
  99377. static CreatePolyhedron(name: string, options: {
  99378. type?: number;
  99379. size?: number;
  99380. sizeX?: number;
  99381. sizeY?: number;
  99382. sizeZ?: number;
  99383. custom?: any;
  99384. faceUV?: Vector4[];
  99385. faceColors?: Color4[];
  99386. flat?: boolean;
  99387. updatable?: boolean;
  99388. sideOrientation?: number;
  99389. frontUVs?: Vector4;
  99390. backUVs?: Vector4;
  99391. }, scene: Scene): Mesh;
  99392. }
  99393. }
  99394. declare module BABYLON {
  99395. /**
  99396. * Gizmo that enables scaling a mesh along 3 axis
  99397. */
  99398. export class ScaleGizmo extends Gizmo {
  99399. /**
  99400. * Internal gizmo used for interactions on the x axis
  99401. */
  99402. xGizmo: AxisScaleGizmo;
  99403. /**
  99404. * Internal gizmo used for interactions on the y axis
  99405. */
  99406. yGizmo: AxisScaleGizmo;
  99407. /**
  99408. * Internal gizmo used for interactions on the z axis
  99409. */
  99410. zGizmo: AxisScaleGizmo;
  99411. /**
  99412. * Internal gizmo used to scale all axis equally
  99413. */
  99414. uniformScaleGizmo: AxisScaleGizmo;
  99415. /** Fires an event when any of it's sub gizmos are dragged */
  99416. onDragStartObservable: Observable<{}>;
  99417. /** Fires an event when any of it's sub gizmos are released from dragging */
  99418. onDragEndObservable: Observable<{}>;
  99419. attachedMesh: Nullable<AbstractMesh>;
  99420. /**
  99421. * Creates a ScaleGizmo
  99422. * @param gizmoLayer The utility layer the gizmo will be added to
  99423. */
  99424. constructor(gizmoLayer?: UtilityLayerRenderer);
  99425. updateGizmoRotationToMatchAttachedMesh: boolean;
  99426. /**
  99427. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99428. */
  99429. snapDistance: number;
  99430. /**
  99431. * Ratio for the scale of the gizmo (Default: 1)
  99432. */
  99433. scaleRatio: number;
  99434. /**
  99435. * Disposes of the gizmo
  99436. */
  99437. dispose(): void;
  99438. }
  99439. }
  99440. declare module BABYLON {
  99441. /**
  99442. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  99443. */
  99444. export class GizmoManager implements IDisposable {
  99445. private scene;
  99446. /**
  99447. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  99448. */
  99449. gizmos: {
  99450. positionGizmo: Nullable<PositionGizmo>;
  99451. rotationGizmo: Nullable<RotationGizmo>;
  99452. scaleGizmo: Nullable<ScaleGizmo>;
  99453. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  99454. };
  99455. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  99456. clearGizmoOnEmptyPointerEvent: boolean;
  99457. /** Fires an event when the manager is attached to a mesh */
  99458. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  99459. private _gizmosEnabled;
  99460. private _pointerObserver;
  99461. private _attachedMesh;
  99462. private _boundingBoxColor;
  99463. private _defaultUtilityLayer;
  99464. private _defaultKeepDepthUtilityLayer;
  99465. /**
  99466. * When bounding box gizmo is enabled, this can be used to track drag/end events
  99467. */
  99468. boundingBoxDragBehavior: SixDofDragBehavior;
  99469. /**
  99470. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  99471. */
  99472. attachableMeshes: Nullable<Array<AbstractMesh>>;
  99473. /**
  99474. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  99475. */
  99476. usePointerToAttachGizmos: boolean;
  99477. /**
  99478. * Instatiates a gizmo manager
  99479. * @param scene the scene to overlay the gizmos on top of
  99480. */
  99481. constructor(scene: Scene);
  99482. /**
  99483. * Attaches a set of gizmos to the specified mesh
  99484. * @param mesh The mesh the gizmo's should be attached to
  99485. */
  99486. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  99487. /**
  99488. * If the position gizmo is enabled
  99489. */
  99490. positionGizmoEnabled: boolean;
  99491. /**
  99492. * If the rotation gizmo is enabled
  99493. */
  99494. rotationGizmoEnabled: boolean;
  99495. /**
  99496. * If the scale gizmo is enabled
  99497. */
  99498. scaleGizmoEnabled: boolean;
  99499. /**
  99500. * If the boundingBox gizmo is enabled
  99501. */
  99502. boundingBoxGizmoEnabled: boolean;
  99503. /**
  99504. * Disposes of the gizmo manager
  99505. */
  99506. dispose(): void;
  99507. }
  99508. }
  99509. declare module BABYLON {
  99510. /**
  99511. * Gizmo that enables viewing a light
  99512. */
  99513. export class LightGizmo extends Gizmo {
  99514. private _box;
  99515. /**
  99516. * Creates a LightGizmo
  99517. * @param gizmoLayer The utility layer the gizmo will be added to
  99518. */
  99519. constructor(gizmoLayer?: UtilityLayerRenderer);
  99520. private _light;
  99521. /**
  99522. * The light that the gizmo is attached to
  99523. */
  99524. light: Nullable<Light>;
  99525. /**
  99526. * @hidden
  99527. * Updates the gizmo to match the attached mesh's position/rotation
  99528. */
  99529. protected _update(): void;
  99530. }
  99531. }
  99532. declare module BABYLON {
  99533. /** @hidden */
  99534. export var backgroundFragmentDeclaration: {
  99535. name: string;
  99536. shader: string;
  99537. };
  99538. }
  99539. declare module BABYLON {
  99540. /** @hidden */
  99541. export var backgroundUboDeclaration: {
  99542. name: string;
  99543. shader: string;
  99544. };
  99545. }
  99546. declare module BABYLON {
  99547. /** @hidden */
  99548. export var backgroundPixelShader: {
  99549. name: string;
  99550. shader: string;
  99551. };
  99552. }
  99553. declare module BABYLON {
  99554. /** @hidden */
  99555. export var backgroundVertexDeclaration: {
  99556. name: string;
  99557. shader: string;
  99558. };
  99559. }
  99560. declare module BABYLON {
  99561. /** @hidden */
  99562. export var backgroundVertexShader: {
  99563. name: string;
  99564. shader: string;
  99565. };
  99566. }
  99567. declare module BABYLON {
  99568. /**
  99569. * Background material used to create an efficient environement around your scene.
  99570. */
  99571. export class BackgroundMaterial extends PushMaterial {
  99572. /**
  99573. * Standard reflectance value at parallel view angle.
  99574. */
  99575. static StandardReflectance0: number;
  99576. /**
  99577. * Standard reflectance value at grazing angle.
  99578. */
  99579. static StandardReflectance90: number;
  99580. protected _primaryColor: Color3;
  99581. /**
  99582. * Key light Color (multiply against the environement texture)
  99583. */
  99584. primaryColor: Color3;
  99585. protected __perceptualColor: Nullable<Color3>;
  99586. /**
  99587. * Experimental Internal Use Only.
  99588. *
  99589. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  99590. * This acts as a helper to set the primary color to a more "human friendly" value.
  99591. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  99592. * output color as close as possible from the chosen value.
  99593. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  99594. * part of lighting setup.)
  99595. */
  99596. _perceptualColor: Nullable<Color3>;
  99597. protected _primaryColorShadowLevel: float;
  99598. /**
  99599. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  99600. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  99601. */
  99602. primaryColorShadowLevel: float;
  99603. protected _primaryColorHighlightLevel: float;
  99604. /**
  99605. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  99606. * The primary color is used at the level chosen to define what the white area would look.
  99607. */
  99608. primaryColorHighlightLevel: float;
  99609. protected _reflectionTexture: Nullable<BaseTexture>;
  99610. /**
  99611. * Reflection Texture used in the material.
  99612. * Should be author in a specific way for the best result (refer to the documentation).
  99613. */
  99614. reflectionTexture: Nullable<BaseTexture>;
  99615. protected _reflectionBlur: float;
  99616. /**
  99617. * Reflection Texture level of blur.
  99618. *
  99619. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  99620. * texture twice.
  99621. */
  99622. reflectionBlur: float;
  99623. protected _diffuseTexture: Nullable<BaseTexture>;
  99624. /**
  99625. * Diffuse Texture used in the material.
  99626. * Should be author in a specific way for the best result (refer to the documentation).
  99627. */
  99628. diffuseTexture: Nullable<BaseTexture>;
  99629. protected _shadowLights: Nullable<IShadowLight[]>;
  99630. /**
  99631. * Specify the list of lights casting shadow on the material.
  99632. * All scene shadow lights will be included if null.
  99633. */
  99634. shadowLights: Nullable<IShadowLight[]>;
  99635. protected _shadowLevel: float;
  99636. /**
  99637. * Helps adjusting the shadow to a softer level if required.
  99638. * 0 means black shadows and 1 means no shadows.
  99639. */
  99640. shadowLevel: float;
  99641. protected _sceneCenter: Vector3;
  99642. /**
  99643. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  99644. * It is usually zero but might be interesting to modify according to your setup.
  99645. */
  99646. sceneCenter: Vector3;
  99647. protected _opacityFresnel: boolean;
  99648. /**
  99649. * This helps specifying that the material is falling off to the sky box at grazing angle.
  99650. * This helps ensuring a nice transition when the camera goes under the ground.
  99651. */
  99652. opacityFresnel: boolean;
  99653. protected _reflectionFresnel: boolean;
  99654. /**
  99655. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  99656. * This helps adding a mirror texture on the ground.
  99657. */
  99658. reflectionFresnel: boolean;
  99659. protected _reflectionFalloffDistance: number;
  99660. /**
  99661. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  99662. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  99663. */
  99664. reflectionFalloffDistance: number;
  99665. protected _reflectionAmount: number;
  99666. /**
  99667. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  99668. */
  99669. reflectionAmount: number;
  99670. protected _reflectionReflectance0: number;
  99671. /**
  99672. * This specifies the weight of the reflection at grazing angle.
  99673. */
  99674. reflectionReflectance0: number;
  99675. protected _reflectionReflectance90: number;
  99676. /**
  99677. * This specifies the weight of the reflection at a perpendicular point of view.
  99678. */
  99679. reflectionReflectance90: number;
  99680. /**
  99681. * Sets the reflection reflectance fresnel values according to the default standard
  99682. * empirically know to work well :-)
  99683. */
  99684. reflectionStandardFresnelWeight: number;
  99685. protected _useRGBColor: boolean;
  99686. /**
  99687. * Helps to directly use the maps channels instead of their level.
  99688. */
  99689. useRGBColor: boolean;
  99690. protected _enableNoise: boolean;
  99691. /**
  99692. * This helps reducing the banding effect that could occur on the background.
  99693. */
  99694. enableNoise: boolean;
  99695. /**
  99696. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99697. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  99698. * Recommended to be keep at 1.0 except for special cases.
  99699. */
  99700. fovMultiplier: number;
  99701. private _fovMultiplier;
  99702. /**
  99703. * Enable the FOV adjustment feature controlled by fovMultiplier.
  99704. */
  99705. useEquirectangularFOV: boolean;
  99706. private _maxSimultaneousLights;
  99707. /**
  99708. * Number of Simultaneous lights allowed on the material.
  99709. */
  99710. maxSimultaneousLights: int;
  99711. /**
  99712. * Default configuration related to image processing available in the Background Material.
  99713. */
  99714. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99715. /**
  99716. * Keep track of the image processing observer to allow dispose and replace.
  99717. */
  99718. private _imageProcessingObserver;
  99719. /**
  99720. * Attaches a new image processing configuration to the PBR Material.
  99721. * @param configuration (if null the scene configuration will be use)
  99722. */
  99723. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99724. /**
  99725. * Gets the image processing configuration used either in this material.
  99726. */
  99727. /**
  99728. * Sets the Default image processing configuration used either in the this material.
  99729. *
  99730. * If sets to null, the scene one is in use.
  99731. */
  99732. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  99733. /**
  99734. * Gets wether the color curves effect is enabled.
  99735. */
  99736. /**
  99737. * Sets wether the color curves effect is enabled.
  99738. */
  99739. cameraColorCurvesEnabled: boolean;
  99740. /**
  99741. * Gets wether the color grading effect is enabled.
  99742. */
  99743. /**
  99744. * Gets wether the color grading effect is enabled.
  99745. */
  99746. cameraColorGradingEnabled: boolean;
  99747. /**
  99748. * Gets wether tonemapping is enabled or not.
  99749. */
  99750. /**
  99751. * Sets wether tonemapping is enabled or not
  99752. */
  99753. cameraToneMappingEnabled: boolean;
  99754. /**
  99755. * The camera exposure used on this material.
  99756. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99757. * This corresponds to a photographic exposure.
  99758. */
  99759. /**
  99760. * The camera exposure used on this material.
  99761. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99762. * This corresponds to a photographic exposure.
  99763. */
  99764. cameraExposure: float;
  99765. /**
  99766. * Gets The camera contrast used on this material.
  99767. */
  99768. /**
  99769. * Sets The camera contrast used on this material.
  99770. */
  99771. cameraContrast: float;
  99772. /**
  99773. * Gets the Color Grading 2D Lookup Texture.
  99774. */
  99775. /**
  99776. * Sets the Color Grading 2D Lookup Texture.
  99777. */
  99778. cameraColorGradingTexture: Nullable<BaseTexture>;
  99779. /**
  99780. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99781. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99782. * 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;
  99783. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99784. */
  99785. /**
  99786. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99787. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99788. * 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;
  99789. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99790. */
  99791. cameraColorCurves: Nullable<ColorCurves>;
  99792. /**
  99793. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  99794. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  99795. */
  99796. switchToBGR: boolean;
  99797. private _renderTargets;
  99798. private _reflectionControls;
  99799. private _white;
  99800. private _primaryShadowColor;
  99801. private _primaryHighlightColor;
  99802. /**
  99803. * Instantiates a Background Material in the given scene
  99804. * @param name The friendly name of the material
  99805. * @param scene The scene to add the material to
  99806. */
  99807. constructor(name: string, scene: Scene);
  99808. /**
  99809. * Gets a boolean indicating that current material needs to register RTT
  99810. */
  99811. readonly hasRenderTargetTextures: boolean;
  99812. /**
  99813. * The entire material has been created in order to prevent overdraw.
  99814. * @returns false
  99815. */
  99816. needAlphaTesting(): boolean;
  99817. /**
  99818. * The entire material has been created in order to prevent overdraw.
  99819. * @returns true if blending is enable
  99820. */
  99821. needAlphaBlending(): boolean;
  99822. /**
  99823. * Checks wether the material is ready to be rendered for a given mesh.
  99824. * @param mesh The mesh to render
  99825. * @param subMesh The submesh to check against
  99826. * @param useInstances Specify wether or not the material is used with instances
  99827. * @returns true if all the dependencies are ready (Textures, Effects...)
  99828. */
  99829. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99830. /**
  99831. * Compute the primary color according to the chosen perceptual color.
  99832. */
  99833. private _computePrimaryColorFromPerceptualColor;
  99834. /**
  99835. * Compute the highlights and shadow colors according to their chosen levels.
  99836. */
  99837. private _computePrimaryColors;
  99838. /**
  99839. * Build the uniform buffer used in the material.
  99840. */
  99841. buildUniformLayout(): void;
  99842. /**
  99843. * Unbind the material.
  99844. */
  99845. unbind(): void;
  99846. /**
  99847. * Bind only the world matrix to the material.
  99848. * @param world The world matrix to bind.
  99849. */
  99850. bindOnlyWorldMatrix(world: Matrix): void;
  99851. /**
  99852. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  99853. * @param world The world matrix to bind.
  99854. * @param subMesh The submesh to bind for.
  99855. */
  99856. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99857. /**
  99858. * Dispose the material.
  99859. * @param forceDisposeEffect Force disposal of the associated effect.
  99860. * @param forceDisposeTextures Force disposal of the associated textures.
  99861. */
  99862. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99863. /**
  99864. * Clones the material.
  99865. * @param name The cloned name.
  99866. * @returns The cloned material.
  99867. */
  99868. clone(name: string): BackgroundMaterial;
  99869. /**
  99870. * Serializes the current material to its JSON representation.
  99871. * @returns The JSON representation.
  99872. */
  99873. serialize(): any;
  99874. /**
  99875. * Gets the class name of the material
  99876. * @returns "BackgroundMaterial"
  99877. */
  99878. getClassName(): string;
  99879. /**
  99880. * Parse a JSON input to create back a background material.
  99881. * @param source The JSON data to parse
  99882. * @param scene The scene to create the parsed material in
  99883. * @param rootUrl The root url of the assets the material depends upon
  99884. * @returns the instantiated BackgroundMaterial.
  99885. */
  99886. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  99887. }
  99888. }
  99889. declare module BABYLON {
  99890. /**
  99891. * Represents the different options available during the creation of
  99892. * a Environment helper.
  99893. *
  99894. * This can control the default ground, skybox and image processing setup of your scene.
  99895. */
  99896. export interface IEnvironmentHelperOptions {
  99897. /**
  99898. * Specifies wether or not to create a ground.
  99899. * True by default.
  99900. */
  99901. createGround: boolean;
  99902. /**
  99903. * Specifies the ground size.
  99904. * 15 by default.
  99905. */
  99906. groundSize: number;
  99907. /**
  99908. * The texture used on the ground for the main color.
  99909. * Comes from the BabylonJS CDN by default.
  99910. *
  99911. * Remarks: Can be either a texture or a url.
  99912. */
  99913. groundTexture: string | BaseTexture;
  99914. /**
  99915. * The color mixed in the ground texture by default.
  99916. * BabylonJS clearColor by default.
  99917. */
  99918. groundColor: Color3;
  99919. /**
  99920. * Specifies the ground opacity.
  99921. * 1 by default.
  99922. */
  99923. groundOpacity: number;
  99924. /**
  99925. * Enables the ground to receive shadows.
  99926. * True by default.
  99927. */
  99928. enableGroundShadow: boolean;
  99929. /**
  99930. * Helps preventing the shadow to be fully black on the ground.
  99931. * 0.5 by default.
  99932. */
  99933. groundShadowLevel: number;
  99934. /**
  99935. * Creates a mirror texture attach to the ground.
  99936. * false by default.
  99937. */
  99938. enableGroundMirror: boolean;
  99939. /**
  99940. * Specifies the ground mirror size ratio.
  99941. * 0.3 by default as the default kernel is 64.
  99942. */
  99943. groundMirrorSizeRatio: number;
  99944. /**
  99945. * Specifies the ground mirror blur kernel size.
  99946. * 64 by default.
  99947. */
  99948. groundMirrorBlurKernel: number;
  99949. /**
  99950. * Specifies the ground mirror visibility amount.
  99951. * 1 by default
  99952. */
  99953. groundMirrorAmount: number;
  99954. /**
  99955. * Specifies the ground mirror reflectance weight.
  99956. * This uses the standard weight of the background material to setup the fresnel effect
  99957. * of the mirror.
  99958. * 1 by default.
  99959. */
  99960. groundMirrorFresnelWeight: number;
  99961. /**
  99962. * Specifies the ground mirror Falloff distance.
  99963. * This can helps reducing the size of the reflection.
  99964. * 0 by Default.
  99965. */
  99966. groundMirrorFallOffDistance: number;
  99967. /**
  99968. * Specifies the ground mirror texture type.
  99969. * Unsigned Int by Default.
  99970. */
  99971. groundMirrorTextureType: number;
  99972. /**
  99973. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  99974. * the shown objects.
  99975. */
  99976. groundYBias: number;
  99977. /**
  99978. * Specifies wether or not to create a skybox.
  99979. * True by default.
  99980. */
  99981. createSkybox: boolean;
  99982. /**
  99983. * Specifies the skybox size.
  99984. * 20 by default.
  99985. */
  99986. skyboxSize: number;
  99987. /**
  99988. * The texture used on the skybox for the main color.
  99989. * Comes from the BabylonJS CDN by default.
  99990. *
  99991. * Remarks: Can be either a texture or a url.
  99992. */
  99993. skyboxTexture: string | BaseTexture;
  99994. /**
  99995. * The color mixed in the skybox texture by default.
  99996. * BabylonJS clearColor by default.
  99997. */
  99998. skyboxColor: Color3;
  99999. /**
  100000. * The background rotation around the Y axis of the scene.
  100001. * This helps aligning the key lights of your scene with the background.
  100002. * 0 by default.
  100003. */
  100004. backgroundYRotation: number;
  100005. /**
  100006. * Compute automatically the size of the elements to best fit with the scene.
  100007. */
  100008. sizeAuto: boolean;
  100009. /**
  100010. * Default position of the rootMesh if autoSize is not true.
  100011. */
  100012. rootPosition: Vector3;
  100013. /**
  100014. * Sets up the image processing in the scene.
  100015. * true by default.
  100016. */
  100017. setupImageProcessing: boolean;
  100018. /**
  100019. * The texture used as your environment texture in the scene.
  100020. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  100021. *
  100022. * Remarks: Can be either a texture or a url.
  100023. */
  100024. environmentTexture: string | BaseTexture;
  100025. /**
  100026. * The value of the exposure to apply to the scene.
  100027. * 0.6 by default if setupImageProcessing is true.
  100028. */
  100029. cameraExposure: number;
  100030. /**
  100031. * The value of the contrast to apply to the scene.
  100032. * 1.6 by default if setupImageProcessing is true.
  100033. */
  100034. cameraContrast: number;
  100035. /**
  100036. * Specifies wether or not tonemapping should be enabled in the scene.
  100037. * true by default if setupImageProcessing is true.
  100038. */
  100039. toneMappingEnabled: boolean;
  100040. }
  100041. /**
  100042. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  100043. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  100044. * It also helps with the default setup of your imageProcessing configuration.
  100045. */
  100046. export class EnvironmentHelper {
  100047. /**
  100048. * Default ground texture URL.
  100049. */
  100050. private static _groundTextureCDNUrl;
  100051. /**
  100052. * Default skybox texture URL.
  100053. */
  100054. private static _skyboxTextureCDNUrl;
  100055. /**
  100056. * Default environment texture URL.
  100057. */
  100058. private static _environmentTextureCDNUrl;
  100059. /**
  100060. * Creates the default options for the helper.
  100061. */
  100062. private static _getDefaultOptions;
  100063. private _rootMesh;
  100064. /**
  100065. * Gets the root mesh created by the helper.
  100066. */
  100067. readonly rootMesh: Mesh;
  100068. private _skybox;
  100069. /**
  100070. * Gets the skybox created by the helper.
  100071. */
  100072. readonly skybox: Nullable<Mesh>;
  100073. private _skyboxTexture;
  100074. /**
  100075. * Gets the skybox texture created by the helper.
  100076. */
  100077. readonly skyboxTexture: Nullable<BaseTexture>;
  100078. private _skyboxMaterial;
  100079. /**
  100080. * Gets the skybox material created by the helper.
  100081. */
  100082. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  100083. private _ground;
  100084. /**
  100085. * Gets the ground mesh created by the helper.
  100086. */
  100087. readonly ground: Nullable<Mesh>;
  100088. private _groundTexture;
  100089. /**
  100090. * Gets the ground texture created by the helper.
  100091. */
  100092. readonly groundTexture: Nullable<BaseTexture>;
  100093. private _groundMirror;
  100094. /**
  100095. * Gets the ground mirror created by the helper.
  100096. */
  100097. readonly groundMirror: Nullable<MirrorTexture>;
  100098. /**
  100099. * Gets the ground mirror render list to helps pushing the meshes
  100100. * you wish in the ground reflection.
  100101. */
  100102. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  100103. private _groundMaterial;
  100104. /**
  100105. * Gets the ground material created by the helper.
  100106. */
  100107. readonly groundMaterial: Nullable<BackgroundMaterial>;
  100108. /**
  100109. * Stores the creation options.
  100110. */
  100111. private readonly _scene;
  100112. private _options;
  100113. /**
  100114. * This observable will be notified with any error during the creation of the environment,
  100115. * mainly texture creation errors.
  100116. */
  100117. onErrorObservable: Observable<{
  100118. message?: string;
  100119. exception?: any;
  100120. }>;
  100121. /**
  100122. * constructor
  100123. * @param options Defines the options we want to customize the helper
  100124. * @param scene The scene to add the material to
  100125. */
  100126. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  100127. /**
  100128. * Updates the background according to the new options
  100129. * @param options
  100130. */
  100131. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  100132. /**
  100133. * Sets the primary color of all the available elements.
  100134. * @param color the main color to affect to the ground and the background
  100135. */
  100136. setMainColor(color: Color3): void;
  100137. /**
  100138. * Setup the image processing according to the specified options.
  100139. */
  100140. private _setupImageProcessing;
  100141. /**
  100142. * Setup the environment texture according to the specified options.
  100143. */
  100144. private _setupEnvironmentTexture;
  100145. /**
  100146. * Setup the background according to the specified options.
  100147. */
  100148. private _setupBackground;
  100149. /**
  100150. * Get the scene sizes according to the setup.
  100151. */
  100152. private _getSceneSize;
  100153. /**
  100154. * Setup the ground according to the specified options.
  100155. */
  100156. private _setupGround;
  100157. /**
  100158. * Setup the ground material according to the specified options.
  100159. */
  100160. private _setupGroundMaterial;
  100161. /**
  100162. * Setup the ground diffuse texture according to the specified options.
  100163. */
  100164. private _setupGroundDiffuseTexture;
  100165. /**
  100166. * Setup the ground mirror texture according to the specified options.
  100167. */
  100168. private _setupGroundMirrorTexture;
  100169. /**
  100170. * Setup the ground to receive the mirror texture.
  100171. */
  100172. private _setupMirrorInGroundMaterial;
  100173. /**
  100174. * Setup the skybox according to the specified options.
  100175. */
  100176. private _setupSkybox;
  100177. /**
  100178. * Setup the skybox material according to the specified options.
  100179. */
  100180. private _setupSkyboxMaterial;
  100181. /**
  100182. * Setup the skybox reflection texture according to the specified options.
  100183. */
  100184. private _setupSkyboxReflectionTexture;
  100185. private _errorHandler;
  100186. /**
  100187. * Dispose all the elements created by the Helper.
  100188. */
  100189. dispose(): void;
  100190. }
  100191. }
  100192. declare module BABYLON {
  100193. /**
  100194. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  100195. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  100196. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  100197. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  100198. */
  100199. export class PhotoDome extends TransformNode {
  100200. private _useDirectMapping;
  100201. /**
  100202. * The texture being displayed on the sphere
  100203. */
  100204. protected _photoTexture: Texture;
  100205. /**
  100206. * Gets or sets the texture being displayed on the sphere
  100207. */
  100208. photoTexture: Texture;
  100209. /**
  100210. * Observable raised when an error occured while loading the 360 image
  100211. */
  100212. onLoadErrorObservable: Observable<string>;
  100213. /**
  100214. * The skybox material
  100215. */
  100216. protected _material: BackgroundMaterial;
  100217. /**
  100218. * The surface used for the skybox
  100219. */
  100220. protected _mesh: Mesh;
  100221. /**
  100222. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100223. * Also see the options.resolution property.
  100224. */
  100225. fovMultiplier: number;
  100226. /**
  100227. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  100228. * @param name Element's name, child elements will append suffixes for their own names.
  100229. * @param urlsOfPhoto defines the url of the photo to display
  100230. * @param options defines an object containing optional or exposed sub element properties
  100231. * @param onError defines a callback called when an error occured while loading the texture
  100232. */
  100233. constructor(name: string, urlOfPhoto: string, options: {
  100234. resolution?: number;
  100235. size?: number;
  100236. useDirectMapping?: boolean;
  100237. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  100238. /**
  100239. * Releases resources associated with this node.
  100240. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100241. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100242. */
  100243. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100244. }
  100245. }
  100246. declare module BABYLON {
  100247. /**
  100248. * Class used to host texture specific utilities
  100249. */
  100250. export class TextureTools {
  100251. /**
  100252. * Uses the GPU to create a copy texture rescaled at a given size
  100253. * @param texture Texture to copy from
  100254. * @param width defines the desired width
  100255. * @param height defines the desired height
  100256. * @param useBilinearMode defines if bilinear mode has to be used
  100257. * @return the generated texture
  100258. */
  100259. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  100260. /**
  100261. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100262. * @param scene defines the hosting scene
  100263. * @returns the environment BRDF texture
  100264. */
  100265. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100266. private static _environmentBRDFBase64Texture;
  100267. }
  100268. }
  100269. declare module BABYLON {
  100270. /**
  100271. * @hidden
  100272. */
  100273. export interface IMaterialClearCoatDefines {
  100274. CLEARCOAT: boolean;
  100275. CLEARCOAT_DEFAULTIOR: boolean;
  100276. CLEARCOAT_TEXTURE: boolean;
  100277. CLEARCOAT_TEXTUREDIRECTUV: number;
  100278. CLEARCOAT_BUMP: boolean;
  100279. CLEARCOAT_BUMPDIRECTUV: number;
  100280. CLEARCOAT_TINT: boolean;
  100281. CLEARCOAT_TINT_TEXTURE: boolean;
  100282. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100283. /** @hidden */
  100284. _areTexturesDirty: boolean;
  100285. }
  100286. /**
  100287. * Define the code related to the clear coat parameters of the pbr material.
  100288. */
  100289. export class PBRClearCoatConfiguration {
  100290. /**
  100291. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100292. * The default fits with a polyurethane material.
  100293. */
  100294. private static readonly _DefaultIndiceOfRefraction;
  100295. private _isEnabled;
  100296. /**
  100297. * Defines if the clear coat is enabled in the material.
  100298. */
  100299. isEnabled: boolean;
  100300. /**
  100301. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100302. */
  100303. intensity: number;
  100304. /**
  100305. * Defines the clear coat layer roughness.
  100306. */
  100307. roughness: number;
  100308. private _indiceOfRefraction;
  100309. /**
  100310. * Defines the indice of refraction of the clear coat.
  100311. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100312. * The default fits with a polyurethane material.
  100313. * Changing the default value is more performance intensive.
  100314. */
  100315. indiceOfRefraction: number;
  100316. private _texture;
  100317. /**
  100318. * Stores the clear coat values in a texture.
  100319. */
  100320. texture: Nullable<BaseTexture>;
  100321. private _bumpTexture;
  100322. /**
  100323. * Define the clear coat specific bump texture.
  100324. */
  100325. bumpTexture: Nullable<BaseTexture>;
  100326. private _isTintEnabled;
  100327. /**
  100328. * Defines if the clear coat tint is enabled in the material.
  100329. */
  100330. isTintEnabled: boolean;
  100331. /**
  100332. * Defines if the clear coat tint is enabled in the material.
  100333. * This is only use if tint is enabled
  100334. */
  100335. tintColor: Color3;
  100336. /**
  100337. * Defines if the distance at which the tint color should be found in the
  100338. * clear coat media.
  100339. * This is only use if tint is enabled
  100340. */
  100341. tintColorAtDistance: number;
  100342. /**
  100343. * Defines the clear coat layer thickness.
  100344. * This is only use if tint is enabled
  100345. */
  100346. tintThickness: number;
  100347. private _tintTexture;
  100348. /**
  100349. * Stores the clear tint values in a texture.
  100350. * rgb is tint
  100351. * a is a thickness factor
  100352. */
  100353. tintTexture: Nullable<BaseTexture>;
  100354. /** @hidden */
  100355. private _internalMarkAllSubMeshesAsTexturesDirty;
  100356. /** @hidden */
  100357. _markAllSubMeshesAsTexturesDirty(): void;
  100358. /**
  100359. * Instantiate a new istance of clear coat configuration.
  100360. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100361. */
  100362. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100363. /**
  100364. * Specifies that the submesh is ready to be used.
  100365. * @param defines the list of "defines" to update.
  100366. * @param scene defines the scene the material belongs to.
  100367. * @param engine defines the engine the material belongs to.
  100368. * @param disableBumpMap defines wether the material disables bump or not.
  100369. * @returns - boolean indicating that the submesh is ready or not.
  100370. */
  100371. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100372. /**
  100373. * Checks to see if a texture is used in the material.
  100374. * @param defines the list of "defines" to update.
  100375. * @param scene defines the scene to the material belongs to.
  100376. */
  100377. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100378. /**
  100379. * Binds the material data.
  100380. * @param uniformBuffer defines the Uniform buffer to fill in.
  100381. * @param scene defines the scene the material belongs to.
  100382. * @param engine defines the engine the material belongs to.
  100383. * @param disableBumpMap defines wether the material disables bump or not.
  100384. * @param isFrozen defines wether the material is frozen or not.
  100385. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100386. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100387. */
  100388. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  100389. /**
  100390. * Checks to see if a texture is used in the material.
  100391. * @param texture - Base texture to use.
  100392. * @returns - Boolean specifying if a texture is used in the material.
  100393. */
  100394. hasTexture(texture: BaseTexture): boolean;
  100395. /**
  100396. * Returns an array of the actively used textures.
  100397. * @param activeTextures Array of BaseTextures
  100398. */
  100399. getActiveTextures(activeTextures: BaseTexture[]): void;
  100400. /**
  100401. * Returns the animatable textures.
  100402. * @param animatables Array of animatable textures.
  100403. */
  100404. getAnimatables(animatables: IAnimatable[]): void;
  100405. /**
  100406. * Disposes the resources of the material.
  100407. * @param forceDisposeTextures - Forces the disposal of all textures.
  100408. */
  100409. dispose(forceDisposeTextures?: boolean): void;
  100410. /**
  100411. * Get the current class name of the texture useful for serialization or dynamic coding.
  100412. * @returns "PBRClearCoatConfiguration"
  100413. */
  100414. getClassName(): string;
  100415. /**
  100416. * Add fallbacks to the effect fallbacks list.
  100417. * @param defines defines the Base texture to use.
  100418. * @param fallbacks defines the current fallback list.
  100419. * @param currentRank defines the current fallback rank.
  100420. * @returns the new fallback rank.
  100421. */
  100422. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100423. /**
  100424. * Add the required uniforms to the current list.
  100425. * @param uniforms defines the current uniform list.
  100426. */
  100427. static AddUniforms(uniforms: string[]): void;
  100428. /**
  100429. * Add the required samplers to the current list.
  100430. * @param samplers defines the current sampler list.
  100431. */
  100432. static AddSamplers(samplers: string[]): void;
  100433. /**
  100434. * Add the required uniforms to the current buffer.
  100435. * @param uniformBuffer defines the current uniform buffer.
  100436. */
  100437. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100438. /**
  100439. * Makes a duplicate of the current configuration into another one.
  100440. * @param clearCoatConfiguration define the config where to copy the info
  100441. */
  100442. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  100443. /**
  100444. * Serializes this clear coat configuration.
  100445. * @returns - An object with the serialized config.
  100446. */
  100447. serialize(): any;
  100448. /**
  100449. * Parses a Clear Coat Configuration from a serialized object.
  100450. * @param source - Serialized object.
  100451. */
  100452. parse(source: any): void;
  100453. }
  100454. }
  100455. declare module BABYLON {
  100456. /**
  100457. * @hidden
  100458. */
  100459. export interface IMaterialAnisotropicDefines {
  100460. ANISOTROPIC: boolean;
  100461. ANISOTROPIC_TEXTURE: boolean;
  100462. ANISOTROPIC_TEXTUREDIRECTUV: number;
  100463. MAINUV1: boolean;
  100464. _areTexturesDirty: boolean;
  100465. _needUVs: boolean;
  100466. }
  100467. /**
  100468. * Define the code related to the anisotropic parameters of the pbr material.
  100469. */
  100470. export class PBRAnisotropicConfiguration {
  100471. private _isEnabled;
  100472. /**
  100473. * Defines if the anisotropy is enabled in the material.
  100474. */
  100475. isEnabled: boolean;
  100476. /**
  100477. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  100478. */
  100479. intensity: number;
  100480. /**
  100481. * Defines if the effect is along the tangents, bitangents or in between.
  100482. * By default, the effect is "strectching" the highlights along the tangents.
  100483. */
  100484. direction: Vector2;
  100485. private _texture;
  100486. /**
  100487. * Stores the anisotropy values in a texture.
  100488. * rg is direction (like normal from -1 to 1)
  100489. * b is a intensity
  100490. */
  100491. texture: Nullable<BaseTexture>;
  100492. /** @hidden */
  100493. private _internalMarkAllSubMeshesAsTexturesDirty;
  100494. /** @hidden */
  100495. _markAllSubMeshesAsTexturesDirty(): void;
  100496. /**
  100497. * Instantiate a new istance of anisotropy configuration.
  100498. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100499. */
  100500. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100501. /**
  100502. * Specifies that the submesh is ready to be used.
  100503. * @param defines the list of "defines" to update.
  100504. * @param scene defines the scene the material belongs to.
  100505. * @returns - boolean indicating that the submesh is ready or not.
  100506. */
  100507. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  100508. /**
  100509. * Checks to see if a texture is used in the material.
  100510. * @param defines the list of "defines" to update.
  100511. * @param mesh the mesh we are preparing the defines for.
  100512. * @param scene defines the scene the material belongs to.
  100513. */
  100514. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  100515. /**
  100516. * Binds the material data.
  100517. * @param uniformBuffer defines the Uniform buffer to fill in.
  100518. * @param scene defines the scene the material belongs to.
  100519. * @param isFrozen defines wether the material is frozen or not.
  100520. */
  100521. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100522. /**
  100523. * Checks to see if a texture is used in the material.
  100524. * @param texture - Base texture to use.
  100525. * @returns - Boolean specifying if a texture is used in the material.
  100526. */
  100527. hasTexture(texture: BaseTexture): boolean;
  100528. /**
  100529. * Returns an array of the actively used textures.
  100530. * @param activeTextures Array of BaseTextures
  100531. */
  100532. getActiveTextures(activeTextures: BaseTexture[]): void;
  100533. /**
  100534. * Returns the animatable textures.
  100535. * @param animatables Array of animatable textures.
  100536. */
  100537. getAnimatables(animatables: IAnimatable[]): void;
  100538. /**
  100539. * Disposes the resources of the material.
  100540. * @param forceDisposeTextures - Forces the disposal of all textures.
  100541. */
  100542. dispose(forceDisposeTextures?: boolean): void;
  100543. /**
  100544. * Get the current class name of the texture useful for serialization or dynamic coding.
  100545. * @returns "PBRAnisotropicConfiguration"
  100546. */
  100547. getClassName(): string;
  100548. /**
  100549. * Add fallbacks to the effect fallbacks list.
  100550. * @param defines defines the Base texture to use.
  100551. * @param fallbacks defines the current fallback list.
  100552. * @param currentRank defines the current fallback rank.
  100553. * @returns the new fallback rank.
  100554. */
  100555. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100556. /**
  100557. * Add the required uniforms to the current list.
  100558. * @param uniforms defines the current uniform list.
  100559. */
  100560. static AddUniforms(uniforms: string[]): void;
  100561. /**
  100562. * Add the required uniforms to the current buffer.
  100563. * @param uniformBuffer defines the current uniform buffer.
  100564. */
  100565. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100566. /**
  100567. * Add the required samplers to the current list.
  100568. * @param samplers defines the current sampler list.
  100569. */
  100570. static AddSamplers(samplers: string[]): void;
  100571. /**
  100572. * Makes a duplicate of the current configuration into another one.
  100573. * @param anisotropicConfiguration define the config where to copy the info
  100574. */
  100575. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  100576. /**
  100577. * Serializes this anisotropy configuration.
  100578. * @returns - An object with the serialized config.
  100579. */
  100580. serialize(): any;
  100581. /**
  100582. * Parses a anisotropy Configuration from a serialized object.
  100583. * @param source - Serialized object.
  100584. */
  100585. parse(source: any): void;
  100586. }
  100587. }
  100588. declare module BABYLON {
  100589. /**
  100590. * @hidden
  100591. */
  100592. export interface IMaterialBRDFDefines {
  100593. BRDF_V_HEIGHT_CORRELATED: boolean;
  100594. MS_BRDF_ENERGY_CONSERVATION: boolean;
  100595. /** @hidden */
  100596. _areMiscDirty: boolean;
  100597. }
  100598. /**
  100599. * Define the code related to the BRDF parameters of the pbr material.
  100600. */
  100601. export class PBRBRDFConfiguration {
  100602. private _useEnergyConservation;
  100603. /**
  100604. * Defines if the material uses energy conservation.
  100605. */
  100606. useEnergyConservation: boolean;
  100607. private _useSmithVisibilityHeightCorrelated;
  100608. /**
  100609. * LEGACY Mode set to false
  100610. * Defines if the material uses height smith correlated visibility term.
  100611. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  100612. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  100613. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  100614. * Not relying on height correlated will also disable energy conservation.
  100615. */
  100616. useSmithVisibilityHeightCorrelated: boolean;
  100617. /** @hidden */
  100618. private _internalMarkAllSubMeshesAsMiscDirty;
  100619. /** @hidden */
  100620. _markAllSubMeshesAsMiscDirty(): void;
  100621. /**
  100622. * Instantiate a new istance of clear coat configuration.
  100623. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  100624. */
  100625. constructor(markAllSubMeshesAsMiscDirty: () => void);
  100626. /**
  100627. * Checks to see if a texture is used in the material.
  100628. * @param defines the list of "defines" to update.
  100629. */
  100630. prepareDefines(defines: IMaterialBRDFDefines): void;
  100631. /**
  100632. * Get the current class name of the texture useful for serialization or dynamic coding.
  100633. * @returns "PBRClearCoatConfiguration"
  100634. */
  100635. getClassName(): string;
  100636. /**
  100637. * Makes a duplicate of the current configuration into another one.
  100638. * @param brdfConfiguration define the config where to copy the info
  100639. */
  100640. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  100641. /**
  100642. * Serializes this BRDF configuration.
  100643. * @returns - An object with the serialized config.
  100644. */
  100645. serialize(): any;
  100646. /**
  100647. * Parses a BRDF Configuration from a serialized object.
  100648. * @param source - Serialized object.
  100649. */
  100650. parse(source: any): void;
  100651. }
  100652. }
  100653. declare module BABYLON {
  100654. /**
  100655. * @hidden
  100656. */
  100657. export interface IMaterialSheenDefines {
  100658. SHEEN: boolean;
  100659. SHEEN_TEXTURE: boolean;
  100660. SHEEN_TEXTUREDIRECTUV: number;
  100661. SHEEN_LINKWITHALBEDO: boolean;
  100662. /** @hidden */
  100663. _areTexturesDirty: boolean;
  100664. }
  100665. /**
  100666. * Define the code related to the Sheen parameters of the pbr material.
  100667. */
  100668. export class PBRSheenConfiguration {
  100669. private _isEnabled;
  100670. /**
  100671. * Defines if the material uses sheen.
  100672. */
  100673. isEnabled: boolean;
  100674. private _linkSheenWithAlbedo;
  100675. /**
  100676. * Defines if the sheen is linked to the sheen color.
  100677. */
  100678. linkSheenWithAlbedo: boolean;
  100679. /**
  100680. * Defines the sheen intensity.
  100681. */
  100682. intensity: number;
  100683. /**
  100684. * Defines the sheen color.
  100685. */
  100686. color: Color3;
  100687. private _texture;
  100688. /**
  100689. * Stores the sheen tint values in a texture.
  100690. * rgb is tint
  100691. * a is a intensity
  100692. */
  100693. texture: Nullable<BaseTexture>;
  100694. /** @hidden */
  100695. private _internalMarkAllSubMeshesAsTexturesDirty;
  100696. /** @hidden */
  100697. _markAllSubMeshesAsTexturesDirty(): void;
  100698. /**
  100699. * Instantiate a new istance of clear coat configuration.
  100700. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100701. */
  100702. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100703. /**
  100704. * Specifies that the submesh is ready to be used.
  100705. * @param defines the list of "defines" to update.
  100706. * @param scene defines the scene the material belongs to.
  100707. * @returns - boolean indicating that the submesh is ready or not.
  100708. */
  100709. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  100710. /**
  100711. * Checks to see if a texture is used in the material.
  100712. * @param defines the list of "defines" to update.
  100713. * @param scene defines the scene the material belongs to.
  100714. */
  100715. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  100716. /**
  100717. * Binds the material data.
  100718. * @param uniformBuffer defines the Uniform buffer to fill in.
  100719. * @param scene defines the scene the material belongs to.
  100720. * @param isFrozen defines wether the material is frozen or not.
  100721. */
  100722. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100723. /**
  100724. * Checks to see if a texture is used in the material.
  100725. * @param texture - Base texture to use.
  100726. * @returns - Boolean specifying if a texture is used in the material.
  100727. */
  100728. hasTexture(texture: BaseTexture): boolean;
  100729. /**
  100730. * Returns an array of the actively used textures.
  100731. * @param activeTextures Array of BaseTextures
  100732. */
  100733. getActiveTextures(activeTextures: BaseTexture[]): void;
  100734. /**
  100735. * Returns the animatable textures.
  100736. * @param animatables Array of animatable textures.
  100737. */
  100738. getAnimatables(animatables: IAnimatable[]): void;
  100739. /**
  100740. * Disposes the resources of the material.
  100741. * @param forceDisposeTextures - Forces the disposal of all textures.
  100742. */
  100743. dispose(forceDisposeTextures?: boolean): void;
  100744. /**
  100745. * Get the current class name of the texture useful for serialization or dynamic coding.
  100746. * @returns "PBRSheenConfiguration"
  100747. */
  100748. getClassName(): string;
  100749. /**
  100750. * Add fallbacks to the effect fallbacks list.
  100751. * @param defines defines the Base texture to use.
  100752. * @param fallbacks defines the current fallback list.
  100753. * @param currentRank defines the current fallback rank.
  100754. * @returns the new fallback rank.
  100755. */
  100756. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100757. /**
  100758. * Add the required uniforms to the current list.
  100759. * @param uniforms defines the current uniform list.
  100760. */
  100761. static AddUniforms(uniforms: string[]): void;
  100762. /**
  100763. * Add the required uniforms to the current buffer.
  100764. * @param uniformBuffer defines the current uniform buffer.
  100765. */
  100766. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100767. /**
  100768. * Add the required samplers to the current list.
  100769. * @param samplers defines the current sampler list.
  100770. */
  100771. static AddSamplers(samplers: string[]): void;
  100772. /**
  100773. * Makes a duplicate of the current configuration into another one.
  100774. * @param sheenConfiguration define the config where to copy the info
  100775. */
  100776. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  100777. /**
  100778. * Serializes this BRDF configuration.
  100779. * @returns - An object with the serialized config.
  100780. */
  100781. serialize(): any;
  100782. /**
  100783. * Parses a Sheen Configuration from a serialized object.
  100784. * @param source - Serialized object.
  100785. */
  100786. parse(source: any): void;
  100787. }
  100788. }
  100789. declare module BABYLON {
  100790. /** @hidden */
  100791. export var pbrFragmentDeclaration: {
  100792. name: string;
  100793. shader: string;
  100794. };
  100795. }
  100796. declare module BABYLON {
  100797. /** @hidden */
  100798. export var pbrUboDeclaration: {
  100799. name: string;
  100800. shader: string;
  100801. };
  100802. }
  100803. declare module BABYLON {
  100804. /** @hidden */
  100805. export var pbrFunctions: {
  100806. name: string;
  100807. shader: string;
  100808. };
  100809. }
  100810. declare module BABYLON {
  100811. /** @hidden */
  100812. export var harmonicsFunctions: {
  100813. name: string;
  100814. shader: string;
  100815. };
  100816. }
  100817. declare module BABYLON {
  100818. /** @hidden */
  100819. export var pbrPreLightingFunctions: {
  100820. name: string;
  100821. shader: string;
  100822. };
  100823. }
  100824. declare module BABYLON {
  100825. /** @hidden */
  100826. export var pbrFalloffLightingFunctions: {
  100827. name: string;
  100828. shader: string;
  100829. };
  100830. }
  100831. declare module BABYLON {
  100832. /** @hidden */
  100833. export var pbrLightingFunctions: {
  100834. name: string;
  100835. shader: string;
  100836. };
  100837. }
  100838. declare module BABYLON {
  100839. /** @hidden */
  100840. export var pbrDebug: {
  100841. name: string;
  100842. shader: string;
  100843. };
  100844. }
  100845. declare module BABYLON {
  100846. /** @hidden */
  100847. export var pbrPixelShader: {
  100848. name: string;
  100849. shader: string;
  100850. };
  100851. }
  100852. declare module BABYLON {
  100853. /** @hidden */
  100854. export var pbrVertexDeclaration: {
  100855. name: string;
  100856. shader: string;
  100857. };
  100858. }
  100859. declare module BABYLON {
  100860. /** @hidden */
  100861. export var pbrVertexShader: {
  100862. name: string;
  100863. shader: string;
  100864. };
  100865. }
  100866. declare module BABYLON {
  100867. /**
  100868. * The Physically based material base class of BJS.
  100869. *
  100870. * This offers the main features of a standard PBR material.
  100871. * For more information, please refer to the documentation :
  100872. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  100873. */
  100874. export abstract class PBRBaseMaterial extends PushMaterial {
  100875. /**
  100876. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  100877. */
  100878. static readonly PBRMATERIAL_OPAQUE: number;
  100879. /**
  100880. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  100881. */
  100882. static readonly PBRMATERIAL_ALPHATEST: number;
  100883. /**
  100884. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100885. */
  100886. static readonly PBRMATERIAL_ALPHABLEND: number;
  100887. /**
  100888. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  100889. * They are also discarded below the alpha cutoff threshold to improve performances.
  100890. */
  100891. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  100892. /**
  100893. * Defines the default value of how much AO map is occluding the analytical lights
  100894. * (point spot...).
  100895. */
  100896. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  100897. /**
  100898. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  100899. */
  100900. static readonly LIGHTFALLOFF_PHYSICAL: number;
  100901. /**
  100902. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  100903. * to enhance interoperability with other engines.
  100904. */
  100905. static readonly LIGHTFALLOFF_GLTF: number;
  100906. /**
  100907. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  100908. * to enhance interoperability with other materials.
  100909. */
  100910. static readonly LIGHTFALLOFF_STANDARD: number;
  100911. /**
  100912. * Intensity of the direct lights e.g. the four lights available in your scene.
  100913. * This impacts both the direct diffuse and specular highlights.
  100914. */
  100915. protected _directIntensity: number;
  100916. /**
  100917. * Intensity of the emissive part of the material.
  100918. * This helps controlling the emissive effect without modifying the emissive color.
  100919. */
  100920. protected _emissiveIntensity: number;
  100921. /**
  100922. * Intensity of the environment e.g. how much the environment will light the object
  100923. * either through harmonics for rough material or through the refelction for shiny ones.
  100924. */
  100925. protected _environmentIntensity: number;
  100926. /**
  100927. * This is a special control allowing the reduction of the specular highlights coming from the
  100928. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  100929. */
  100930. protected _specularIntensity: number;
  100931. /**
  100932. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  100933. */
  100934. private _lightingInfos;
  100935. /**
  100936. * Debug Control allowing disabling the bump map on this material.
  100937. */
  100938. protected _disableBumpMap: boolean;
  100939. /**
  100940. * AKA Diffuse Texture in standard nomenclature.
  100941. */
  100942. protected _albedoTexture: BaseTexture;
  100943. /**
  100944. * AKA Occlusion Texture in other nomenclature.
  100945. */
  100946. protected _ambientTexture: BaseTexture;
  100947. /**
  100948. * AKA Occlusion Texture Intensity in other nomenclature.
  100949. */
  100950. protected _ambientTextureStrength: number;
  100951. /**
  100952. * Defines how much the AO map is occluding the analytical lights (point spot...).
  100953. * 1 means it completely occludes it
  100954. * 0 mean it has no impact
  100955. */
  100956. protected _ambientTextureImpactOnAnalyticalLights: number;
  100957. /**
  100958. * Stores the alpha values in a texture.
  100959. */
  100960. protected _opacityTexture: BaseTexture;
  100961. /**
  100962. * Stores the reflection values in a texture.
  100963. */
  100964. protected _reflectionTexture: BaseTexture;
  100965. /**
  100966. * Stores the refraction values in a texture.
  100967. */
  100968. protected _refractionTexture: BaseTexture;
  100969. /**
  100970. * Stores the emissive values in a texture.
  100971. */
  100972. protected _emissiveTexture: BaseTexture;
  100973. /**
  100974. * AKA Specular texture in other nomenclature.
  100975. */
  100976. protected _reflectivityTexture: BaseTexture;
  100977. /**
  100978. * Used to switch from specular/glossiness to metallic/roughness workflow.
  100979. */
  100980. protected _metallicTexture: BaseTexture;
  100981. /**
  100982. * Specifies the metallic scalar of the metallic/roughness workflow.
  100983. * Can also be used to scale the metalness values of the metallic texture.
  100984. */
  100985. protected _metallic: Nullable<number>;
  100986. /**
  100987. * Specifies the roughness scalar of the metallic/roughness workflow.
  100988. * Can also be used to scale the roughness values of the metallic texture.
  100989. */
  100990. protected _roughness: Nullable<number>;
  100991. /**
  100992. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  100993. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  100994. */
  100995. protected _microSurfaceTexture: BaseTexture;
  100996. /**
  100997. * Stores surface normal data used to displace a mesh in a texture.
  100998. */
  100999. protected _bumpTexture: BaseTexture;
  101000. /**
  101001. * Stores the pre-calculated light information of a mesh in a texture.
  101002. */
  101003. protected _lightmapTexture: BaseTexture;
  101004. /**
  101005. * The color of a material in ambient lighting.
  101006. */
  101007. protected _ambientColor: Color3;
  101008. /**
  101009. * AKA Diffuse Color in other nomenclature.
  101010. */
  101011. protected _albedoColor: Color3;
  101012. /**
  101013. * AKA Specular Color in other nomenclature.
  101014. */
  101015. protected _reflectivityColor: Color3;
  101016. /**
  101017. * The color applied when light is reflected from a material.
  101018. */
  101019. protected _reflectionColor: Color3;
  101020. /**
  101021. * The color applied when light is emitted from a material.
  101022. */
  101023. protected _emissiveColor: Color3;
  101024. /**
  101025. * AKA Glossiness in other nomenclature.
  101026. */
  101027. protected _microSurface: number;
  101028. /**
  101029. * source material index of refraction (IOR)' / 'destination material IOR.
  101030. */
  101031. protected _indexOfRefraction: number;
  101032. /**
  101033. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101034. */
  101035. protected _invertRefractionY: boolean;
  101036. /**
  101037. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101038. * Materials half opaque for instance using refraction could benefit from this control.
  101039. */
  101040. protected _linkRefractionWithTransparency: boolean;
  101041. /**
  101042. * Specifies that the material will use the light map as a show map.
  101043. */
  101044. protected _useLightmapAsShadowmap: boolean;
  101045. /**
  101046. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101047. * makes the reflect vector face the model (under horizon).
  101048. */
  101049. protected _useHorizonOcclusion: boolean;
  101050. /**
  101051. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101052. * too much the area relying on ambient texture to define their ambient occlusion.
  101053. */
  101054. protected _useRadianceOcclusion: boolean;
  101055. /**
  101056. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101057. */
  101058. protected _useAlphaFromAlbedoTexture: boolean;
  101059. /**
  101060. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  101061. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101062. */
  101063. protected _useSpecularOverAlpha: boolean;
  101064. /**
  101065. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101066. */
  101067. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101068. /**
  101069. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101070. */
  101071. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  101072. /**
  101073. * Specifies if the metallic texture contains the roughness information in its green channel.
  101074. */
  101075. protected _useRoughnessFromMetallicTextureGreen: boolean;
  101076. /**
  101077. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101078. */
  101079. protected _useMetallnessFromMetallicTextureBlue: boolean;
  101080. /**
  101081. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101082. */
  101083. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  101084. /**
  101085. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101086. */
  101087. protected _useAmbientInGrayScale: boolean;
  101088. /**
  101089. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101090. * The material will try to infer what glossiness each pixel should be.
  101091. */
  101092. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  101093. /**
  101094. * Defines the falloff type used in this material.
  101095. * It by default is Physical.
  101096. */
  101097. protected _lightFalloff: number;
  101098. /**
  101099. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101100. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101101. */
  101102. protected _useRadianceOverAlpha: boolean;
  101103. /**
  101104. * Allows using an object space normal map (instead of tangent space).
  101105. */
  101106. protected _useObjectSpaceNormalMap: boolean;
  101107. /**
  101108. * Allows using the bump map in parallax mode.
  101109. */
  101110. protected _useParallax: boolean;
  101111. /**
  101112. * Allows using the bump map in parallax occlusion mode.
  101113. */
  101114. protected _useParallaxOcclusion: boolean;
  101115. /**
  101116. * Controls the scale bias of the parallax mode.
  101117. */
  101118. protected _parallaxScaleBias: number;
  101119. /**
  101120. * If sets to true, disables all the lights affecting the material.
  101121. */
  101122. protected _disableLighting: boolean;
  101123. /**
  101124. * Number of Simultaneous lights allowed on the material.
  101125. */
  101126. protected _maxSimultaneousLights: number;
  101127. /**
  101128. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101129. */
  101130. protected _invertNormalMapX: boolean;
  101131. /**
  101132. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101133. */
  101134. protected _invertNormalMapY: boolean;
  101135. /**
  101136. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101137. */
  101138. protected _twoSidedLighting: boolean;
  101139. /**
  101140. * Defines the alpha limits in alpha test mode.
  101141. */
  101142. protected _alphaCutOff: number;
  101143. /**
  101144. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101145. */
  101146. protected _forceAlphaTest: boolean;
  101147. /**
  101148. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101149. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101150. */
  101151. protected _useAlphaFresnel: boolean;
  101152. /**
  101153. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101154. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101155. */
  101156. protected _useLinearAlphaFresnel: boolean;
  101157. /**
  101158. * The transparency mode of the material.
  101159. */
  101160. protected _transparencyMode: Nullable<number>;
  101161. /**
  101162. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  101163. * from cos thetav and roughness:
  101164. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  101165. */
  101166. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  101167. /**
  101168. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101169. */
  101170. protected _forceIrradianceInFragment: boolean;
  101171. /**
  101172. * Force normal to face away from face.
  101173. */
  101174. protected _forceNormalForward: boolean;
  101175. /**
  101176. * Enables specular anti aliasing in the PBR shader.
  101177. * It will both interacts on the Geometry for analytical and IBL lighting.
  101178. * It also prefilter the roughness map based on the bump values.
  101179. */
  101180. protected _enableSpecularAntiAliasing: boolean;
  101181. /**
  101182. * Default configuration related to image processing available in the PBR Material.
  101183. */
  101184. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101185. /**
  101186. * Keep track of the image processing observer to allow dispose and replace.
  101187. */
  101188. private _imageProcessingObserver;
  101189. /**
  101190. * Attaches a new image processing configuration to the PBR Material.
  101191. * @param configuration
  101192. */
  101193. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101194. /**
  101195. * Stores the available render targets.
  101196. */
  101197. private _renderTargets;
  101198. /**
  101199. * Sets the global ambient color for the material used in lighting calculations.
  101200. */
  101201. private _globalAmbientColor;
  101202. /**
  101203. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  101204. */
  101205. private _useLogarithmicDepth;
  101206. /**
  101207. * If set to true, no lighting calculations will be applied.
  101208. */
  101209. private _unlit;
  101210. private _debugMode;
  101211. /**
  101212. * @hidden
  101213. * This is reserved for the inspector.
  101214. * Defines the material debug mode.
  101215. * It helps seeing only some components of the material while troubleshooting.
  101216. */
  101217. debugMode: number;
  101218. /**
  101219. * @hidden
  101220. * This is reserved for the inspector.
  101221. * Specify from where on screen the debug mode should start.
  101222. * The value goes from -1 (full screen) to 1 (not visible)
  101223. * It helps with side by side comparison against the final render
  101224. * This defaults to -1
  101225. */
  101226. private debugLimit;
  101227. /**
  101228. * @hidden
  101229. * This is reserved for the inspector.
  101230. * As the default viewing range might not be enough (if the ambient is really small for instance)
  101231. * You can use the factor to better multiply the final value.
  101232. */
  101233. private debugFactor;
  101234. /**
  101235. * Defines the clear coat layer parameters for the material.
  101236. */
  101237. readonly clearCoat: PBRClearCoatConfiguration;
  101238. /**
  101239. * Defines the anisotropic parameters for the material.
  101240. */
  101241. readonly anisotropy: PBRAnisotropicConfiguration;
  101242. /**
  101243. * Defines the BRDF parameters for the material.
  101244. */
  101245. readonly brdf: PBRBRDFConfiguration;
  101246. /**
  101247. * Defines the Sheen parameters for the material.
  101248. */
  101249. readonly sheen: PBRSheenConfiguration;
  101250. /**
  101251. * Instantiates a new PBRMaterial instance.
  101252. *
  101253. * @param name The material name
  101254. * @param scene The scene the material will be use in.
  101255. */
  101256. constructor(name: string, scene: Scene);
  101257. /**
  101258. * Gets a boolean indicating that current material needs to register RTT
  101259. */
  101260. readonly hasRenderTargetTextures: boolean;
  101261. /**
  101262. * Gets the name of the material class.
  101263. */
  101264. getClassName(): string;
  101265. /**
  101266. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101267. */
  101268. /**
  101269. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  101270. */
  101271. useLogarithmicDepth: boolean;
  101272. /**
  101273. * Gets the current transparency mode.
  101274. */
  101275. /**
  101276. * Sets the transparency mode of the material.
  101277. *
  101278. * | Value | Type | Description |
  101279. * | ----- | ----------------------------------- | ----------- |
  101280. * | 0 | OPAQUE | |
  101281. * | 1 | ALPHATEST | |
  101282. * | 2 | ALPHABLEND | |
  101283. * | 3 | ALPHATESTANDBLEND | |
  101284. *
  101285. */
  101286. transparencyMode: Nullable<number>;
  101287. /**
  101288. * Returns true if alpha blending should be disabled.
  101289. */
  101290. private readonly _disableAlphaBlending;
  101291. /**
  101292. * Specifies whether or not this material should be rendered in alpha blend mode.
  101293. */
  101294. needAlphaBlending(): boolean;
  101295. /**
  101296. * Specifies if the mesh will require alpha blending.
  101297. * @param mesh - BJS mesh.
  101298. */
  101299. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101300. /**
  101301. * Specifies whether or not this material should be rendered in alpha test mode.
  101302. */
  101303. needAlphaTesting(): boolean;
  101304. /**
  101305. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  101306. */
  101307. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  101308. /**
  101309. * Gets the texture used for the alpha test.
  101310. */
  101311. getAlphaTestTexture(): BaseTexture;
  101312. /**
  101313. * Specifies that the submesh is ready to be used.
  101314. * @param mesh - BJS mesh.
  101315. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  101316. * @param useInstances - Specifies that instances should be used.
  101317. * @returns - boolean indicating that the submesh is ready or not.
  101318. */
  101319. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101320. /**
  101321. * Specifies if the material uses metallic roughness workflow.
  101322. * @returns boolean specifiying if the material uses metallic roughness workflow.
  101323. */
  101324. isMetallicWorkflow(): boolean;
  101325. private _prepareEffect;
  101326. private _prepareDefines;
  101327. /**
  101328. * Force shader compilation
  101329. */
  101330. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  101331. clipPlane: boolean;
  101332. }>): void;
  101333. /**
  101334. * Initializes the uniform buffer layout for the shader.
  101335. */
  101336. buildUniformLayout(): void;
  101337. /**
  101338. * Unbinds the textures.
  101339. */
  101340. unbind(): void;
  101341. /**
  101342. * Binds the submesh data.
  101343. * @param world - The world matrix.
  101344. * @param mesh - The BJS mesh.
  101345. * @param subMesh - A submesh of the BJS mesh.
  101346. */
  101347. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101348. /**
  101349. * Returns the animatable textures.
  101350. * @returns - Array of animatable textures.
  101351. */
  101352. getAnimatables(): IAnimatable[];
  101353. /**
  101354. * Returns the texture used for reflections.
  101355. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  101356. */
  101357. private _getReflectionTexture;
  101358. /**
  101359. * Returns the texture used for refraction or null if none is used.
  101360. * @returns - Refection texture if present. If no refraction texture and refraction
  101361. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101362. */
  101363. private _getRefractionTexture;
  101364. /**
  101365. * Returns an array of the actively used textures.
  101366. * @returns - Array of BaseTextures
  101367. */
  101368. getActiveTextures(): BaseTexture[];
  101369. /**
  101370. * Checks to see if a texture is used in the material.
  101371. * @param texture - Base texture to use.
  101372. * @returns - Boolean specifying if a texture is used in the material.
  101373. */
  101374. hasTexture(texture: BaseTexture): boolean;
  101375. /**
  101376. * Disposes the resources of the material.
  101377. * @param forceDisposeEffect - Forces the disposal of effects.
  101378. * @param forceDisposeTextures - Forces the disposal of all textures.
  101379. */
  101380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101381. }
  101382. }
  101383. declare module BABYLON {
  101384. /**
  101385. * The Physically based material of BJS.
  101386. *
  101387. * This offers the main features of a standard PBR material.
  101388. * For more information, please refer to the documentation :
  101389. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101390. */
  101391. export class PBRMaterial extends PBRBaseMaterial {
  101392. /**
  101393. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101394. */
  101395. static readonly PBRMATERIAL_OPAQUE: number;
  101396. /**
  101397. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101398. */
  101399. static readonly PBRMATERIAL_ALPHATEST: number;
  101400. /**
  101401. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101402. */
  101403. static readonly PBRMATERIAL_ALPHABLEND: number;
  101404. /**
  101405. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101406. * They are also discarded below the alpha cutoff threshold to improve performances.
  101407. */
  101408. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101409. /**
  101410. * Defines the default value of how much AO map is occluding the analytical lights
  101411. * (point spot...).
  101412. */
  101413. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101414. /**
  101415. * Intensity of the direct lights e.g. the four lights available in your scene.
  101416. * This impacts both the direct diffuse and specular highlights.
  101417. */
  101418. directIntensity: number;
  101419. /**
  101420. * Intensity of the emissive part of the material.
  101421. * This helps controlling the emissive effect without modifying the emissive color.
  101422. */
  101423. emissiveIntensity: number;
  101424. /**
  101425. * Intensity of the environment e.g. how much the environment will light the object
  101426. * either through harmonics for rough material or through the refelction for shiny ones.
  101427. */
  101428. environmentIntensity: number;
  101429. /**
  101430. * This is a special control allowing the reduction of the specular highlights coming from the
  101431. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  101432. */
  101433. specularIntensity: number;
  101434. /**
  101435. * Debug Control allowing disabling the bump map on this material.
  101436. */
  101437. disableBumpMap: boolean;
  101438. /**
  101439. * AKA Diffuse Texture in standard nomenclature.
  101440. */
  101441. albedoTexture: BaseTexture;
  101442. /**
  101443. * AKA Occlusion Texture in other nomenclature.
  101444. */
  101445. ambientTexture: BaseTexture;
  101446. /**
  101447. * AKA Occlusion Texture Intensity in other nomenclature.
  101448. */
  101449. ambientTextureStrength: number;
  101450. /**
  101451. * Defines how much the AO map is occluding the analytical lights (point spot...).
  101452. * 1 means it completely occludes it
  101453. * 0 mean it has no impact
  101454. */
  101455. ambientTextureImpactOnAnalyticalLights: number;
  101456. /**
  101457. * Stores the alpha values in a texture.
  101458. */
  101459. opacityTexture: BaseTexture;
  101460. /**
  101461. * Stores the reflection values in a texture.
  101462. */
  101463. reflectionTexture: Nullable<BaseTexture>;
  101464. /**
  101465. * Stores the emissive values in a texture.
  101466. */
  101467. emissiveTexture: BaseTexture;
  101468. /**
  101469. * AKA Specular texture in other nomenclature.
  101470. */
  101471. reflectivityTexture: BaseTexture;
  101472. /**
  101473. * Used to switch from specular/glossiness to metallic/roughness workflow.
  101474. */
  101475. metallicTexture: BaseTexture;
  101476. /**
  101477. * Specifies the metallic scalar of the metallic/roughness workflow.
  101478. * Can also be used to scale the metalness values of the metallic texture.
  101479. */
  101480. metallic: Nullable<number>;
  101481. /**
  101482. * Specifies the roughness scalar of the metallic/roughness workflow.
  101483. * Can also be used to scale the roughness values of the metallic texture.
  101484. */
  101485. roughness: Nullable<number>;
  101486. /**
  101487. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  101488. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  101489. */
  101490. microSurfaceTexture: BaseTexture;
  101491. /**
  101492. * Stores surface normal data used to displace a mesh in a texture.
  101493. */
  101494. bumpTexture: BaseTexture;
  101495. /**
  101496. * Stores the pre-calculated light information of a mesh in a texture.
  101497. */
  101498. lightmapTexture: BaseTexture;
  101499. /**
  101500. * Stores the refracted light information in a texture.
  101501. */
  101502. refractionTexture: BaseTexture;
  101503. /**
  101504. * The color of a material in ambient lighting.
  101505. */
  101506. ambientColor: Color3;
  101507. /**
  101508. * AKA Diffuse Color in other nomenclature.
  101509. */
  101510. albedoColor: Color3;
  101511. /**
  101512. * AKA Specular Color in other nomenclature.
  101513. */
  101514. reflectivityColor: Color3;
  101515. /**
  101516. * The color reflected from the material.
  101517. */
  101518. reflectionColor: Color3;
  101519. /**
  101520. * The color emitted from the material.
  101521. */
  101522. emissiveColor: Color3;
  101523. /**
  101524. * AKA Glossiness in other nomenclature.
  101525. */
  101526. microSurface: number;
  101527. /**
  101528. * source material index of refraction (IOR)' / 'destination material IOR.
  101529. */
  101530. indexOfRefraction: number;
  101531. /**
  101532. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101533. */
  101534. invertRefractionY: boolean;
  101535. /**
  101536. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101537. * Materials half opaque for instance using refraction could benefit from this control.
  101538. */
  101539. linkRefractionWithTransparency: boolean;
  101540. /**
  101541. * If true, the light map contains occlusion information instead of lighting info.
  101542. */
  101543. useLightmapAsShadowmap: boolean;
  101544. /**
  101545. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  101546. */
  101547. useAlphaFromAlbedoTexture: boolean;
  101548. /**
  101549. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101550. */
  101551. forceAlphaTest: boolean;
  101552. /**
  101553. * Defines the alpha limits in alpha test mode.
  101554. */
  101555. alphaCutOff: number;
  101556. /**
  101557. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101558. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101559. */
  101560. useSpecularOverAlpha: boolean;
  101561. /**
  101562. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  101563. */
  101564. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  101565. /**
  101566. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  101567. */
  101568. useRoughnessFromMetallicTextureAlpha: boolean;
  101569. /**
  101570. * Specifies if the metallic texture contains the roughness information in its green channel.
  101571. */
  101572. useRoughnessFromMetallicTextureGreen: boolean;
  101573. /**
  101574. * Specifies if the metallic texture contains the metallness information in its blue channel.
  101575. */
  101576. useMetallnessFromMetallicTextureBlue: boolean;
  101577. /**
  101578. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  101579. */
  101580. useAmbientOcclusionFromMetallicTextureRed: boolean;
  101581. /**
  101582. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  101583. */
  101584. useAmbientInGrayScale: boolean;
  101585. /**
  101586. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  101587. * The material will try to infer what glossiness each pixel should be.
  101588. */
  101589. useAutoMicroSurfaceFromReflectivityMap: boolean;
  101590. /**
  101591. * BJS is using an harcoded light falloff based on a manually sets up range.
  101592. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101593. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101594. */
  101595. /**
  101596. * BJS is using an harcoded light falloff based on a manually sets up range.
  101597. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  101598. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  101599. */
  101600. usePhysicalLightFalloff: boolean;
  101601. /**
  101602. * In order to support the falloff compatibility with gltf, a special mode has been added
  101603. * to reproduce the gltf light falloff.
  101604. */
  101605. /**
  101606. * In order to support the falloff compatibility with gltf, a special mode has been added
  101607. * to reproduce the gltf light falloff.
  101608. */
  101609. useGLTFLightFalloff: boolean;
  101610. /**
  101611. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101612. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101613. */
  101614. useRadianceOverAlpha: boolean;
  101615. /**
  101616. * Allows using an object space normal map (instead of tangent space).
  101617. */
  101618. useObjectSpaceNormalMap: boolean;
  101619. /**
  101620. * Allows using the bump map in parallax mode.
  101621. */
  101622. useParallax: boolean;
  101623. /**
  101624. * Allows using the bump map in parallax occlusion mode.
  101625. */
  101626. useParallaxOcclusion: boolean;
  101627. /**
  101628. * Controls the scale bias of the parallax mode.
  101629. */
  101630. parallaxScaleBias: number;
  101631. /**
  101632. * If sets to true, disables all the lights affecting the material.
  101633. */
  101634. disableLighting: boolean;
  101635. /**
  101636. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  101637. */
  101638. forceIrradianceInFragment: boolean;
  101639. /**
  101640. * Number of Simultaneous lights allowed on the material.
  101641. */
  101642. maxSimultaneousLights: number;
  101643. /**
  101644. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101645. */
  101646. invertNormalMapX: boolean;
  101647. /**
  101648. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101649. */
  101650. invertNormalMapY: boolean;
  101651. /**
  101652. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101653. */
  101654. twoSidedLighting: boolean;
  101655. /**
  101656. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101657. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  101658. */
  101659. useAlphaFresnel: boolean;
  101660. /**
  101661. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  101662. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  101663. */
  101664. useLinearAlphaFresnel: boolean;
  101665. /**
  101666. * Let user defines the brdf lookup texture used for IBL.
  101667. * A default 8bit version is embedded but you could point at :
  101668. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  101669. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101670. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101671. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101672. */
  101673. environmentBRDFTexture: Nullable<BaseTexture>;
  101674. /**
  101675. * Force normal to face away from face.
  101676. */
  101677. forceNormalForward: boolean;
  101678. /**
  101679. * Enables specular anti aliasing in the PBR shader.
  101680. * It will both interacts on the Geometry for analytical and IBL lighting.
  101681. * It also prefilter the roughness map based on the bump values.
  101682. */
  101683. enableSpecularAntiAliasing: boolean;
  101684. /**
  101685. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  101686. * makes the reflect vector face the model (under horizon).
  101687. */
  101688. useHorizonOcclusion: boolean;
  101689. /**
  101690. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  101691. * too much the area relying on ambient texture to define their ambient occlusion.
  101692. */
  101693. useRadianceOcclusion: boolean;
  101694. /**
  101695. * If set to true, no lighting calculations will be applied.
  101696. */
  101697. unlit: boolean;
  101698. /**
  101699. * Gets the image processing configuration used either in this material.
  101700. */
  101701. /**
  101702. * Sets the Default image processing configuration used either in the this material.
  101703. *
  101704. * If sets to null, the scene one is in use.
  101705. */
  101706. imageProcessingConfiguration: ImageProcessingConfiguration;
  101707. /**
  101708. * Gets wether the color curves effect is enabled.
  101709. */
  101710. /**
  101711. * Sets wether the color curves effect is enabled.
  101712. */
  101713. cameraColorCurvesEnabled: boolean;
  101714. /**
  101715. * Gets wether the color grading effect is enabled.
  101716. */
  101717. /**
  101718. * Gets wether the color grading effect is enabled.
  101719. */
  101720. cameraColorGradingEnabled: boolean;
  101721. /**
  101722. * Gets wether tonemapping is enabled or not.
  101723. */
  101724. /**
  101725. * Sets wether tonemapping is enabled or not
  101726. */
  101727. cameraToneMappingEnabled: boolean;
  101728. /**
  101729. * The camera exposure used on this material.
  101730. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101731. * This corresponds to a photographic exposure.
  101732. */
  101733. /**
  101734. * The camera exposure used on this material.
  101735. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101736. * This corresponds to a photographic exposure.
  101737. */
  101738. cameraExposure: number;
  101739. /**
  101740. * Gets The camera contrast used on this material.
  101741. */
  101742. /**
  101743. * Sets The camera contrast used on this material.
  101744. */
  101745. cameraContrast: number;
  101746. /**
  101747. * Gets the Color Grading 2D Lookup Texture.
  101748. */
  101749. /**
  101750. * Sets the Color Grading 2D Lookup Texture.
  101751. */
  101752. cameraColorGradingTexture: Nullable<BaseTexture>;
  101753. /**
  101754. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101755. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101756. * 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;
  101757. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101758. */
  101759. /**
  101760. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101761. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101762. * 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;
  101763. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101764. */
  101765. cameraColorCurves: Nullable<ColorCurves>;
  101766. /**
  101767. * Instantiates a new PBRMaterial instance.
  101768. *
  101769. * @param name The material name
  101770. * @param scene The scene the material will be use in.
  101771. */
  101772. constructor(name: string, scene: Scene);
  101773. /**
  101774. * Returns the name of this material class.
  101775. */
  101776. getClassName(): string;
  101777. /**
  101778. * Makes a duplicate of the current material.
  101779. * @param name - name to use for the new material.
  101780. */
  101781. clone(name: string): PBRMaterial;
  101782. /**
  101783. * Serializes this PBR Material.
  101784. * @returns - An object with the serialized material.
  101785. */
  101786. serialize(): any;
  101787. /**
  101788. * Parses a PBR Material from a serialized object.
  101789. * @param source - Serialized object.
  101790. * @param scene - BJS scene instance.
  101791. * @param rootUrl - url for the scene object
  101792. * @returns - PBRMaterial
  101793. */
  101794. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  101795. }
  101796. }
  101797. declare module BABYLON {
  101798. /**
  101799. * Direct draw surface info
  101800. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  101801. */
  101802. export interface DDSInfo {
  101803. /**
  101804. * Width of the texture
  101805. */
  101806. width: number;
  101807. /**
  101808. * Width of the texture
  101809. */
  101810. height: number;
  101811. /**
  101812. * Number of Mipmaps for the texture
  101813. * @see https://en.wikipedia.org/wiki/Mipmap
  101814. */
  101815. mipmapCount: number;
  101816. /**
  101817. * If the textures format is a known fourCC format
  101818. * @see https://www.fourcc.org/
  101819. */
  101820. isFourCC: boolean;
  101821. /**
  101822. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  101823. */
  101824. isRGB: boolean;
  101825. /**
  101826. * If the texture is a lumincance format
  101827. */
  101828. isLuminance: boolean;
  101829. /**
  101830. * If this is a cube texture
  101831. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  101832. */
  101833. isCube: boolean;
  101834. /**
  101835. * If the texture is a compressed format eg. FOURCC_DXT1
  101836. */
  101837. isCompressed: boolean;
  101838. /**
  101839. * The dxgiFormat of the texture
  101840. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  101841. */
  101842. dxgiFormat: number;
  101843. /**
  101844. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  101845. */
  101846. textureType: number;
  101847. /**
  101848. * Sphericle polynomial created for the dds texture
  101849. */
  101850. sphericalPolynomial?: SphericalPolynomial;
  101851. }
  101852. /**
  101853. * Class used to provide DDS decompression tools
  101854. */
  101855. export class DDSTools {
  101856. /**
  101857. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  101858. */
  101859. static StoreLODInAlphaChannel: boolean;
  101860. /**
  101861. * Gets DDS information from an array buffer
  101862. * @param arrayBuffer defines the array buffer to read data from
  101863. * @returns the DDS information
  101864. */
  101865. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  101866. private static _FloatView;
  101867. private static _Int32View;
  101868. private static _ToHalfFloat;
  101869. private static _FromHalfFloat;
  101870. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  101871. private static _GetHalfFloatRGBAArrayBuffer;
  101872. private static _GetFloatRGBAArrayBuffer;
  101873. private static _GetFloatAsUIntRGBAArrayBuffer;
  101874. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  101875. private static _GetRGBAArrayBuffer;
  101876. private static _ExtractLongWordOrder;
  101877. private static _GetRGBArrayBuffer;
  101878. private static _GetLuminanceArrayBuffer;
  101879. /**
  101880. * Uploads DDS Levels to a Babylon Texture
  101881. * @hidden
  101882. */
  101883. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  101884. }
  101885. interface Engine {
  101886. /**
  101887. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  101888. * @param rootUrl defines the url where the file to load is located
  101889. * @param scene defines the current scene
  101890. * @param lodScale defines scale to apply to the mip map selection
  101891. * @param lodOffset defines offset to apply to the mip map selection
  101892. * @param onLoad defines an optional callback raised when the texture is loaded
  101893. * @param onError defines an optional callback raised if there is an issue to load the texture
  101894. * @param format defines the format of the data
  101895. * @param forcedExtension defines the extension to use to pick the right loader
  101896. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  101897. * @returns the cube texture as an InternalTexture
  101898. */
  101899. 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;
  101900. }
  101901. }
  101902. declare module BABYLON {
  101903. /**
  101904. * Implementation of the DDS Texture Loader.
  101905. * @hidden
  101906. */
  101907. export class _DDSTextureLoader implements IInternalTextureLoader {
  101908. /**
  101909. * Defines wether the loader supports cascade loading the different faces.
  101910. */
  101911. readonly supportCascades: boolean;
  101912. /**
  101913. * This returns if the loader support the current file information.
  101914. * @param extension defines the file extension of the file being loaded
  101915. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101916. * @param fallback defines the fallback internal texture if any
  101917. * @param isBase64 defines whether the texture is encoded as a base64
  101918. * @param isBuffer defines whether the texture data are stored as a buffer
  101919. * @returns true if the loader can load the specified file
  101920. */
  101921. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  101922. /**
  101923. * Transform the url before loading if required.
  101924. * @param rootUrl the url of the texture
  101925. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101926. * @returns the transformed texture
  101927. */
  101928. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  101929. /**
  101930. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  101931. * @param rootUrl the url of the texture
  101932. * @param textureFormatInUse defines the current compressed format in use iun the engine
  101933. * @returns the fallback texture
  101934. */
  101935. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  101936. /**
  101937. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  101938. * @param data contains the texture data
  101939. * @param texture defines the BabylonJS internal texture
  101940. * @param createPolynomials will be true if polynomials have been requested
  101941. * @param onLoad defines the callback to trigger once the texture is ready
  101942. * @param onError defines the callback to trigger in case of error
  101943. */
  101944. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  101945. /**
  101946. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  101947. * @param data contains the texture data
  101948. * @param texture defines the BabylonJS internal texture
  101949. * @param callback defines the method to call once ready to upload
  101950. */
  101951. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  101952. }
  101953. }
  101954. declare module BABYLON {
  101955. /** @hidden */
  101956. export var rgbdEncodePixelShader: {
  101957. name: string;
  101958. shader: string;
  101959. };
  101960. }
  101961. declare module BABYLON {
  101962. /** @hidden */
  101963. export var rgbdDecodePixelShader: {
  101964. name: string;
  101965. shader: string;
  101966. };
  101967. }
  101968. declare module BABYLON {
  101969. /**
  101970. * Raw texture data and descriptor sufficient for WebGL texture upload
  101971. */
  101972. export interface EnvironmentTextureInfo {
  101973. /**
  101974. * Version of the environment map
  101975. */
  101976. version: number;
  101977. /**
  101978. * Width of image
  101979. */
  101980. width: number;
  101981. /**
  101982. * Irradiance information stored in the file.
  101983. */
  101984. irradiance: any;
  101985. /**
  101986. * Specular information stored in the file.
  101987. */
  101988. specular: any;
  101989. }
  101990. /**
  101991. * Sets of helpers addressing the serialization and deserialization of environment texture
  101992. * stored in a BabylonJS env file.
  101993. * Those files are usually stored as .env files.
  101994. */
  101995. export class EnvironmentTextureTools {
  101996. /**
  101997. * Magic number identifying the env file.
  101998. */
  101999. private static _MagicBytes;
  102000. /**
  102001. * Gets the environment info from an env file.
  102002. * @param data The array buffer containing the .env bytes.
  102003. * @returns the environment file info (the json header) if successfully parsed.
  102004. */
  102005. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102006. /**
  102007. * Creates an environment texture from a loaded cube texture.
  102008. * @param texture defines the cube texture to convert in env file
  102009. * @return a promise containing the environment data if succesfull.
  102010. */
  102011. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102012. /**
  102013. * Creates a JSON representation of the spherical data.
  102014. * @param texture defines the texture containing the polynomials
  102015. * @return the JSON representation of the spherical info
  102016. */
  102017. private static _CreateEnvTextureIrradiance;
  102018. /**
  102019. * Uploads the texture info contained in the env file to the GPU.
  102020. * @param texture defines the internal texture to upload to
  102021. * @param arrayBuffer defines the buffer cotaining the data to load
  102022. * @param info defines the texture info retrieved through the GetEnvInfo method
  102023. * @returns a promise
  102024. */
  102025. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102026. /**
  102027. * Uploads the levels of image data to the GPU.
  102028. * @param texture defines the internal texture to upload to
  102029. * @param imageData defines the array buffer views of image data [mipmap][face]
  102030. * @returns a promise
  102031. */
  102032. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102033. /**
  102034. * Uploads spherical polynomials information to the texture.
  102035. * @param texture defines the texture we are trying to upload the information to
  102036. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102037. */
  102038. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102039. /** @hidden */
  102040. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102041. }
  102042. }
  102043. declare module BABYLON {
  102044. /**
  102045. * Implementation of the ENV Texture Loader.
  102046. * @hidden
  102047. */
  102048. export class _ENVTextureLoader implements IInternalTextureLoader {
  102049. /**
  102050. * Defines wether the loader supports cascade loading the different faces.
  102051. */
  102052. readonly supportCascades: boolean;
  102053. /**
  102054. * This returns if the loader support the current file information.
  102055. * @param extension defines the file extension of the file being loaded
  102056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102057. * @param fallback defines the fallback internal texture if any
  102058. * @param isBase64 defines whether the texture is encoded as a base64
  102059. * @param isBuffer defines whether the texture data are stored as a buffer
  102060. * @returns true if the loader can load the specified file
  102061. */
  102062. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102063. /**
  102064. * Transform the url before loading if required.
  102065. * @param rootUrl the url of the texture
  102066. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102067. * @returns the transformed texture
  102068. */
  102069. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102070. /**
  102071. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102072. * @param rootUrl the url of the texture
  102073. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102074. * @returns the fallback texture
  102075. */
  102076. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102077. /**
  102078. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102079. * @param data contains the texture data
  102080. * @param texture defines the BabylonJS internal texture
  102081. * @param createPolynomials will be true if polynomials have been requested
  102082. * @param onLoad defines the callback to trigger once the texture is ready
  102083. * @param onError defines the callback to trigger in case of error
  102084. */
  102085. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102086. /**
  102087. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102088. * @param data contains the texture data
  102089. * @param texture defines the BabylonJS internal texture
  102090. * @param callback defines the method to call once ready to upload
  102091. */
  102092. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102093. }
  102094. }
  102095. declare module BABYLON {
  102096. /**
  102097. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102098. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102099. */
  102100. export class KhronosTextureContainer {
  102101. /** contents of the KTX container file */
  102102. arrayBuffer: any;
  102103. private static HEADER_LEN;
  102104. private static COMPRESSED_2D;
  102105. private static COMPRESSED_3D;
  102106. private static TEX_2D;
  102107. private static TEX_3D;
  102108. /**
  102109. * Gets the openGL type
  102110. */
  102111. glType: number;
  102112. /**
  102113. * Gets the openGL type size
  102114. */
  102115. glTypeSize: number;
  102116. /**
  102117. * Gets the openGL format
  102118. */
  102119. glFormat: number;
  102120. /**
  102121. * Gets the openGL internal format
  102122. */
  102123. glInternalFormat: number;
  102124. /**
  102125. * Gets the base internal format
  102126. */
  102127. glBaseInternalFormat: number;
  102128. /**
  102129. * Gets image width in pixel
  102130. */
  102131. pixelWidth: number;
  102132. /**
  102133. * Gets image height in pixel
  102134. */
  102135. pixelHeight: number;
  102136. /**
  102137. * Gets image depth in pixels
  102138. */
  102139. pixelDepth: number;
  102140. /**
  102141. * Gets the number of array elements
  102142. */
  102143. numberOfArrayElements: number;
  102144. /**
  102145. * Gets the number of faces
  102146. */
  102147. numberOfFaces: number;
  102148. /**
  102149. * Gets the number of mipmap levels
  102150. */
  102151. numberOfMipmapLevels: number;
  102152. /**
  102153. * Gets the bytes of key value data
  102154. */
  102155. bytesOfKeyValueData: number;
  102156. /**
  102157. * Gets the load type
  102158. */
  102159. loadType: number;
  102160. /**
  102161. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102162. */
  102163. isInvalid: boolean;
  102164. /**
  102165. * Creates a new KhronosTextureContainer
  102166. * @param arrayBuffer contents of the KTX container file
  102167. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102168. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102169. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102170. */
  102171. constructor(
  102172. /** contents of the KTX container file */
  102173. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102174. /**
  102175. * Uploads KTX content to a Babylon Texture.
  102176. * It is assumed that the texture has already been created & is currently bound
  102177. * @hidden
  102178. */
  102179. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102180. private _upload2DCompressedLevels;
  102181. }
  102182. }
  102183. declare module BABYLON {
  102184. /**
  102185. * Implementation of the KTX Texture Loader.
  102186. * @hidden
  102187. */
  102188. export class _KTXTextureLoader implements IInternalTextureLoader {
  102189. /**
  102190. * Defines wether the loader supports cascade loading the different faces.
  102191. */
  102192. readonly supportCascades: boolean;
  102193. /**
  102194. * This returns if the loader support the current file information.
  102195. * @param extension defines the file extension of the file being loaded
  102196. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102197. * @param fallback defines the fallback internal texture if any
  102198. * @param isBase64 defines whether the texture is encoded as a base64
  102199. * @param isBuffer defines whether the texture data are stored as a buffer
  102200. * @returns true if the loader can load the specified file
  102201. */
  102202. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102203. /**
  102204. * Transform the url before loading if required.
  102205. * @param rootUrl the url of the texture
  102206. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102207. * @returns the transformed texture
  102208. */
  102209. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102210. /**
  102211. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102212. * @param rootUrl the url of the texture
  102213. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102214. * @returns the fallback texture
  102215. */
  102216. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102217. /**
  102218. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102219. * @param data contains the texture data
  102220. * @param texture defines the BabylonJS internal texture
  102221. * @param createPolynomials will be true if polynomials have been requested
  102222. * @param onLoad defines the callback to trigger once the texture is ready
  102223. * @param onError defines the callback to trigger in case of error
  102224. */
  102225. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102226. /**
  102227. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102228. * @param data contains the texture data
  102229. * @param texture defines the BabylonJS internal texture
  102230. * @param callback defines the method to call once ready to upload
  102231. */
  102232. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102233. }
  102234. }
  102235. declare module BABYLON {
  102236. /** @hidden */
  102237. export var _forceSceneHelpersToBundle: boolean;
  102238. interface Scene {
  102239. /**
  102240. * Creates a default light for the scene.
  102241. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  102242. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  102243. */
  102244. createDefaultLight(replace?: boolean): void;
  102245. /**
  102246. * Creates a default camera for the scene.
  102247. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  102248. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102249. * @param replace has default false, when true replaces the active camera in the scene
  102250. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  102251. */
  102252. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102253. /**
  102254. * Creates a default camera and a default light.
  102255. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  102256. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  102257. * @param replace has the default false, when true replaces the active camera/light in the scene
  102258. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  102259. */
  102260. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  102261. /**
  102262. * Creates a new sky box
  102263. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  102264. * @param environmentTexture defines the texture to use as environment texture
  102265. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  102266. * @param scale defines the overall scale of the skybox
  102267. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  102268. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  102269. * @returns a new mesh holding the sky box
  102270. */
  102271. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  102272. /**
  102273. * Creates a new environment
  102274. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  102275. * @param options defines the options you can use to configure the environment
  102276. * @returns the new EnvironmentHelper
  102277. */
  102278. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  102279. /**
  102280. * Creates a new VREXperienceHelper
  102281. * @see http://doc.babylonjs.com/how_to/webvr_helper
  102282. * @param webVROptions defines the options used to create the new VREXperienceHelper
  102283. * @returns a new VREXperienceHelper
  102284. */
  102285. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  102286. /**
  102287. * Creates a new XREXperienceHelper
  102288. * @see http://doc.babylonjs.com/how_to/webxr
  102289. * @returns a promise for a new XREXperienceHelper
  102290. */
  102291. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  102292. }
  102293. }
  102294. declare module BABYLON {
  102295. /**
  102296. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  102297. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  102298. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  102299. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  102300. */
  102301. export class VideoDome extends TransformNode {
  102302. /**
  102303. * Define the video source as a Monoscopic panoramic 360 video.
  102304. */
  102305. static readonly MODE_MONOSCOPIC: number;
  102306. /**
  102307. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102308. */
  102309. static readonly MODE_TOPBOTTOM: number;
  102310. /**
  102311. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102312. */
  102313. static readonly MODE_SIDEBYSIDE: number;
  102314. private _useDirectMapping;
  102315. /**
  102316. * The video texture being displayed on the sphere
  102317. */
  102318. protected _videoTexture: VideoTexture;
  102319. /**
  102320. * Gets the video texture being displayed on the sphere
  102321. */
  102322. readonly videoTexture: VideoTexture;
  102323. /**
  102324. * The skybox material
  102325. */
  102326. protected _material: BackgroundMaterial;
  102327. /**
  102328. * The surface used for the skybox
  102329. */
  102330. protected _mesh: Mesh;
  102331. /**
  102332. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102333. * Also see the options.resolution property.
  102334. */
  102335. fovMultiplier: number;
  102336. private _videoMode;
  102337. /**
  102338. * Gets or set the current video mode for the video. It can be:
  102339. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  102340. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  102341. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  102342. */
  102343. videoMode: number;
  102344. /**
  102345. * Oberserver used in Stereoscopic VR Mode.
  102346. */
  102347. private _onBeforeCameraRenderObserver;
  102348. /**
  102349. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  102350. * @param name Element's name, child elements will append suffixes for their own names.
  102351. * @param urlsOrVideo defines the url(s) or the video element to use
  102352. * @param options An object containing optional or exposed sub element properties
  102353. */
  102354. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  102355. resolution?: number;
  102356. clickToPlay?: boolean;
  102357. autoPlay?: boolean;
  102358. loop?: boolean;
  102359. size?: number;
  102360. poster?: string;
  102361. useDirectMapping?: boolean;
  102362. }, scene: Scene);
  102363. private _changeVideoMode;
  102364. /**
  102365. * Releases resources associated with this node.
  102366. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102367. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102368. */
  102369. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102370. }
  102371. }
  102372. declare module BABYLON {
  102373. /**
  102374. * This class can be used to get instrumentation data from a Babylon engine
  102375. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102376. */
  102377. export class EngineInstrumentation implements IDisposable {
  102378. /**
  102379. * Define the instrumented engine.
  102380. */
  102381. engine: Engine;
  102382. private _captureGPUFrameTime;
  102383. private _gpuFrameTimeToken;
  102384. private _gpuFrameTime;
  102385. private _captureShaderCompilationTime;
  102386. private _shaderCompilationTime;
  102387. private _onBeginFrameObserver;
  102388. private _onEndFrameObserver;
  102389. private _onBeforeShaderCompilationObserver;
  102390. private _onAfterShaderCompilationObserver;
  102391. /**
  102392. * Gets the perf counter used for GPU frame time
  102393. */
  102394. readonly gpuFrameTimeCounter: PerfCounter;
  102395. /**
  102396. * Gets the GPU frame time capture status
  102397. */
  102398. /**
  102399. * Enable or disable the GPU frame time capture
  102400. */
  102401. captureGPUFrameTime: boolean;
  102402. /**
  102403. * Gets the perf counter used for shader compilation time
  102404. */
  102405. readonly shaderCompilationTimeCounter: PerfCounter;
  102406. /**
  102407. * Gets the shader compilation time capture status
  102408. */
  102409. /**
  102410. * Enable or disable the shader compilation time capture
  102411. */
  102412. captureShaderCompilationTime: boolean;
  102413. /**
  102414. * Instantiates a new engine instrumentation.
  102415. * This class can be used to get instrumentation data from a Babylon engine
  102416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102417. * @param engine Defines the engine to instrument
  102418. */
  102419. constructor(
  102420. /**
  102421. * Define the instrumented engine.
  102422. */
  102423. engine: Engine);
  102424. /**
  102425. * Dispose and release associated resources.
  102426. */
  102427. dispose(): void;
  102428. }
  102429. }
  102430. declare module BABYLON {
  102431. /**
  102432. * This class can be used to get instrumentation data from a Babylon engine
  102433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102434. */
  102435. export class SceneInstrumentation implements IDisposable {
  102436. /**
  102437. * Defines the scene to instrument
  102438. */
  102439. scene: Scene;
  102440. private _captureActiveMeshesEvaluationTime;
  102441. private _activeMeshesEvaluationTime;
  102442. private _captureRenderTargetsRenderTime;
  102443. private _renderTargetsRenderTime;
  102444. private _captureFrameTime;
  102445. private _frameTime;
  102446. private _captureRenderTime;
  102447. private _renderTime;
  102448. private _captureInterFrameTime;
  102449. private _interFrameTime;
  102450. private _captureParticlesRenderTime;
  102451. private _particlesRenderTime;
  102452. private _captureSpritesRenderTime;
  102453. private _spritesRenderTime;
  102454. private _capturePhysicsTime;
  102455. private _physicsTime;
  102456. private _captureAnimationsTime;
  102457. private _animationsTime;
  102458. private _captureCameraRenderTime;
  102459. private _cameraRenderTime;
  102460. private _onBeforeActiveMeshesEvaluationObserver;
  102461. private _onAfterActiveMeshesEvaluationObserver;
  102462. private _onBeforeRenderTargetsRenderObserver;
  102463. private _onAfterRenderTargetsRenderObserver;
  102464. private _onAfterRenderObserver;
  102465. private _onBeforeDrawPhaseObserver;
  102466. private _onAfterDrawPhaseObserver;
  102467. private _onBeforeAnimationsObserver;
  102468. private _onBeforeParticlesRenderingObserver;
  102469. private _onAfterParticlesRenderingObserver;
  102470. private _onBeforeSpritesRenderingObserver;
  102471. private _onAfterSpritesRenderingObserver;
  102472. private _onBeforePhysicsObserver;
  102473. private _onAfterPhysicsObserver;
  102474. private _onAfterAnimationsObserver;
  102475. private _onBeforeCameraRenderObserver;
  102476. private _onAfterCameraRenderObserver;
  102477. /**
  102478. * Gets the perf counter used for active meshes evaluation time
  102479. */
  102480. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  102481. /**
  102482. * Gets the active meshes evaluation time capture status
  102483. */
  102484. /**
  102485. * Enable or disable the active meshes evaluation time capture
  102486. */
  102487. captureActiveMeshesEvaluationTime: boolean;
  102488. /**
  102489. * Gets the perf counter used for render targets render time
  102490. */
  102491. readonly renderTargetsRenderTimeCounter: PerfCounter;
  102492. /**
  102493. * Gets the render targets render time capture status
  102494. */
  102495. /**
  102496. * Enable or disable the render targets render time capture
  102497. */
  102498. captureRenderTargetsRenderTime: boolean;
  102499. /**
  102500. * Gets the perf counter used for particles render time
  102501. */
  102502. readonly particlesRenderTimeCounter: PerfCounter;
  102503. /**
  102504. * Gets the particles render time capture status
  102505. */
  102506. /**
  102507. * Enable or disable the particles render time capture
  102508. */
  102509. captureParticlesRenderTime: boolean;
  102510. /**
  102511. * Gets the perf counter used for sprites render time
  102512. */
  102513. readonly spritesRenderTimeCounter: PerfCounter;
  102514. /**
  102515. * Gets the sprites render time capture status
  102516. */
  102517. /**
  102518. * Enable or disable the sprites render time capture
  102519. */
  102520. captureSpritesRenderTime: boolean;
  102521. /**
  102522. * Gets the perf counter used for physics time
  102523. */
  102524. readonly physicsTimeCounter: PerfCounter;
  102525. /**
  102526. * Gets the physics time capture status
  102527. */
  102528. /**
  102529. * Enable or disable the physics time capture
  102530. */
  102531. capturePhysicsTime: boolean;
  102532. /**
  102533. * Gets the perf counter used for animations time
  102534. */
  102535. readonly animationsTimeCounter: PerfCounter;
  102536. /**
  102537. * Gets the animations time capture status
  102538. */
  102539. /**
  102540. * Enable or disable the animations time capture
  102541. */
  102542. captureAnimationsTime: boolean;
  102543. /**
  102544. * Gets the perf counter used for frame time capture
  102545. */
  102546. readonly frameTimeCounter: PerfCounter;
  102547. /**
  102548. * Gets the frame time capture status
  102549. */
  102550. /**
  102551. * Enable or disable the frame time capture
  102552. */
  102553. captureFrameTime: boolean;
  102554. /**
  102555. * Gets the perf counter used for inter-frames time capture
  102556. */
  102557. readonly interFrameTimeCounter: PerfCounter;
  102558. /**
  102559. * Gets the inter-frames time capture status
  102560. */
  102561. /**
  102562. * Enable or disable the inter-frames time capture
  102563. */
  102564. captureInterFrameTime: boolean;
  102565. /**
  102566. * Gets the perf counter used for render time capture
  102567. */
  102568. readonly renderTimeCounter: PerfCounter;
  102569. /**
  102570. * Gets the render time capture status
  102571. */
  102572. /**
  102573. * Enable or disable the render time capture
  102574. */
  102575. captureRenderTime: boolean;
  102576. /**
  102577. * Gets the perf counter used for camera render time capture
  102578. */
  102579. readonly cameraRenderTimeCounter: PerfCounter;
  102580. /**
  102581. * Gets the camera render time capture status
  102582. */
  102583. /**
  102584. * Enable or disable the camera render time capture
  102585. */
  102586. captureCameraRenderTime: boolean;
  102587. /**
  102588. * Gets the perf counter used for draw calls
  102589. */
  102590. readonly drawCallsCounter: PerfCounter;
  102591. /**
  102592. * Gets the perf counter used for texture collisions
  102593. */
  102594. readonly textureCollisionsCounter: PerfCounter;
  102595. /**
  102596. * Instantiates a new scene instrumentation.
  102597. * This class can be used to get instrumentation data from a Babylon engine
  102598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  102599. * @param scene Defines the scene to instrument
  102600. */
  102601. constructor(
  102602. /**
  102603. * Defines the scene to instrument
  102604. */
  102605. scene: Scene);
  102606. /**
  102607. * Dispose and release associated resources.
  102608. */
  102609. dispose(): void;
  102610. }
  102611. }
  102612. declare module BABYLON {
  102613. /** @hidden */
  102614. export var glowMapGenerationPixelShader: {
  102615. name: string;
  102616. shader: string;
  102617. };
  102618. }
  102619. declare module BABYLON {
  102620. /** @hidden */
  102621. export var glowMapGenerationVertexShader: {
  102622. name: string;
  102623. shader: string;
  102624. };
  102625. }
  102626. declare module BABYLON {
  102627. /**
  102628. * Effect layer options. This helps customizing the behaviour
  102629. * of the effect layer.
  102630. */
  102631. export interface IEffectLayerOptions {
  102632. /**
  102633. * Multiplication factor apply to the canvas size to compute the render target size
  102634. * used to generated the objects (the smaller the faster).
  102635. */
  102636. mainTextureRatio: number;
  102637. /**
  102638. * Enforces a fixed size texture to ensure effect stability across devices.
  102639. */
  102640. mainTextureFixedSize?: number;
  102641. /**
  102642. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  102643. */
  102644. alphaBlendingMode: number;
  102645. /**
  102646. * The camera attached to the layer.
  102647. */
  102648. camera: Nullable<Camera>;
  102649. /**
  102650. * The rendering group to draw the layer in.
  102651. */
  102652. renderingGroupId: number;
  102653. }
  102654. /**
  102655. * The effect layer Helps adding post process effect blended with the main pass.
  102656. *
  102657. * This can be for instance use to generate glow or higlight effects on the scene.
  102658. *
  102659. * The effect layer class can not be used directly and is intented to inherited from to be
  102660. * customized per effects.
  102661. */
  102662. export abstract class EffectLayer {
  102663. private _vertexBuffers;
  102664. private _indexBuffer;
  102665. private _cachedDefines;
  102666. private _effectLayerMapGenerationEffect;
  102667. private _effectLayerOptions;
  102668. private _mergeEffect;
  102669. protected _scene: Scene;
  102670. protected _engine: Engine;
  102671. protected _maxSize: number;
  102672. protected _mainTextureDesiredSize: ISize;
  102673. protected _mainTexture: RenderTargetTexture;
  102674. protected _shouldRender: boolean;
  102675. protected _postProcesses: PostProcess[];
  102676. protected _textures: BaseTexture[];
  102677. protected _emissiveTextureAndColor: {
  102678. texture: Nullable<BaseTexture>;
  102679. color: Color4;
  102680. };
  102681. /**
  102682. * The name of the layer
  102683. */
  102684. name: string;
  102685. /**
  102686. * The clear color of the texture used to generate the glow map.
  102687. */
  102688. neutralColor: Color4;
  102689. /**
  102690. * Specifies wether the highlight layer is enabled or not.
  102691. */
  102692. isEnabled: boolean;
  102693. /**
  102694. * Gets the camera attached to the layer.
  102695. */
  102696. readonly camera: Nullable<Camera>;
  102697. /**
  102698. * Gets the rendering group id the layer should render in.
  102699. */
  102700. readonly renderingGroupId: number;
  102701. /**
  102702. * An event triggered when the effect layer has been disposed.
  102703. */
  102704. onDisposeObservable: Observable<EffectLayer>;
  102705. /**
  102706. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  102707. */
  102708. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  102709. /**
  102710. * An event triggered when the generated texture is being merged in the scene.
  102711. */
  102712. onBeforeComposeObservable: Observable<EffectLayer>;
  102713. /**
  102714. * An event triggered when the generated texture has been merged in the scene.
  102715. */
  102716. onAfterComposeObservable: Observable<EffectLayer>;
  102717. /**
  102718. * An event triggered when the efffect layer changes its size.
  102719. */
  102720. onSizeChangedObservable: Observable<EffectLayer>;
  102721. /** @hidden */
  102722. static _SceneComponentInitialization: (scene: Scene) => void;
  102723. /**
  102724. * Instantiates a new effect Layer and references it in the scene.
  102725. * @param name The name of the layer
  102726. * @param scene The scene to use the layer in
  102727. */
  102728. constructor(
  102729. /** The Friendly of the effect in the scene */
  102730. name: string, scene: Scene);
  102731. /**
  102732. * Get the effect name of the layer.
  102733. * @return The effect name
  102734. */
  102735. abstract getEffectName(): string;
  102736. /**
  102737. * Checks for the readiness of the element composing the layer.
  102738. * @param subMesh the mesh to check for
  102739. * @param useInstances specify wether or not to use instances to render the mesh
  102740. * @return true if ready otherwise, false
  102741. */
  102742. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  102743. /**
  102744. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  102745. * @returns true if the effect requires stencil during the main canvas render pass.
  102746. */
  102747. abstract needStencil(): boolean;
  102748. /**
  102749. * Create the merge effect. This is the shader use to blit the information back
  102750. * to the main canvas at the end of the scene rendering.
  102751. * @returns The effect containing the shader used to merge the effect on the main canvas
  102752. */
  102753. protected abstract _createMergeEffect(): Effect;
  102754. /**
  102755. * Creates the render target textures and post processes used in the effect layer.
  102756. */
  102757. protected abstract _createTextureAndPostProcesses(): void;
  102758. /**
  102759. * Implementation specific of rendering the generating effect on the main canvas.
  102760. * @param effect The effect used to render through
  102761. */
  102762. protected abstract _internalRender(effect: Effect): void;
  102763. /**
  102764. * Sets the required values for both the emissive texture and and the main color.
  102765. */
  102766. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  102767. /**
  102768. * Free any resources and references associated to a mesh.
  102769. * Internal use
  102770. * @param mesh The mesh to free.
  102771. */
  102772. abstract _disposeMesh(mesh: Mesh): void;
  102773. /**
  102774. * Serializes this layer (Glow or Highlight for example)
  102775. * @returns a serialized layer object
  102776. */
  102777. abstract serialize?(): any;
  102778. /**
  102779. * Initializes the effect layer with the required options.
  102780. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  102781. */
  102782. protected _init(options: Partial<IEffectLayerOptions>): void;
  102783. /**
  102784. * Generates the index buffer of the full screen quad blending to the main canvas.
  102785. */
  102786. private _generateIndexBuffer;
  102787. /**
  102788. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  102789. */
  102790. private _genrateVertexBuffer;
  102791. /**
  102792. * Sets the main texture desired size which is the closest power of two
  102793. * of the engine canvas size.
  102794. */
  102795. private _setMainTextureSize;
  102796. /**
  102797. * Creates the main texture for the effect layer.
  102798. */
  102799. protected _createMainTexture(): void;
  102800. /**
  102801. * Adds specific effects defines.
  102802. * @param defines The defines to add specifics to.
  102803. */
  102804. protected _addCustomEffectDefines(defines: string[]): void;
  102805. /**
  102806. * Checks for the readiness of the element composing the layer.
  102807. * @param subMesh the mesh to check for
  102808. * @param useInstances specify wether or not to use instances to render the mesh
  102809. * @param emissiveTexture the associated emissive texture used to generate the glow
  102810. * @return true if ready otherwise, false
  102811. */
  102812. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  102813. /**
  102814. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  102815. */
  102816. render(): void;
  102817. /**
  102818. * Determine if a given mesh will be used in the current effect.
  102819. * @param mesh mesh to test
  102820. * @returns true if the mesh will be used
  102821. */
  102822. hasMesh(mesh: AbstractMesh): boolean;
  102823. /**
  102824. * Returns true if the layer contains information to display, otherwise false.
  102825. * @returns true if the glow layer should be rendered
  102826. */
  102827. shouldRender(): boolean;
  102828. /**
  102829. * Returns true if the mesh should render, otherwise false.
  102830. * @param mesh The mesh to render
  102831. * @returns true if it should render otherwise false
  102832. */
  102833. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  102834. /**
  102835. * Returns true if the mesh can be rendered, otherwise false.
  102836. * @param mesh The mesh to render
  102837. * @param material The material used on the mesh
  102838. * @returns true if it can be rendered otherwise false
  102839. */
  102840. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  102841. /**
  102842. * Returns true if the mesh should render, otherwise false.
  102843. * @param mesh The mesh to render
  102844. * @returns true if it should render otherwise false
  102845. */
  102846. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  102847. /**
  102848. * Renders the submesh passed in parameter to the generation map.
  102849. */
  102850. protected _renderSubMesh(subMesh: SubMesh): void;
  102851. /**
  102852. * Rebuild the required buffers.
  102853. * @hidden Internal use only.
  102854. */
  102855. _rebuild(): void;
  102856. /**
  102857. * Dispose only the render target textures and post process.
  102858. */
  102859. private _disposeTextureAndPostProcesses;
  102860. /**
  102861. * Dispose the highlight layer and free resources.
  102862. */
  102863. dispose(): void;
  102864. /**
  102865. * Gets the class name of the effect layer
  102866. * @returns the string with the class name of the effect layer
  102867. */
  102868. getClassName(): string;
  102869. /**
  102870. * Creates an effect layer from parsed effect layer data
  102871. * @param parsedEffectLayer defines effect layer data
  102872. * @param scene defines the current scene
  102873. * @param rootUrl defines the root URL containing the effect layer information
  102874. * @returns a parsed effect Layer
  102875. */
  102876. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  102877. }
  102878. }
  102879. declare module BABYLON {
  102880. interface AbstractScene {
  102881. /**
  102882. * The list of effect layers (highlights/glow) added to the scene
  102883. * @see http://doc.babylonjs.com/how_to/highlight_layer
  102884. * @see http://doc.babylonjs.com/how_to/glow_layer
  102885. */
  102886. effectLayers: Array<EffectLayer>;
  102887. /**
  102888. * Removes the given effect layer from this scene.
  102889. * @param toRemove defines the effect layer to remove
  102890. * @returns the index of the removed effect layer
  102891. */
  102892. removeEffectLayer(toRemove: EffectLayer): number;
  102893. /**
  102894. * Adds the given effect layer to this scene
  102895. * @param newEffectLayer defines the effect layer to add
  102896. */
  102897. addEffectLayer(newEffectLayer: EffectLayer): void;
  102898. }
  102899. /**
  102900. * Defines the layer scene component responsible to manage any effect layers
  102901. * in a given scene.
  102902. */
  102903. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  102904. /**
  102905. * The component name helpfull to identify the component in the list of scene components.
  102906. */
  102907. readonly name: string;
  102908. /**
  102909. * The scene the component belongs to.
  102910. */
  102911. scene: Scene;
  102912. private _engine;
  102913. private _renderEffects;
  102914. private _needStencil;
  102915. private _previousStencilState;
  102916. /**
  102917. * Creates a new instance of the component for the given scene
  102918. * @param scene Defines the scene to register the component in
  102919. */
  102920. constructor(scene: Scene);
  102921. /**
  102922. * Registers the component in a given scene
  102923. */
  102924. register(): void;
  102925. /**
  102926. * Rebuilds the elements related to this component in case of
  102927. * context lost for instance.
  102928. */
  102929. rebuild(): void;
  102930. /**
  102931. * Serializes the component data to the specified json object
  102932. * @param serializationObject The object to serialize to
  102933. */
  102934. serialize(serializationObject: any): void;
  102935. /**
  102936. * Adds all the element from the container to the scene
  102937. * @param container the container holding the elements
  102938. */
  102939. addFromContainer(container: AbstractScene): void;
  102940. /**
  102941. * Removes all the elements in the container from the scene
  102942. * @param container contains the elements to remove
  102943. */
  102944. removeFromContainer(container: AbstractScene): void;
  102945. /**
  102946. * Disposes the component and the associated ressources.
  102947. */
  102948. dispose(): void;
  102949. private _isReadyForMesh;
  102950. private _renderMainTexture;
  102951. private _setStencil;
  102952. private _setStencilBack;
  102953. private _draw;
  102954. private _drawCamera;
  102955. private _drawRenderingGroup;
  102956. }
  102957. }
  102958. declare module BABYLON {
  102959. /** @hidden */
  102960. export var glowMapMergePixelShader: {
  102961. name: string;
  102962. shader: string;
  102963. };
  102964. }
  102965. declare module BABYLON {
  102966. /** @hidden */
  102967. export var glowMapMergeVertexShader: {
  102968. name: string;
  102969. shader: string;
  102970. };
  102971. }
  102972. declare module BABYLON {
  102973. interface AbstractScene {
  102974. /**
  102975. * Return a the first highlight layer of the scene with a given name.
  102976. * @param name The name of the highlight layer to look for.
  102977. * @return The highlight layer if found otherwise null.
  102978. */
  102979. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  102980. }
  102981. /**
  102982. * Glow layer options. This helps customizing the behaviour
  102983. * of the glow layer.
  102984. */
  102985. export interface IGlowLayerOptions {
  102986. /**
  102987. * Multiplication factor apply to the canvas size to compute the render target size
  102988. * used to generated the glowing objects (the smaller the faster).
  102989. */
  102990. mainTextureRatio: number;
  102991. /**
  102992. * Enforces a fixed size texture to ensure resize independant blur.
  102993. */
  102994. mainTextureFixedSize?: number;
  102995. /**
  102996. * How big is the kernel of the blur texture.
  102997. */
  102998. blurKernelSize: number;
  102999. /**
  103000. * The camera attached to the layer.
  103001. */
  103002. camera: Nullable<Camera>;
  103003. /**
  103004. * Enable MSAA by chosing the number of samples.
  103005. */
  103006. mainTextureSamples?: number;
  103007. /**
  103008. * The rendering group to draw the layer in.
  103009. */
  103010. renderingGroupId: number;
  103011. }
  103012. /**
  103013. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  103014. *
  103015. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103016. * glowy meshes to your scene.
  103017. *
  103018. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  103019. */
  103020. export class GlowLayer extends EffectLayer {
  103021. /**
  103022. * Effect Name of the layer.
  103023. */
  103024. static readonly EffectName: string;
  103025. /**
  103026. * The default blur kernel size used for the glow.
  103027. */
  103028. static DefaultBlurKernelSize: number;
  103029. /**
  103030. * The default texture size ratio used for the glow.
  103031. */
  103032. static DefaultTextureRatio: number;
  103033. /**
  103034. * Sets the kernel size of the blur.
  103035. */
  103036. /**
  103037. * Gets the kernel size of the blur.
  103038. */
  103039. blurKernelSize: number;
  103040. /**
  103041. * Sets the glow intensity.
  103042. */
  103043. /**
  103044. * Gets the glow intensity.
  103045. */
  103046. intensity: number;
  103047. private _options;
  103048. private _intensity;
  103049. private _horizontalBlurPostprocess1;
  103050. private _verticalBlurPostprocess1;
  103051. private _horizontalBlurPostprocess2;
  103052. private _verticalBlurPostprocess2;
  103053. private _blurTexture1;
  103054. private _blurTexture2;
  103055. private _postProcesses1;
  103056. private _postProcesses2;
  103057. private _includedOnlyMeshes;
  103058. private _excludedMeshes;
  103059. /**
  103060. * Callback used to let the user override the color selection on a per mesh basis
  103061. */
  103062. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  103063. /**
  103064. * Callback used to let the user override the texture selection on a per mesh basis
  103065. */
  103066. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  103067. /**
  103068. * Instantiates a new glow Layer and references it to the scene.
  103069. * @param name The name of the layer
  103070. * @param scene The scene to use the layer in
  103071. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  103072. */
  103073. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  103074. /**
  103075. * Get the effect name of the layer.
  103076. * @return The effect name
  103077. */
  103078. getEffectName(): string;
  103079. /**
  103080. * Create the merge effect. This is the shader use to blit the information back
  103081. * to the main canvas at the end of the scene rendering.
  103082. */
  103083. protected _createMergeEffect(): Effect;
  103084. /**
  103085. * Creates the render target textures and post processes used in the glow layer.
  103086. */
  103087. protected _createTextureAndPostProcesses(): void;
  103088. /**
  103089. * Checks for the readiness of the element composing the layer.
  103090. * @param subMesh the mesh to check for
  103091. * @param useInstances specify wether or not to use instances to render the mesh
  103092. * @param emissiveTexture the associated emissive texture used to generate the glow
  103093. * @return true if ready otherwise, false
  103094. */
  103095. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103096. /**
  103097. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103098. */
  103099. needStencil(): boolean;
  103100. /**
  103101. * Returns true if the mesh can be rendered, otherwise false.
  103102. * @param mesh The mesh to render
  103103. * @param material The material used on the mesh
  103104. * @returns true if it can be rendered otherwise false
  103105. */
  103106. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103107. /**
  103108. * Implementation specific of rendering the generating effect on the main canvas.
  103109. * @param effect The effect used to render through
  103110. */
  103111. protected _internalRender(effect: Effect): void;
  103112. /**
  103113. * Sets the required values for both the emissive texture and and the main color.
  103114. */
  103115. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103116. /**
  103117. * Returns true if the mesh should render, otherwise false.
  103118. * @param mesh The mesh to render
  103119. * @returns true if it should render otherwise false
  103120. */
  103121. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103122. /**
  103123. * Adds specific effects defines.
  103124. * @param defines The defines to add specifics to.
  103125. */
  103126. protected _addCustomEffectDefines(defines: string[]): void;
  103127. /**
  103128. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  103129. * @param mesh The mesh to exclude from the glow layer
  103130. */
  103131. addExcludedMesh(mesh: Mesh): void;
  103132. /**
  103133. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  103134. * @param mesh The mesh to remove
  103135. */
  103136. removeExcludedMesh(mesh: Mesh): void;
  103137. /**
  103138. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  103139. * @param mesh The mesh to include in the glow layer
  103140. */
  103141. addIncludedOnlyMesh(mesh: Mesh): void;
  103142. /**
  103143. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  103144. * @param mesh The mesh to remove
  103145. */
  103146. removeIncludedOnlyMesh(mesh: Mesh): void;
  103147. /**
  103148. * Determine if a given mesh will be used in the glow layer
  103149. * @param mesh The mesh to test
  103150. * @returns true if the mesh will be highlighted by the current glow layer
  103151. */
  103152. hasMesh(mesh: AbstractMesh): boolean;
  103153. /**
  103154. * Free any resources and references associated to a mesh.
  103155. * Internal use
  103156. * @param mesh The mesh to free.
  103157. * @hidden
  103158. */
  103159. _disposeMesh(mesh: Mesh): void;
  103160. /**
  103161. * Gets the class name of the effect layer
  103162. * @returns the string with the class name of the effect layer
  103163. */
  103164. getClassName(): string;
  103165. /**
  103166. * Serializes this glow layer
  103167. * @returns a serialized glow layer object
  103168. */
  103169. serialize(): any;
  103170. /**
  103171. * Creates a Glow Layer from parsed glow layer data
  103172. * @param parsedGlowLayer defines glow layer data
  103173. * @param scene defines the current scene
  103174. * @param rootUrl defines the root URL containing the glow layer information
  103175. * @returns a parsed Glow Layer
  103176. */
  103177. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  103178. }
  103179. }
  103180. declare module BABYLON {
  103181. /** @hidden */
  103182. export var glowBlurPostProcessPixelShader: {
  103183. name: string;
  103184. shader: string;
  103185. };
  103186. }
  103187. declare module BABYLON {
  103188. interface AbstractScene {
  103189. /**
  103190. * Return a the first highlight layer of the scene with a given name.
  103191. * @param name The name of the highlight layer to look for.
  103192. * @return The highlight layer if found otherwise null.
  103193. */
  103194. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  103195. }
  103196. /**
  103197. * Highlight layer options. This helps customizing the behaviour
  103198. * of the highlight layer.
  103199. */
  103200. export interface IHighlightLayerOptions {
  103201. /**
  103202. * Multiplication factor apply to the canvas size to compute the render target size
  103203. * used to generated the glowing objects (the smaller the faster).
  103204. */
  103205. mainTextureRatio: number;
  103206. /**
  103207. * Enforces a fixed size texture to ensure resize independant blur.
  103208. */
  103209. mainTextureFixedSize?: number;
  103210. /**
  103211. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  103212. * of the picture to blur (the smaller the faster).
  103213. */
  103214. blurTextureSizeRatio: number;
  103215. /**
  103216. * How big in texel of the blur texture is the vertical blur.
  103217. */
  103218. blurVerticalSize: number;
  103219. /**
  103220. * How big in texel of the blur texture is the horizontal blur.
  103221. */
  103222. blurHorizontalSize: number;
  103223. /**
  103224. * Alpha blending mode used to apply the blur. Default is combine.
  103225. */
  103226. alphaBlendingMode: number;
  103227. /**
  103228. * The camera attached to the layer.
  103229. */
  103230. camera: Nullable<Camera>;
  103231. /**
  103232. * Should we display highlight as a solid stroke?
  103233. */
  103234. isStroke?: boolean;
  103235. /**
  103236. * The rendering group to draw the layer in.
  103237. */
  103238. renderingGroupId: number;
  103239. }
  103240. /**
  103241. * The highlight layer Helps adding a glow effect around a mesh.
  103242. *
  103243. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  103244. * glowy meshes to your scene.
  103245. *
  103246. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  103247. */
  103248. export class HighlightLayer extends EffectLayer {
  103249. name: string;
  103250. /**
  103251. * Effect Name of the highlight layer.
  103252. */
  103253. static readonly EffectName: string;
  103254. /**
  103255. * The neutral color used during the preparation of the glow effect.
  103256. * This is black by default as the blend operation is a blend operation.
  103257. */
  103258. static NeutralColor: Color4;
  103259. /**
  103260. * Stencil value used for glowing meshes.
  103261. */
  103262. static GlowingMeshStencilReference: number;
  103263. /**
  103264. * Stencil value used for the other meshes in the scene.
  103265. */
  103266. static NormalMeshStencilReference: number;
  103267. /**
  103268. * Specifies whether or not the inner glow is ACTIVE in the layer.
  103269. */
  103270. innerGlow: boolean;
  103271. /**
  103272. * Specifies whether or not the outer glow is ACTIVE in the layer.
  103273. */
  103274. outerGlow: boolean;
  103275. /**
  103276. * Specifies the horizontal size of the blur.
  103277. */
  103278. /**
  103279. * Gets the horizontal size of the blur.
  103280. */
  103281. blurHorizontalSize: number;
  103282. /**
  103283. * Specifies the vertical size of the blur.
  103284. */
  103285. /**
  103286. * Gets the vertical size of the blur.
  103287. */
  103288. blurVerticalSize: number;
  103289. /**
  103290. * An event triggered when the highlight layer is being blurred.
  103291. */
  103292. onBeforeBlurObservable: Observable<HighlightLayer>;
  103293. /**
  103294. * An event triggered when the highlight layer has been blurred.
  103295. */
  103296. onAfterBlurObservable: Observable<HighlightLayer>;
  103297. private _instanceGlowingMeshStencilReference;
  103298. private _options;
  103299. private _downSamplePostprocess;
  103300. private _horizontalBlurPostprocess;
  103301. private _verticalBlurPostprocess;
  103302. private _blurTexture;
  103303. private _meshes;
  103304. private _excludedMeshes;
  103305. /**
  103306. * Instantiates a new highlight Layer and references it to the scene..
  103307. * @param name The name of the layer
  103308. * @param scene The scene to use the layer in
  103309. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  103310. */
  103311. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  103312. /**
  103313. * Get the effect name of the layer.
  103314. * @return The effect name
  103315. */
  103316. getEffectName(): string;
  103317. /**
  103318. * Create the merge effect. This is the shader use to blit the information back
  103319. * to the main canvas at the end of the scene rendering.
  103320. */
  103321. protected _createMergeEffect(): Effect;
  103322. /**
  103323. * Creates the render target textures and post processes used in the highlight layer.
  103324. */
  103325. protected _createTextureAndPostProcesses(): void;
  103326. /**
  103327. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103328. */
  103329. needStencil(): boolean;
  103330. /**
  103331. * Checks for the readiness of the element composing the layer.
  103332. * @param subMesh the mesh to check for
  103333. * @param useInstances specify wether or not to use instances to render the mesh
  103334. * @param emissiveTexture the associated emissive texture used to generate the glow
  103335. * @return true if ready otherwise, false
  103336. */
  103337. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103338. /**
  103339. * Implementation specific of rendering the generating effect on the main canvas.
  103340. * @param effect The effect used to render through
  103341. */
  103342. protected _internalRender(effect: Effect): void;
  103343. /**
  103344. * Returns true if the layer contains information to display, otherwise false.
  103345. */
  103346. shouldRender(): boolean;
  103347. /**
  103348. * Returns true if the mesh should render, otherwise false.
  103349. * @param mesh The mesh to render
  103350. * @returns true if it should render otherwise false
  103351. */
  103352. protected _shouldRenderMesh(mesh: Mesh): boolean;
  103353. /**
  103354. * Sets the required values for both the emissive texture and and the main color.
  103355. */
  103356. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103357. /**
  103358. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  103359. * @param mesh The mesh to exclude from the highlight layer
  103360. */
  103361. addExcludedMesh(mesh: Mesh): void;
  103362. /**
  103363. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  103364. * @param mesh The mesh to highlight
  103365. */
  103366. removeExcludedMesh(mesh: Mesh): void;
  103367. /**
  103368. * Determine if a given mesh will be highlighted by the current HighlightLayer
  103369. * @param mesh mesh to test
  103370. * @returns true if the mesh will be highlighted by the current HighlightLayer
  103371. */
  103372. hasMesh(mesh: AbstractMesh): boolean;
  103373. /**
  103374. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  103375. * @param mesh The mesh to highlight
  103376. * @param color The color of the highlight
  103377. * @param glowEmissiveOnly Extract the glow from the emissive texture
  103378. */
  103379. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  103380. /**
  103381. * Remove a mesh from the highlight layer in order to make it stop glowing.
  103382. * @param mesh The mesh to highlight
  103383. */
  103384. removeMesh(mesh: Mesh): void;
  103385. /**
  103386. * Force the stencil to the normal expected value for none glowing parts
  103387. */
  103388. private _defaultStencilReference;
  103389. /**
  103390. * Free any resources and references associated to a mesh.
  103391. * Internal use
  103392. * @param mesh The mesh to free.
  103393. * @hidden
  103394. */
  103395. _disposeMesh(mesh: Mesh): void;
  103396. /**
  103397. * Dispose the highlight layer and free resources.
  103398. */
  103399. dispose(): void;
  103400. /**
  103401. * Gets the class name of the effect layer
  103402. * @returns the string with the class name of the effect layer
  103403. */
  103404. getClassName(): string;
  103405. /**
  103406. * Serializes this Highlight layer
  103407. * @returns a serialized Highlight layer object
  103408. */
  103409. serialize(): any;
  103410. /**
  103411. * Creates a Highlight layer from parsed Highlight layer data
  103412. * @param parsedHightlightLayer defines the Highlight layer data
  103413. * @param scene defines the current scene
  103414. * @param rootUrl defines the root URL containing the Highlight layer information
  103415. * @returns a parsed Highlight layer
  103416. */
  103417. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  103418. }
  103419. }
  103420. declare module BABYLON {
  103421. /** @hidden */
  103422. export var lensFlarePixelShader: {
  103423. name: string;
  103424. shader: string;
  103425. };
  103426. }
  103427. declare module BABYLON {
  103428. /** @hidden */
  103429. export var lensFlareVertexShader: {
  103430. name: string;
  103431. shader: string;
  103432. };
  103433. }
  103434. declare module BABYLON {
  103435. /**
  103436. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103437. * It is usually composed of several `lensFlare`.
  103438. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103439. */
  103440. export class LensFlareSystem {
  103441. /**
  103442. * Define the name of the lens flare system
  103443. */
  103444. name: string;
  103445. /**
  103446. * List of lens flares used in this system.
  103447. */
  103448. lensFlares: LensFlare[];
  103449. /**
  103450. * Define a limit from the border the lens flare can be visible.
  103451. */
  103452. borderLimit: number;
  103453. /**
  103454. * Define a viewport border we do not want to see the lens flare in.
  103455. */
  103456. viewportBorder: number;
  103457. /**
  103458. * Define a predicate which could limit the list of meshes able to occlude the effect.
  103459. */
  103460. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  103461. /**
  103462. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  103463. */
  103464. layerMask: number;
  103465. /**
  103466. * Define the id of the lens flare system in the scene.
  103467. * (equal to name by default)
  103468. */
  103469. id: string;
  103470. private _scene;
  103471. private _emitter;
  103472. private _vertexBuffers;
  103473. private _indexBuffer;
  103474. private _effect;
  103475. private _positionX;
  103476. private _positionY;
  103477. private _isEnabled;
  103478. /** @hidden */
  103479. static _SceneComponentInitialization: (scene: Scene) => void;
  103480. /**
  103481. * Instantiates a lens flare system.
  103482. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  103483. * It is usually composed of several `lensFlare`.
  103484. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103485. * @param name Define the name of the lens flare system in the scene
  103486. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  103487. * @param scene Define the scene the lens flare system belongs to
  103488. */
  103489. constructor(
  103490. /**
  103491. * Define the name of the lens flare system
  103492. */
  103493. name: string, emitter: any, scene: Scene);
  103494. /**
  103495. * Define if the lens flare system is enabled.
  103496. */
  103497. isEnabled: boolean;
  103498. /**
  103499. * Get the scene the effects belongs to.
  103500. * @returns the scene holding the lens flare system
  103501. */
  103502. getScene(): Scene;
  103503. /**
  103504. * Get the emitter of the lens flare system.
  103505. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103506. * @returns the emitter of the lens flare system
  103507. */
  103508. getEmitter(): any;
  103509. /**
  103510. * Set the emitter of the lens flare system.
  103511. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  103512. * @param newEmitter Define the new emitter of the system
  103513. */
  103514. setEmitter(newEmitter: any): void;
  103515. /**
  103516. * Get the lens flare system emitter position.
  103517. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  103518. * @returns the position
  103519. */
  103520. getEmitterPosition(): Vector3;
  103521. /**
  103522. * @hidden
  103523. */
  103524. computeEffectivePosition(globalViewport: Viewport): boolean;
  103525. /** @hidden */
  103526. _isVisible(): boolean;
  103527. /**
  103528. * @hidden
  103529. */
  103530. render(): boolean;
  103531. /**
  103532. * Dispose and release the lens flare with its associated resources.
  103533. */
  103534. dispose(): void;
  103535. /**
  103536. * Parse a lens flare system from a JSON repressentation
  103537. * @param parsedLensFlareSystem Define the JSON to parse
  103538. * @param scene Define the scene the parsed system should be instantiated in
  103539. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  103540. * @returns the parsed system
  103541. */
  103542. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  103543. /**
  103544. * Serialize the current Lens Flare System into a JSON representation.
  103545. * @returns the serialized JSON
  103546. */
  103547. serialize(): any;
  103548. }
  103549. }
  103550. declare module BABYLON {
  103551. /**
  103552. * This represents one of the lens effect in a `lensFlareSystem`.
  103553. * It controls one of the indiviual texture used in the effect.
  103554. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103555. */
  103556. export class LensFlare {
  103557. /**
  103558. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103559. */
  103560. size: number;
  103561. /**
  103562. * 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.
  103563. */
  103564. position: number;
  103565. /**
  103566. * Define the lens color.
  103567. */
  103568. color: Color3;
  103569. /**
  103570. * Define the lens texture.
  103571. */
  103572. texture: Nullable<Texture>;
  103573. /**
  103574. * Define the alpha mode to render this particular lens.
  103575. */
  103576. alphaMode: number;
  103577. private _system;
  103578. /**
  103579. * Creates a new Lens Flare.
  103580. * This represents one of the lens effect in a `lensFlareSystem`.
  103581. * It controls one of the indiviual texture used in the effect.
  103582. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103583. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  103584. * @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.
  103585. * @param color Define the lens color
  103586. * @param imgUrl Define the lens texture url
  103587. * @param system Define the `lensFlareSystem` this flare is part of
  103588. * @returns The newly created Lens Flare
  103589. */
  103590. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  103591. /**
  103592. * Instantiates a new Lens Flare.
  103593. * This represents one of the lens effect in a `lensFlareSystem`.
  103594. * It controls one of the indiviual texture used in the effect.
  103595. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103596. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  103597. * @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.
  103598. * @param color Define the lens color
  103599. * @param imgUrl Define the lens texture url
  103600. * @param system Define the `lensFlareSystem` this flare is part of
  103601. */
  103602. constructor(
  103603. /**
  103604. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  103605. */
  103606. size: number,
  103607. /**
  103608. * 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.
  103609. */
  103610. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  103611. /**
  103612. * Dispose and release the lens flare with its associated resources.
  103613. */
  103614. dispose(): void;
  103615. }
  103616. }
  103617. declare module BABYLON {
  103618. interface AbstractScene {
  103619. /**
  103620. * The list of lens flare system added to the scene
  103621. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  103622. */
  103623. lensFlareSystems: Array<LensFlareSystem>;
  103624. /**
  103625. * Removes the given lens flare system from this scene.
  103626. * @param toRemove The lens flare system to remove
  103627. * @returns The index of the removed lens flare system
  103628. */
  103629. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  103630. /**
  103631. * Adds the given lens flare system to this scene
  103632. * @param newLensFlareSystem The lens flare system to add
  103633. */
  103634. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  103635. /**
  103636. * Gets a lens flare system using its name
  103637. * @param name defines the name to look for
  103638. * @returns the lens flare system or null if not found
  103639. */
  103640. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  103641. /**
  103642. * Gets a lens flare system using its id
  103643. * @param id defines the id to look for
  103644. * @returns the lens flare system or null if not found
  103645. */
  103646. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  103647. }
  103648. /**
  103649. * Defines the lens flare scene component responsible to manage any lens flares
  103650. * in a given scene.
  103651. */
  103652. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  103653. /**
  103654. * The component name helpfull to identify the component in the list of scene components.
  103655. */
  103656. readonly name: string;
  103657. /**
  103658. * The scene the component belongs to.
  103659. */
  103660. scene: Scene;
  103661. /**
  103662. * Creates a new instance of the component for the given scene
  103663. * @param scene Defines the scene to register the component in
  103664. */
  103665. constructor(scene: Scene);
  103666. /**
  103667. * Registers the component in a given scene
  103668. */
  103669. register(): void;
  103670. /**
  103671. * Rebuilds the elements related to this component in case of
  103672. * context lost for instance.
  103673. */
  103674. rebuild(): void;
  103675. /**
  103676. * Adds all the element from the container to the scene
  103677. * @param container the container holding the elements
  103678. */
  103679. addFromContainer(container: AbstractScene): void;
  103680. /**
  103681. * Removes all the elements in the container from the scene
  103682. * @param container contains the elements to remove
  103683. */
  103684. removeFromContainer(container: AbstractScene): void;
  103685. /**
  103686. * Serializes the component data to the specified json object
  103687. * @param serializationObject The object to serialize to
  103688. */
  103689. serialize(serializationObject: any): void;
  103690. /**
  103691. * Disposes the component and the associated ressources.
  103692. */
  103693. dispose(): void;
  103694. private _draw;
  103695. }
  103696. }
  103697. declare module BABYLON {
  103698. /**
  103699. * Defines the shadow generator component responsible to manage any shadow generators
  103700. * in a given scene.
  103701. */
  103702. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  103703. /**
  103704. * The component name helpfull to identify the component in the list of scene components.
  103705. */
  103706. readonly name: string;
  103707. /**
  103708. * The scene the component belongs to.
  103709. */
  103710. scene: Scene;
  103711. /**
  103712. * Creates a new instance of the component for the given scene
  103713. * @param scene Defines the scene to register the component in
  103714. */
  103715. constructor(scene: Scene);
  103716. /**
  103717. * Registers the component in a given scene
  103718. */
  103719. register(): void;
  103720. /**
  103721. * Rebuilds the elements related to this component in case of
  103722. * context lost for instance.
  103723. */
  103724. rebuild(): void;
  103725. /**
  103726. * Serializes the component data to the specified json object
  103727. * @param serializationObject The object to serialize to
  103728. */
  103729. serialize(serializationObject: any): void;
  103730. /**
  103731. * Adds all the element from the container to the scene
  103732. * @param container the container holding the elements
  103733. */
  103734. addFromContainer(container: AbstractScene): void;
  103735. /**
  103736. * Removes all the elements in the container from the scene
  103737. * @param container contains the elements to remove
  103738. */
  103739. removeFromContainer(container: AbstractScene): void;
  103740. /**
  103741. * Rebuilds the elements related to this component in case of
  103742. * context lost for instance.
  103743. */
  103744. dispose(): void;
  103745. private _gatherRenderTargets;
  103746. }
  103747. }
  103748. declare module BABYLON {
  103749. /**
  103750. * A directional light is defined by a direction (what a surprise!).
  103751. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  103752. * 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.
  103753. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103754. */
  103755. export class DirectionalLight extends ShadowLight {
  103756. private _shadowFrustumSize;
  103757. /**
  103758. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  103759. */
  103760. /**
  103761. * Specifies a fix frustum size for the shadow generation.
  103762. */
  103763. shadowFrustumSize: number;
  103764. private _shadowOrthoScale;
  103765. /**
  103766. * Gets the shadow projection scale against the optimal computed one.
  103767. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103768. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103769. */
  103770. /**
  103771. * Sets the shadow projection scale against the optimal computed one.
  103772. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  103773. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  103774. */
  103775. shadowOrthoScale: number;
  103776. /**
  103777. * Automatically compute the projection matrix to best fit (including all the casters)
  103778. * on each frame.
  103779. */
  103780. autoUpdateExtends: boolean;
  103781. private _orthoLeft;
  103782. private _orthoRight;
  103783. private _orthoTop;
  103784. private _orthoBottom;
  103785. /**
  103786. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  103787. * The directional light is emitted from everywhere in the given direction.
  103788. * It can cast shadows.
  103789. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103790. * @param name The friendly name of the light
  103791. * @param direction The direction of the light
  103792. * @param scene The scene the light belongs to
  103793. */
  103794. constructor(name: string, direction: Vector3, scene: Scene);
  103795. /**
  103796. * Returns the string "DirectionalLight".
  103797. * @return The class name
  103798. */
  103799. getClassName(): string;
  103800. /**
  103801. * Returns the integer 1.
  103802. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103803. */
  103804. getTypeID(): number;
  103805. /**
  103806. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  103807. * Returns the DirectionalLight Shadow projection matrix.
  103808. */
  103809. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103810. /**
  103811. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  103812. * Returns the DirectionalLight Shadow projection matrix.
  103813. */
  103814. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  103815. /**
  103816. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  103817. * Returns the DirectionalLight Shadow projection matrix.
  103818. */
  103819. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103820. protected _buildUniformLayout(): void;
  103821. /**
  103822. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  103823. * @param effect The effect to update
  103824. * @param lightIndex The index of the light in the effect to update
  103825. * @returns The directional light
  103826. */
  103827. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  103828. /**
  103829. * Gets the minZ used for shadow according to both the scene and the light.
  103830. *
  103831. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103832. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103833. * @param activeCamera The camera we are returning the min for
  103834. * @returns the depth min z
  103835. */
  103836. getDepthMinZ(activeCamera: Camera): number;
  103837. /**
  103838. * Gets the maxZ used for shadow according to both the scene and the light.
  103839. *
  103840. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  103841. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  103842. * @param activeCamera The camera we are returning the max for
  103843. * @returns the depth max z
  103844. */
  103845. getDepthMaxZ(activeCamera: Camera): number;
  103846. /**
  103847. * Prepares the list of defines specific to the light type.
  103848. * @param defines the list of defines
  103849. * @param lightIndex defines the index of the light for the effect
  103850. */
  103851. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103852. }
  103853. }
  103854. declare module BABYLON {
  103855. /**
  103856. * A point light is a light defined by an unique point in world space.
  103857. * The light is emitted in every direction from this point.
  103858. * A good example of a point light is a standard light bulb.
  103859. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103860. */
  103861. export class PointLight extends ShadowLight {
  103862. private _shadowAngle;
  103863. /**
  103864. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103865. * This specifies what angle the shadow will use to be created.
  103866. *
  103867. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103868. */
  103869. /**
  103870. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103871. * This specifies what angle the shadow will use to be created.
  103872. *
  103873. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  103874. */
  103875. shadowAngle: number;
  103876. /**
  103877. * Gets the direction if it has been set.
  103878. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103879. */
  103880. /**
  103881. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  103882. */
  103883. direction: Vector3;
  103884. /**
  103885. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  103886. * A PointLight emits the light in every direction.
  103887. * It can cast shadows.
  103888. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  103889. * ```javascript
  103890. * var pointLight = new PointLight("pl", camera.position, scene);
  103891. * ```
  103892. * Documentation : https://doc.babylonjs.com/babylon101/lights
  103893. * @param name The light friendly name
  103894. * @param position The position of the point light in the scene
  103895. * @param scene The scene the lights belongs to
  103896. */
  103897. constructor(name: string, position: Vector3, scene: Scene);
  103898. /**
  103899. * Returns the string "PointLight"
  103900. * @returns the class name
  103901. */
  103902. getClassName(): string;
  103903. /**
  103904. * Returns the integer 0.
  103905. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  103906. */
  103907. getTypeID(): number;
  103908. /**
  103909. * Specifies wether or not the shadowmap should be a cube texture.
  103910. * @returns true if the shadowmap needs to be a cube texture.
  103911. */
  103912. needCube(): boolean;
  103913. /**
  103914. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  103915. * @param faceIndex The index of the face we are computed the direction to generate shadow
  103916. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  103917. */
  103918. getShadowDirection(faceIndex?: number): Vector3;
  103919. /**
  103920. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  103921. * - fov = PI / 2
  103922. * - aspect ratio : 1.0
  103923. * - z-near and far equal to the active camera minZ and maxZ.
  103924. * Returns the PointLight.
  103925. */
  103926. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  103927. protected _buildUniformLayout(): void;
  103928. /**
  103929. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  103930. * @param effect The effect to update
  103931. * @param lightIndex The index of the light in the effect to update
  103932. * @returns The point light
  103933. */
  103934. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  103935. /**
  103936. * Prepares the list of defines specific to the light type.
  103937. * @param defines the list of defines
  103938. * @param lightIndex defines the index of the light for the effect
  103939. */
  103940. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  103941. }
  103942. }
  103943. declare module BABYLON {
  103944. /**
  103945. * A spot light is defined by a position, a direction, an angle, and an exponent.
  103946. * These values define a cone of light starting from the position, emitting toward the direction.
  103947. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  103948. * and the exponent defines the speed of the decay of the light with distance (reach).
  103949. * Documentation: https://doc.babylonjs.com/babylon101/lights
  103950. */
  103951. export class SpotLight extends ShadowLight {
  103952. private _angle;
  103953. private _innerAngle;
  103954. private _cosHalfAngle;
  103955. private _lightAngleScale;
  103956. private _lightAngleOffset;
  103957. /**
  103958. * Gets the cone angle of the spot light in Radians.
  103959. */
  103960. /**
  103961. * Sets the cone angle of the spot light in Radians.
  103962. */
  103963. angle: number;
  103964. /**
  103965. * Only used in gltf falloff mode, this defines the angle where
  103966. * the directional falloff will start before cutting at angle which could be seen
  103967. * as outer angle.
  103968. */
  103969. /**
  103970. * Only used in gltf falloff mode, this defines the angle where
  103971. * the directional falloff will start before cutting at angle which could be seen
  103972. * as outer angle.
  103973. */
  103974. innerAngle: number;
  103975. private _shadowAngleScale;
  103976. /**
  103977. * Allows scaling the angle of the light for shadow generation only.
  103978. */
  103979. /**
  103980. * Allows scaling the angle of the light for shadow generation only.
  103981. */
  103982. shadowAngleScale: number;
  103983. /**
  103984. * The light decay speed with the distance from the emission spot.
  103985. */
  103986. exponent: number;
  103987. private _projectionTextureMatrix;
  103988. /**
  103989. * Allows reading the projecton texture
  103990. */
  103991. readonly projectionTextureMatrix: Matrix;
  103992. protected _projectionTextureLightNear: number;
  103993. /**
  103994. * Gets the near clip of the Spotlight for texture projection.
  103995. */
  103996. /**
  103997. * Sets the near clip of the Spotlight for texture projection.
  103998. */
  103999. projectionTextureLightNear: number;
  104000. protected _projectionTextureLightFar: number;
  104001. /**
  104002. * Gets the far clip of the Spotlight for texture projection.
  104003. */
  104004. /**
  104005. * Sets the far clip of the Spotlight for texture projection.
  104006. */
  104007. projectionTextureLightFar: number;
  104008. protected _projectionTextureUpDirection: Vector3;
  104009. /**
  104010. * Gets the Up vector of the Spotlight for texture projection.
  104011. */
  104012. /**
  104013. * Sets the Up vector of the Spotlight for texture projection.
  104014. */
  104015. projectionTextureUpDirection: Vector3;
  104016. private _projectionTexture;
  104017. /**
  104018. * Gets the projection texture of the light.
  104019. */
  104020. /**
  104021. * Sets the projection texture of the light.
  104022. */
  104023. projectionTexture: Nullable<BaseTexture>;
  104024. private _projectionTextureViewLightDirty;
  104025. private _projectionTextureProjectionLightDirty;
  104026. private _projectionTextureDirty;
  104027. private _projectionTextureViewTargetVector;
  104028. private _projectionTextureViewLightMatrix;
  104029. private _projectionTextureProjectionLightMatrix;
  104030. private _projectionTextureScalingMatrix;
  104031. /**
  104032. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  104033. * It can cast shadows.
  104034. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104035. * @param name The light friendly name
  104036. * @param position The position of the spot light in the scene
  104037. * @param direction The direction of the light in the scene
  104038. * @param angle The cone angle of the light in Radians
  104039. * @param exponent The light decay speed with the distance from the emission spot
  104040. * @param scene The scene the lights belongs to
  104041. */
  104042. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  104043. /**
  104044. * Returns the string "SpotLight".
  104045. * @returns the class name
  104046. */
  104047. getClassName(): string;
  104048. /**
  104049. * Returns the integer 2.
  104050. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104051. */
  104052. getTypeID(): number;
  104053. /**
  104054. * Overrides the direction setter to recompute the projection texture view light Matrix.
  104055. */
  104056. protected _setDirection(value: Vector3): void;
  104057. /**
  104058. * Overrides the position setter to recompute the projection texture view light Matrix.
  104059. */
  104060. protected _setPosition(value: Vector3): void;
  104061. /**
  104062. * 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.
  104063. * Returns the SpotLight.
  104064. */
  104065. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104066. protected _computeProjectionTextureViewLightMatrix(): void;
  104067. protected _computeProjectionTextureProjectionLightMatrix(): void;
  104068. /**
  104069. * Main function for light texture projection matrix computing.
  104070. */
  104071. protected _computeProjectionTextureMatrix(): void;
  104072. protected _buildUniformLayout(): void;
  104073. private _computeAngleValues;
  104074. /**
  104075. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  104076. * @param effect The effect to update
  104077. * @param lightIndex The index of the light in the effect to update
  104078. * @returns The spot light
  104079. */
  104080. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  104081. /**
  104082. * Disposes the light and the associated resources.
  104083. */
  104084. dispose(): void;
  104085. /**
  104086. * Prepares the list of defines specific to the light type.
  104087. * @param defines the list of defines
  104088. * @param lightIndex defines the index of the light for the effect
  104089. */
  104090. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104091. }
  104092. }
  104093. declare module BABYLON {
  104094. /**
  104095. * Header information of HDR texture files.
  104096. */
  104097. export interface HDRInfo {
  104098. /**
  104099. * The height of the texture in pixels.
  104100. */
  104101. height: number;
  104102. /**
  104103. * The width of the texture in pixels.
  104104. */
  104105. width: number;
  104106. /**
  104107. * The index of the beginning of the data in the binary file.
  104108. */
  104109. dataPosition: number;
  104110. }
  104111. /**
  104112. * This groups tools to convert HDR texture to native colors array.
  104113. */
  104114. export class HDRTools {
  104115. private static Ldexp;
  104116. private static Rgbe2float;
  104117. private static readStringLine;
  104118. /**
  104119. * Reads header information from an RGBE texture stored in a native array.
  104120. * More information on this format are available here:
  104121. * https://en.wikipedia.org/wiki/RGBE_image_format
  104122. *
  104123. * @param uint8array The binary file stored in native array.
  104124. * @return The header information.
  104125. */
  104126. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  104127. /**
  104128. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  104129. * This RGBE texture needs to store the information as a panorama.
  104130. *
  104131. * More information on this format are available here:
  104132. * https://en.wikipedia.org/wiki/RGBE_image_format
  104133. *
  104134. * @param buffer The binary file stored in an array buffer.
  104135. * @param size The expected size of the extracted cubemap.
  104136. * @return The Cube Map information.
  104137. */
  104138. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  104139. /**
  104140. * Returns the pixels data extracted from an RGBE texture.
  104141. * This pixels will be stored left to right up to down in the R G B order in one array.
  104142. *
  104143. * More information on this format are available here:
  104144. * https://en.wikipedia.org/wiki/RGBE_image_format
  104145. *
  104146. * @param uint8array The binary file stored in an array buffer.
  104147. * @param hdrInfo The header information of the file.
  104148. * @return The pixels data in RGB right to left up to down order.
  104149. */
  104150. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  104151. private static RGBE_ReadPixels_RLE;
  104152. }
  104153. }
  104154. declare module BABYLON {
  104155. /**
  104156. * This represents a texture coming from an HDR input.
  104157. *
  104158. * The only supported format is currently panorama picture stored in RGBE format.
  104159. * Example of such files can be found on HDRLib: http://hdrlib.com/
  104160. */
  104161. export class HDRCubeTexture extends BaseTexture {
  104162. private static _facesMapping;
  104163. private _generateHarmonics;
  104164. private _noMipmap;
  104165. private _textureMatrix;
  104166. private _size;
  104167. private _onLoad;
  104168. private _onError;
  104169. /**
  104170. * The texture URL.
  104171. */
  104172. url: string;
  104173. /**
  104174. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  104175. */
  104176. coordinatesMode: number;
  104177. protected _isBlocking: boolean;
  104178. /**
  104179. * Sets wether or not the texture is blocking during loading.
  104180. */
  104181. /**
  104182. * Gets wether or not the texture is blocking during loading.
  104183. */
  104184. isBlocking: boolean;
  104185. protected _rotationY: number;
  104186. /**
  104187. * Sets texture matrix rotation angle around Y axis in radians.
  104188. */
  104189. /**
  104190. * Gets texture matrix rotation angle around Y axis radians.
  104191. */
  104192. rotationY: number;
  104193. /**
  104194. * Gets or sets the center of the bounding box associated with the cube texture
  104195. * It must define where the camera used to render the texture was set
  104196. */
  104197. boundingBoxPosition: Vector3;
  104198. private _boundingBoxSize;
  104199. /**
  104200. * Gets or sets the size of the bounding box associated with the cube texture
  104201. * When defined, the cubemap will switch to local mode
  104202. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104203. * @example https://www.babylonjs-playground.com/#RNASML
  104204. */
  104205. boundingBoxSize: Vector3;
  104206. /**
  104207. * Instantiates an HDRTexture from the following parameters.
  104208. *
  104209. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  104210. * @param scene The scene the texture will be used in
  104211. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  104212. * @param noMipmap Forces to not generate the mipmap if true
  104213. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  104214. * @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)
  104215. * @param reserved Reserved flag for internal use.
  104216. */
  104217. 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>);
  104218. /**
  104219. * Get the current class name of the texture useful for serialization or dynamic coding.
  104220. * @returns "HDRCubeTexture"
  104221. */
  104222. getClassName(): string;
  104223. /**
  104224. * Occurs when the file is raw .hdr file.
  104225. */
  104226. private loadTexture;
  104227. clone(): HDRCubeTexture;
  104228. delayLoad(): void;
  104229. /**
  104230. * Get the texture reflection matrix used to rotate/transform the reflection.
  104231. * @returns the reflection matrix
  104232. */
  104233. getReflectionTextureMatrix(): Matrix;
  104234. /**
  104235. * Set the texture reflection matrix used to rotate/transform the reflection.
  104236. * @param value Define the reflection matrix to set
  104237. */
  104238. setReflectionTextureMatrix(value: Matrix): void;
  104239. /**
  104240. * Parses a JSON representation of an HDR Texture in order to create the texture
  104241. * @param parsedTexture Define the JSON representation
  104242. * @param scene Define the scene the texture should be created in
  104243. * @param rootUrl Define the root url in case we need to load relative dependencies
  104244. * @returns the newly created texture after parsing
  104245. */
  104246. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  104247. serialize(): any;
  104248. }
  104249. }
  104250. declare module BABYLON {
  104251. /**
  104252. * Class used to control physics engine
  104253. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104254. */
  104255. export class PhysicsEngine implements IPhysicsEngine {
  104256. private _physicsPlugin;
  104257. /**
  104258. * Global value used to control the smallest number supported by the simulation
  104259. */
  104260. static Epsilon: number;
  104261. private _impostors;
  104262. private _joints;
  104263. /**
  104264. * Gets the gravity vector used by the simulation
  104265. */
  104266. gravity: Vector3;
  104267. /**
  104268. * Factory used to create the default physics plugin.
  104269. * @returns The default physics plugin
  104270. */
  104271. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  104272. /**
  104273. * Creates a new Physics Engine
  104274. * @param gravity defines the gravity vector used by the simulation
  104275. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  104276. */
  104277. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  104278. /**
  104279. * Sets the gravity vector used by the simulation
  104280. * @param gravity defines the gravity vector to use
  104281. */
  104282. setGravity(gravity: Vector3): void;
  104283. /**
  104284. * Set the time step of the physics engine.
  104285. * Default is 1/60.
  104286. * To slow it down, enter 1/600 for example.
  104287. * To speed it up, 1/30
  104288. * @param newTimeStep defines the new timestep to apply to this world.
  104289. */
  104290. setTimeStep(newTimeStep?: number): void;
  104291. /**
  104292. * Get the time step of the physics engine.
  104293. * @returns the current time step
  104294. */
  104295. getTimeStep(): number;
  104296. /**
  104297. * Release all resources
  104298. */
  104299. dispose(): void;
  104300. /**
  104301. * Gets the name of the current physics plugin
  104302. * @returns the name of the plugin
  104303. */
  104304. getPhysicsPluginName(): string;
  104305. /**
  104306. * Adding a new impostor for the impostor tracking.
  104307. * This will be done by the impostor itself.
  104308. * @param impostor the impostor to add
  104309. */
  104310. addImpostor(impostor: PhysicsImpostor): void;
  104311. /**
  104312. * Remove an impostor from the engine.
  104313. * This impostor and its mesh will not longer be updated by the physics engine.
  104314. * @param impostor the impostor to remove
  104315. */
  104316. removeImpostor(impostor: PhysicsImpostor): void;
  104317. /**
  104318. * Add a joint to the physics engine
  104319. * @param mainImpostor defines the main impostor to which the joint is added.
  104320. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104321. * @param joint defines the joint that will connect both impostors.
  104322. */
  104323. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104324. /**
  104325. * Removes a joint from the simulation
  104326. * @param mainImpostor defines the impostor used with the joint
  104327. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104328. * @param joint defines the joint to remove
  104329. */
  104330. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104331. /**
  104332. * Called by the scene. No need to call it.
  104333. * @param delta defines the timespam between frames
  104334. */
  104335. _step(delta: number): void;
  104336. /**
  104337. * Gets the current plugin used to run the simulation
  104338. * @returns current plugin
  104339. */
  104340. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104341. /**
  104342. * Gets the list of physic impostors
  104343. * @returns an array of PhysicsImpostor
  104344. */
  104345. getImpostors(): Array<PhysicsImpostor>;
  104346. /**
  104347. * Gets the impostor for a physics enabled object
  104348. * @param object defines the object impersonated by the impostor
  104349. * @returns the PhysicsImpostor or null if not found
  104350. */
  104351. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104352. /**
  104353. * Gets the impostor for a physics body object
  104354. * @param body defines physics body used by the impostor
  104355. * @returns the PhysicsImpostor or null if not found
  104356. */
  104357. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104358. }
  104359. }
  104360. declare module BABYLON {
  104361. /** @hidden */
  104362. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  104363. private _useDeltaForWorldStep;
  104364. world: any;
  104365. name: string;
  104366. private _physicsMaterials;
  104367. private _fixedTimeStep;
  104368. BJSCANNON: any;
  104369. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  104370. setGravity(gravity: Vector3): void;
  104371. setTimeStep(timeStep: number): void;
  104372. getTimeStep(): number;
  104373. executeStep(delta: number): void;
  104374. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104375. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104376. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104377. private _processChildMeshes;
  104378. removePhysicsBody(impostor: PhysicsImpostor): void;
  104379. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104380. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104381. private _addMaterial;
  104382. private _checkWithEpsilon;
  104383. private _createShape;
  104384. private _createHeightmap;
  104385. private _minus90X;
  104386. private _plus90X;
  104387. private _tmpPosition;
  104388. private _tmpDeltaPosition;
  104389. private _tmpUnityRotation;
  104390. private _updatePhysicsBodyTransformation;
  104391. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104392. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104393. isSupported(): boolean;
  104394. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104395. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104396. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104397. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104398. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104399. getBodyMass(impostor: PhysicsImpostor): number;
  104400. getBodyFriction(impostor: PhysicsImpostor): number;
  104401. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104402. getBodyRestitution(impostor: PhysicsImpostor): number;
  104403. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104404. sleepBody(impostor: PhysicsImpostor): void;
  104405. wakeUpBody(impostor: PhysicsImpostor): void;
  104406. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  104407. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  104408. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  104409. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104410. getRadius(impostor: PhysicsImpostor): number;
  104411. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104412. dispose(): void;
  104413. private _extendNamespace;
  104414. }
  104415. }
  104416. declare module BABYLON {
  104417. /** @hidden */
  104418. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  104419. world: any;
  104420. name: string;
  104421. BJSOIMO: any;
  104422. constructor(iterations?: number, oimoInjection?: any);
  104423. setGravity(gravity: Vector3): void;
  104424. setTimeStep(timeStep: number): void;
  104425. getTimeStep(): number;
  104426. private _tmpImpostorsArray;
  104427. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104428. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104429. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104430. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104431. private _tmpPositionVector;
  104432. removePhysicsBody(impostor: PhysicsImpostor): void;
  104433. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  104434. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  104435. isSupported(): boolean;
  104436. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104437. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104438. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104439. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  104440. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104441. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104442. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104443. getBodyMass(impostor: PhysicsImpostor): number;
  104444. getBodyFriction(impostor: PhysicsImpostor): number;
  104445. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104446. getBodyRestitution(impostor: PhysicsImpostor): number;
  104447. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104448. sleepBody(impostor: PhysicsImpostor): void;
  104449. wakeUpBody(impostor: PhysicsImpostor): void;
  104450. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104451. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  104452. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104453. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104454. getRadius(impostor: PhysicsImpostor): number;
  104455. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104456. dispose(): void;
  104457. }
  104458. }
  104459. declare module BABYLON {
  104460. interface AbstractScene {
  104461. /**
  104462. * The list of reflection probes added to the scene
  104463. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104464. */
  104465. reflectionProbes: Array<ReflectionProbe>;
  104466. /**
  104467. * Removes the given reflection probe from this scene.
  104468. * @param toRemove The reflection probe to remove
  104469. * @returns The index of the removed reflection probe
  104470. */
  104471. removeReflectionProbe(toRemove: ReflectionProbe): number;
  104472. /**
  104473. * Adds the given reflection probe to this scene.
  104474. * @param newReflectionProbe The reflection probe to add
  104475. */
  104476. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  104477. }
  104478. /**
  104479. * Class used to generate realtime reflection / refraction cube textures
  104480. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  104481. */
  104482. export class ReflectionProbe {
  104483. /** defines the name of the probe */
  104484. name: string;
  104485. private _scene;
  104486. private _renderTargetTexture;
  104487. private _projectionMatrix;
  104488. private _viewMatrix;
  104489. private _target;
  104490. private _add;
  104491. private _attachedMesh;
  104492. private _invertYAxis;
  104493. /** Gets or sets probe position (center of the cube map) */
  104494. position: Vector3;
  104495. /**
  104496. * Creates a new reflection probe
  104497. * @param name defines the name of the probe
  104498. * @param size defines the texture resolution (for each face)
  104499. * @param scene defines the hosting scene
  104500. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  104501. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  104502. */
  104503. constructor(
  104504. /** defines the name of the probe */
  104505. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  104506. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  104507. samples: number;
  104508. /** Gets or sets the refresh rate to use (on every frame by default) */
  104509. refreshRate: number;
  104510. /**
  104511. * Gets the hosting scene
  104512. * @returns a Scene
  104513. */
  104514. getScene(): Scene;
  104515. /** Gets the internal CubeTexture used to render to */
  104516. readonly cubeTexture: RenderTargetTexture;
  104517. /** Gets the list of meshes to render */
  104518. readonly renderList: Nullable<AbstractMesh[]>;
  104519. /**
  104520. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  104521. * @param mesh defines the mesh to attach to
  104522. */
  104523. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  104524. /**
  104525. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  104526. * @param renderingGroupId The rendering group id corresponding to its index
  104527. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104528. */
  104529. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104530. /**
  104531. * Clean all associated resources
  104532. */
  104533. dispose(): void;
  104534. /**
  104535. * Converts the reflection probe information to a readable string for debug purpose.
  104536. * @param fullDetails Supports for multiple levels of logging within scene loading
  104537. * @returns the human readable reflection probe info
  104538. */
  104539. toString(fullDetails?: boolean): string;
  104540. /**
  104541. * Get the class name of the relfection probe.
  104542. * @returns "ReflectionProbe"
  104543. */
  104544. getClassName(): string;
  104545. /**
  104546. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  104547. * @returns The JSON representation of the texture
  104548. */
  104549. serialize(): any;
  104550. /**
  104551. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  104552. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  104553. * @param scene Define the scene the parsed reflection probe should be instantiated in
  104554. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104555. * @returns The parsed reflection probe if successful
  104556. */
  104557. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  104558. }
  104559. }
  104560. declare module BABYLON {
  104561. /** @hidden */
  104562. export var _BabylonLoaderRegistered: boolean;
  104563. }
  104564. declare module BABYLON {
  104565. /**
  104566. * The Physically based simple base material of BJS.
  104567. *
  104568. * This enables better naming and convention enforcements on top of the pbrMaterial.
  104569. * It is used as the base class for both the specGloss and metalRough conventions.
  104570. */
  104571. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  104572. /**
  104573. * Number of Simultaneous lights allowed on the material.
  104574. */
  104575. maxSimultaneousLights: number;
  104576. /**
  104577. * If sets to true, disables all the lights affecting the material.
  104578. */
  104579. disableLighting: boolean;
  104580. /**
  104581. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  104582. */
  104583. environmentTexture: BaseTexture;
  104584. /**
  104585. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104586. */
  104587. invertNormalMapX: boolean;
  104588. /**
  104589. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104590. */
  104591. invertNormalMapY: boolean;
  104592. /**
  104593. * Normal map used in the model.
  104594. */
  104595. normalTexture: BaseTexture;
  104596. /**
  104597. * Emissivie color used to self-illuminate the model.
  104598. */
  104599. emissiveColor: Color3;
  104600. /**
  104601. * Emissivie texture used to self-illuminate the model.
  104602. */
  104603. emissiveTexture: BaseTexture;
  104604. /**
  104605. * Occlusion Channel Strenght.
  104606. */
  104607. occlusionStrength: number;
  104608. /**
  104609. * Occlusion Texture of the material (adding extra occlusion effects).
  104610. */
  104611. occlusionTexture: BaseTexture;
  104612. /**
  104613. * Defines the alpha limits in alpha test mode.
  104614. */
  104615. alphaCutOff: number;
  104616. /**
  104617. * Gets the current double sided mode.
  104618. */
  104619. /**
  104620. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104621. */
  104622. doubleSided: boolean;
  104623. /**
  104624. * Stores the pre-calculated light information of a mesh in a texture.
  104625. */
  104626. lightmapTexture: BaseTexture;
  104627. /**
  104628. * If true, the light map contains occlusion information instead of lighting info.
  104629. */
  104630. useLightmapAsShadowmap: boolean;
  104631. /**
  104632. * Instantiates a new PBRMaterial instance.
  104633. *
  104634. * @param name The material name
  104635. * @param scene The scene the material will be use in.
  104636. */
  104637. constructor(name: string, scene: Scene);
  104638. getClassName(): string;
  104639. }
  104640. }
  104641. declare module BABYLON {
  104642. /**
  104643. * The PBR material of BJS following the metal roughness convention.
  104644. *
  104645. * This fits to the PBR convention in the GLTF definition:
  104646. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  104647. */
  104648. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  104649. /**
  104650. * The base color has two different interpretations depending on the value of metalness.
  104651. * When the material is a metal, the base color is the specific measured reflectance value
  104652. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  104653. * of the material.
  104654. */
  104655. baseColor: Color3;
  104656. /**
  104657. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  104658. * well as opacity information in the alpha channel.
  104659. */
  104660. baseTexture: BaseTexture;
  104661. /**
  104662. * Specifies the metallic scalar value of the material.
  104663. * Can also be used to scale the metalness values of the metallic texture.
  104664. */
  104665. metallic: number;
  104666. /**
  104667. * Specifies the roughness scalar value of the material.
  104668. * Can also be used to scale the roughness values of the metallic texture.
  104669. */
  104670. roughness: number;
  104671. /**
  104672. * Texture containing both the metallic value in the B channel and the
  104673. * roughness value in the G channel to keep better precision.
  104674. */
  104675. metallicRoughnessTexture: BaseTexture;
  104676. /**
  104677. * Instantiates a new PBRMetalRoughnessMaterial instance.
  104678. *
  104679. * @param name The material name
  104680. * @param scene The scene the material will be use in.
  104681. */
  104682. constructor(name: string, scene: Scene);
  104683. /**
  104684. * Return the currrent class name of the material.
  104685. */
  104686. getClassName(): string;
  104687. /**
  104688. * Makes a duplicate of the current material.
  104689. * @param name - name to use for the new material.
  104690. */
  104691. clone(name: string): PBRMetallicRoughnessMaterial;
  104692. /**
  104693. * Serialize the material to a parsable JSON object.
  104694. */
  104695. serialize(): any;
  104696. /**
  104697. * Parses a JSON object correponding to the serialize function.
  104698. */
  104699. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  104700. }
  104701. }
  104702. declare module BABYLON {
  104703. /**
  104704. * The PBR material of BJS following the specular glossiness convention.
  104705. *
  104706. * This fits to the PBR convention in the GLTF definition:
  104707. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  104708. */
  104709. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  104710. /**
  104711. * Specifies the diffuse color of the material.
  104712. */
  104713. diffuseColor: Color3;
  104714. /**
  104715. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  104716. * channel.
  104717. */
  104718. diffuseTexture: BaseTexture;
  104719. /**
  104720. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  104721. */
  104722. specularColor: Color3;
  104723. /**
  104724. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  104725. */
  104726. glossiness: number;
  104727. /**
  104728. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  104729. */
  104730. specularGlossinessTexture: BaseTexture;
  104731. /**
  104732. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  104733. *
  104734. * @param name The material name
  104735. * @param scene The scene the material will be use in.
  104736. */
  104737. constructor(name: string, scene: Scene);
  104738. /**
  104739. * Return the currrent class name of the material.
  104740. */
  104741. getClassName(): string;
  104742. /**
  104743. * Makes a duplicate of the current material.
  104744. * @param name - name to use for the new material.
  104745. */
  104746. clone(name: string): PBRSpecularGlossinessMaterial;
  104747. /**
  104748. * Serialize the material to a parsable JSON object.
  104749. */
  104750. serialize(): any;
  104751. /**
  104752. * Parses a JSON object correponding to the serialize function.
  104753. */
  104754. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  104755. }
  104756. }
  104757. declare module BABYLON {
  104758. /**
  104759. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  104760. * It can help converting any input color in a desired output one. This can then be used to create effects
  104761. * from sepia, black and white to sixties or futuristic rendering...
  104762. *
  104763. * The only supported format is currently 3dl.
  104764. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  104765. */
  104766. export class ColorGradingTexture extends BaseTexture {
  104767. /**
  104768. * The current texture matrix. (will always be identity in color grading texture)
  104769. */
  104770. private _textureMatrix;
  104771. /**
  104772. * The texture URL.
  104773. */
  104774. url: string;
  104775. /**
  104776. * Empty line regex stored for GC.
  104777. */
  104778. private static _noneEmptyLineRegex;
  104779. private _engine;
  104780. /**
  104781. * Instantiates a ColorGradingTexture from the following parameters.
  104782. *
  104783. * @param url The location of the color gradind data (currently only supporting 3dl)
  104784. * @param scene The scene the texture will be used in
  104785. */
  104786. constructor(url: string, scene: Scene);
  104787. /**
  104788. * Returns the texture matrix used in most of the material.
  104789. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  104790. */
  104791. getTextureMatrix(): Matrix;
  104792. /**
  104793. * Occurs when the file being loaded is a .3dl LUT file.
  104794. */
  104795. private load3dlTexture;
  104796. /**
  104797. * Starts the loading process of the texture.
  104798. */
  104799. private loadTexture;
  104800. /**
  104801. * Clones the color gradind texture.
  104802. */
  104803. clone(): ColorGradingTexture;
  104804. /**
  104805. * Called during delayed load for textures.
  104806. */
  104807. delayLoad(): void;
  104808. /**
  104809. * Parses a color grading texture serialized by Babylon.
  104810. * @param parsedTexture The texture information being parsedTexture
  104811. * @param scene The scene to load the texture in
  104812. * @param rootUrl The root url of the data assets to load
  104813. * @return A color gradind texture
  104814. */
  104815. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  104816. /**
  104817. * Serializes the LUT texture to json format.
  104818. */
  104819. serialize(): any;
  104820. }
  104821. }
  104822. declare module BABYLON {
  104823. /**
  104824. * Based on jsTGALoader - Javascript loader for TGA file
  104825. * By Vincent Thibault
  104826. * @see http://blog.robrowser.com/javascript-tga-loader.html
  104827. */
  104828. export class TGATools {
  104829. private static _TYPE_INDEXED;
  104830. private static _TYPE_RGB;
  104831. private static _TYPE_GREY;
  104832. private static _TYPE_RLE_INDEXED;
  104833. private static _TYPE_RLE_RGB;
  104834. private static _TYPE_RLE_GREY;
  104835. private static _ORIGIN_MASK;
  104836. private static _ORIGIN_SHIFT;
  104837. private static _ORIGIN_BL;
  104838. private static _ORIGIN_BR;
  104839. private static _ORIGIN_UL;
  104840. private static _ORIGIN_UR;
  104841. /**
  104842. * Gets the header of a TGA file
  104843. * @param data defines the TGA data
  104844. * @returns the header
  104845. */
  104846. static GetTGAHeader(data: Uint8Array): any;
  104847. /**
  104848. * Uploads TGA content to a Babylon Texture
  104849. * @hidden
  104850. */
  104851. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  104852. /** @hidden */
  104853. 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;
  104854. /** @hidden */
  104855. 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;
  104856. /** @hidden */
  104857. 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;
  104858. /** @hidden */
  104859. 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;
  104860. /** @hidden */
  104861. 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;
  104862. /** @hidden */
  104863. 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;
  104864. }
  104865. }
  104866. declare module BABYLON {
  104867. /**
  104868. * Implementation of the TGA Texture Loader.
  104869. * @hidden
  104870. */
  104871. export class _TGATextureLoader implements IInternalTextureLoader {
  104872. /**
  104873. * Defines wether the loader supports cascade loading the different faces.
  104874. */
  104875. readonly supportCascades: boolean;
  104876. /**
  104877. * This returns if the loader support the current file information.
  104878. * @param extension defines the file extension of the file being loaded
  104879. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104880. * @param fallback defines the fallback internal texture if any
  104881. * @param isBase64 defines whether the texture is encoded as a base64
  104882. * @param isBuffer defines whether the texture data are stored as a buffer
  104883. * @returns true if the loader can load the specified file
  104884. */
  104885. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  104886. /**
  104887. * Transform the url before loading if required.
  104888. * @param rootUrl the url of the texture
  104889. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104890. * @returns the transformed texture
  104891. */
  104892. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  104893. /**
  104894. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  104895. * @param rootUrl the url of the texture
  104896. * @param textureFormatInUse defines the current compressed format in use iun the engine
  104897. * @returns the fallback texture
  104898. */
  104899. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  104900. /**
  104901. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  104902. * @param data contains the texture data
  104903. * @param texture defines the BabylonJS internal texture
  104904. * @param createPolynomials will be true if polynomials have been requested
  104905. * @param onLoad defines the callback to trigger once the texture is ready
  104906. * @param onError defines the callback to trigger in case of error
  104907. */
  104908. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  104909. /**
  104910. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  104911. * @param data contains the texture data
  104912. * @param texture defines the BabylonJS internal texture
  104913. * @param callback defines the method to call once ready to upload
  104914. */
  104915. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  104916. }
  104917. }
  104918. declare module BABYLON {
  104919. /**
  104920. * 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.
  104921. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104922. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104923. */
  104924. export class CustomProceduralTexture extends ProceduralTexture {
  104925. private _animate;
  104926. private _time;
  104927. private _config;
  104928. private _texturePath;
  104929. /**
  104930. * Instantiates a new Custom Procedural Texture.
  104931. * 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.
  104932. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  104933. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  104934. * @param name Define the name of the texture
  104935. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  104936. * @param size Define the size of the texture to create
  104937. * @param scene Define the scene the texture belongs to
  104938. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  104939. * @param generateMipMaps Define if the texture should creates mip maps or not
  104940. */
  104941. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104942. private _loadJson;
  104943. /**
  104944. * Is the texture ready to be used ? (rendered at least once)
  104945. * @returns true if ready, otherwise, false.
  104946. */
  104947. isReady(): boolean;
  104948. /**
  104949. * Render the texture to its associated render target.
  104950. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  104951. */
  104952. render(useCameraPostProcess?: boolean): void;
  104953. /**
  104954. * Update the list of dependant textures samplers in the shader.
  104955. */
  104956. updateTextures(): void;
  104957. /**
  104958. * Update the uniform values of the procedural texture in the shader.
  104959. */
  104960. updateShaderUniforms(): void;
  104961. /**
  104962. * Define if the texture animates or not.
  104963. */
  104964. animate: boolean;
  104965. }
  104966. }
  104967. declare module BABYLON {
  104968. /** @hidden */
  104969. export var noisePixelShader: {
  104970. name: string;
  104971. shader: string;
  104972. };
  104973. }
  104974. declare module BABYLON {
  104975. /**
  104976. * Class used to generate noise procedural textures
  104977. */
  104978. export class NoiseProceduralTexture extends ProceduralTexture {
  104979. private _time;
  104980. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  104981. brightness: number;
  104982. /** Defines the number of octaves to process */
  104983. octaves: number;
  104984. /** Defines the level of persistence (0.8 by default) */
  104985. persistence: number;
  104986. /** Gets or sets animation speed factor (default is 1) */
  104987. animationSpeedFactor: number;
  104988. /**
  104989. * Creates a new NoiseProceduralTexture
  104990. * @param name defines the name fo the texture
  104991. * @param size defines the size of the texture (default is 256)
  104992. * @param scene defines the hosting scene
  104993. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  104994. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  104995. */
  104996. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  104997. private _updateShaderUniforms;
  104998. protected _getDefines(): string;
  104999. /** Generate the current state of the procedural texture */
  105000. render(useCameraPostProcess?: boolean): void;
  105001. /**
  105002. * Serializes this noise procedural texture
  105003. * @returns a serialized noise procedural texture object
  105004. */
  105005. serialize(): any;
  105006. /**
  105007. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  105008. * @param parsedTexture defines parsed texture data
  105009. * @param scene defines the current scene
  105010. * @param rootUrl defines the root URL containing noise procedural texture information
  105011. * @returns a parsed NoiseProceduralTexture
  105012. */
  105013. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  105014. }
  105015. }
  105016. declare module BABYLON {
  105017. /**
  105018. * Raw cube texture where the raw buffers are passed in
  105019. */
  105020. export class RawCubeTexture extends CubeTexture {
  105021. /**
  105022. * Creates a cube texture where the raw buffers are passed in.
  105023. * @param scene defines the scene the texture is attached to
  105024. * @param data defines the array of data to use to create each face
  105025. * @param size defines the size of the textures
  105026. * @param format defines the format of the data
  105027. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105028. * @param generateMipMaps defines if the engine should generate the mip levels
  105029. * @param invertY defines if data must be stored with Y axis inverted
  105030. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105031. * @param compression defines the compression used (null by default)
  105032. */
  105033. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  105034. /**
  105035. * Updates the raw cube texture.
  105036. * @param data defines the data to store
  105037. * @param format defines the data format
  105038. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105039. * @param invertY defines if data must be stored with Y axis inverted
  105040. * @param compression defines the compression used (null by default)
  105041. * @param level defines which level of the texture to update
  105042. */
  105043. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  105044. /**
  105045. * Updates a raw cube texture with RGBD encoded data.
  105046. * @param data defines the array of data [mipmap][face] to use to create each face
  105047. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  105048. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  105049. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  105050. * @returns a promsie that resolves when the operation is complete
  105051. */
  105052. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  105053. /**
  105054. * Clones the raw cube texture.
  105055. * @return a new cube texture
  105056. */
  105057. clone(): CubeTexture;
  105058. /** @hidden */
  105059. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105060. }
  105061. }
  105062. declare module BABYLON {
  105063. /**
  105064. * Class used to store 3D textures containing user data
  105065. */
  105066. export class RawTexture3D extends Texture {
  105067. /** Gets or sets the texture format to use */
  105068. format: number;
  105069. private _engine;
  105070. /**
  105071. * Create a new RawTexture3D
  105072. * @param data defines the data of the texture
  105073. * @param width defines the width of the texture
  105074. * @param height defines the height of the texture
  105075. * @param depth defines the depth of the texture
  105076. * @param format defines the texture format to use
  105077. * @param scene defines the hosting scene
  105078. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  105079. * @param invertY defines if texture must be stored with Y axis inverted
  105080. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  105081. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  105082. */
  105083. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  105084. /** Gets or sets the texture format to use */
  105085. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  105086. /**
  105087. * Update the texture with new data
  105088. * @param data defines the data to store in the texture
  105089. */
  105090. update(data: ArrayBufferView): void;
  105091. }
  105092. }
  105093. declare module BABYLON {
  105094. /**
  105095. * Creates a refraction texture used by refraction channel of the standard material.
  105096. * It is like a mirror but to see through a material.
  105097. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105098. */
  105099. export class RefractionTexture extends RenderTargetTexture {
  105100. /**
  105101. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  105102. * 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.
  105103. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105104. */
  105105. refractionPlane: Plane;
  105106. /**
  105107. * Define how deep under the surface we should see.
  105108. */
  105109. depth: number;
  105110. /**
  105111. * Creates a refraction texture used by refraction channel of the standard material.
  105112. * It is like a mirror but to see through a material.
  105113. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  105114. * @param name Define the texture name
  105115. * @param size Define the size of the underlying texture
  105116. * @param scene Define the scene the refraction belongs to
  105117. * @param generateMipMaps Define if we need to generate mips level for the refraction
  105118. */
  105119. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  105120. /**
  105121. * Clone the refraction texture.
  105122. * @returns the cloned texture
  105123. */
  105124. clone(): RefractionTexture;
  105125. /**
  105126. * Serialize the texture to a JSON representation you could use in Parse later on
  105127. * @returns the serialized JSON representation
  105128. */
  105129. serialize(): any;
  105130. }
  105131. }
  105132. declare module BABYLON {
  105133. /**
  105134. * Configuration for Draco compression
  105135. */
  105136. export interface IDracoCompressionConfiguration {
  105137. /**
  105138. * Configuration for the decoder.
  105139. */
  105140. decoder?: {
  105141. /**
  105142. * The url to the WebAssembly module.
  105143. */
  105144. wasmUrl?: string;
  105145. /**
  105146. * The url to the WebAssembly binary.
  105147. */
  105148. wasmBinaryUrl?: string;
  105149. /**
  105150. * The url to the fallback JavaScript module.
  105151. */
  105152. fallbackUrl?: string;
  105153. };
  105154. }
  105155. /**
  105156. * Draco compression (https://google.github.io/draco/)
  105157. *
  105158. * This class wraps the Draco module.
  105159. *
  105160. * **Encoder**
  105161. *
  105162. * The encoder is not currently implemented.
  105163. *
  105164. * **Decoder**
  105165. *
  105166. * 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.
  105167. *
  105168. * To update the configuration, use the following code:
  105169. * ```javascript
  105170. * DracoCompression.Configuration = {
  105171. * decoder: {
  105172. * wasmUrl: "<url to the WebAssembly library>",
  105173. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  105174. * fallbackUrl: "<url to the fallback JavaScript library>",
  105175. * }
  105176. * };
  105177. * ```
  105178. *
  105179. * 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.
  105180. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  105181. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  105182. *
  105183. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  105184. * ```javascript
  105185. * var dracoCompression = new DracoCompression();
  105186. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  105187. * [VertexBuffer.PositionKind]: 0
  105188. * });
  105189. * ```
  105190. *
  105191. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  105192. */
  105193. export class DracoCompression implements IDisposable {
  105194. private static _DecoderModulePromise;
  105195. /**
  105196. * The configuration. Defaults to the following urls:
  105197. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  105198. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  105199. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  105200. */
  105201. static Configuration: IDracoCompressionConfiguration;
  105202. /**
  105203. * Returns true if the decoder is available.
  105204. */
  105205. static readonly DecoderAvailable: boolean;
  105206. /**
  105207. * Constructor
  105208. */
  105209. constructor();
  105210. /**
  105211. * Stop all async operations and release resources.
  105212. */
  105213. dispose(): void;
  105214. /**
  105215. * Decode Draco compressed mesh data to vertex data.
  105216. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  105217. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  105218. * @returns A promise that resolves with the decoded vertex data
  105219. */
  105220. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  105221. [kind: string]: number;
  105222. }): Promise<VertexData>;
  105223. private static _GetDecoderModule;
  105224. private static _LoadScriptAsync;
  105225. private static _LoadFileAsync;
  105226. }
  105227. }
  105228. declare module BABYLON {
  105229. /**
  105230. * Class for building Constructive Solid Geometry
  105231. */
  105232. export class CSG {
  105233. private polygons;
  105234. /**
  105235. * The world matrix
  105236. */
  105237. matrix: Matrix;
  105238. /**
  105239. * Stores the position
  105240. */
  105241. position: Vector3;
  105242. /**
  105243. * Stores the rotation
  105244. */
  105245. rotation: Vector3;
  105246. /**
  105247. * Stores the rotation quaternion
  105248. */
  105249. rotationQuaternion: Nullable<Quaternion>;
  105250. /**
  105251. * Stores the scaling vector
  105252. */
  105253. scaling: Vector3;
  105254. /**
  105255. * Convert the Mesh to CSG
  105256. * @param mesh The Mesh to convert to CSG
  105257. * @returns A new CSG from the Mesh
  105258. */
  105259. static FromMesh(mesh: Mesh): CSG;
  105260. /**
  105261. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  105262. * @param polygons Polygons used to construct a CSG solid
  105263. */
  105264. private static FromPolygons;
  105265. /**
  105266. * Clones, or makes a deep copy, of the CSG
  105267. * @returns A new CSG
  105268. */
  105269. clone(): CSG;
  105270. /**
  105271. * Unions this CSG with another CSG
  105272. * @param csg The CSG to union against this CSG
  105273. * @returns The unioned CSG
  105274. */
  105275. union(csg: CSG): CSG;
  105276. /**
  105277. * Unions this CSG with another CSG in place
  105278. * @param csg The CSG to union against this CSG
  105279. */
  105280. unionInPlace(csg: CSG): void;
  105281. /**
  105282. * Subtracts this CSG with another CSG
  105283. * @param csg The CSG to subtract against this CSG
  105284. * @returns A new CSG
  105285. */
  105286. subtract(csg: CSG): CSG;
  105287. /**
  105288. * Subtracts this CSG with another CSG in place
  105289. * @param csg The CSG to subtact against this CSG
  105290. */
  105291. subtractInPlace(csg: CSG): void;
  105292. /**
  105293. * Intersect this CSG with another CSG
  105294. * @param csg The CSG to intersect against this CSG
  105295. * @returns A new CSG
  105296. */
  105297. intersect(csg: CSG): CSG;
  105298. /**
  105299. * Intersects this CSG with another CSG in place
  105300. * @param csg The CSG to intersect against this CSG
  105301. */
  105302. intersectInPlace(csg: CSG): void;
  105303. /**
  105304. * Return a new CSG solid with solid and empty space switched. This solid is
  105305. * not modified.
  105306. * @returns A new CSG solid with solid and empty space switched
  105307. */
  105308. inverse(): CSG;
  105309. /**
  105310. * Inverses the CSG in place
  105311. */
  105312. inverseInPlace(): void;
  105313. /**
  105314. * This is used to keep meshes transformations so they can be restored
  105315. * when we build back a Babylon Mesh
  105316. * NB : All CSG operations are performed in world coordinates
  105317. * @param csg The CSG to copy the transform attributes from
  105318. * @returns This CSG
  105319. */
  105320. copyTransformAttributes(csg: CSG): CSG;
  105321. /**
  105322. * Build Raw mesh from CSG
  105323. * Coordinates here are in world space
  105324. * @param name The name of the mesh geometry
  105325. * @param scene The Scene
  105326. * @param keepSubMeshes Specifies if the submeshes should be kept
  105327. * @returns A new Mesh
  105328. */
  105329. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  105330. /**
  105331. * Build Mesh from CSG taking material and transforms into account
  105332. * @param name The name of the Mesh
  105333. * @param material The material of the Mesh
  105334. * @param scene The Scene
  105335. * @param keepSubMeshes Specifies if submeshes should be kept
  105336. * @returns The new Mesh
  105337. */
  105338. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  105339. }
  105340. }
  105341. declare module BABYLON {
  105342. /**
  105343. * Class used to create a trail following a mesh
  105344. */
  105345. export class TrailMesh extends Mesh {
  105346. private _generator;
  105347. private _autoStart;
  105348. private _running;
  105349. private _diameter;
  105350. private _length;
  105351. private _sectionPolygonPointsCount;
  105352. private _sectionVectors;
  105353. private _sectionNormalVectors;
  105354. private _beforeRenderObserver;
  105355. /**
  105356. * @constructor
  105357. * @param name The value used by scene.getMeshByName() to do a lookup.
  105358. * @param generator The mesh to generate a trail.
  105359. * @param scene The scene to add this mesh to.
  105360. * @param diameter Diameter of trailing mesh. Default is 1.
  105361. * @param length Length of trailing mesh. Default is 60.
  105362. * @param autoStart Automatically start trailing mesh. Default true.
  105363. */
  105364. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  105365. /**
  105366. * "TrailMesh"
  105367. * @returns "TrailMesh"
  105368. */
  105369. getClassName(): string;
  105370. private _createMesh;
  105371. /**
  105372. * Start trailing mesh.
  105373. */
  105374. start(): void;
  105375. /**
  105376. * Stop trailing mesh.
  105377. */
  105378. stop(): void;
  105379. /**
  105380. * Update trailing mesh geometry.
  105381. */
  105382. update(): void;
  105383. /**
  105384. * Returns a new TrailMesh object.
  105385. * @param name is a string, the name given to the new mesh
  105386. * @param newGenerator use new generator object for cloned trail mesh
  105387. * @returns a new mesh
  105388. */
  105389. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  105390. /**
  105391. * Serializes this trail mesh
  105392. * @param serializationObject object to write serialization to
  105393. */
  105394. serialize(serializationObject: any): void;
  105395. /**
  105396. * Parses a serialized trail mesh
  105397. * @param parsedMesh the serialized mesh
  105398. * @param scene the scene to create the trail mesh in
  105399. * @returns the created trail mesh
  105400. */
  105401. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  105402. }
  105403. }
  105404. declare module BABYLON {
  105405. /**
  105406. * Class containing static functions to help procedurally build meshes
  105407. */
  105408. export class RibbonBuilder {
  105409. /**
  105410. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105411. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105412. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105413. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105414. * * 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
  105415. * * 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
  105416. * * 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
  105417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105420. * * 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
  105421. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105422. * * 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
  105423. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105425. * @param name defines the name of the mesh
  105426. * @param options defines the options used to create the mesh
  105427. * @param scene defines the hosting scene
  105428. * @returns the ribbon mesh
  105429. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105431. */
  105432. static CreateRibbon(name: string, options: {
  105433. pathArray: Vector3[][];
  105434. closeArray?: boolean;
  105435. closePath?: boolean;
  105436. offset?: number;
  105437. updatable?: boolean;
  105438. sideOrientation?: number;
  105439. frontUVs?: Vector4;
  105440. backUVs?: Vector4;
  105441. instance?: Mesh;
  105442. invertUV?: boolean;
  105443. uvs?: Vector2[];
  105444. colors?: Color4[];
  105445. }, scene?: Nullable<Scene>): Mesh;
  105446. }
  105447. }
  105448. declare module BABYLON {
  105449. /**
  105450. * Class containing static functions to help procedurally build meshes
  105451. */
  105452. export class TorusKnotBuilder {
  105453. /**
  105454. * Creates a torus knot mesh
  105455. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  105456. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  105457. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  105458. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  105459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105462. * @param name defines the name of the mesh
  105463. * @param options defines the options used to create the mesh
  105464. * @param scene defines the hosting scene
  105465. * @returns the torus knot mesh
  105466. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  105467. */
  105468. static CreateTorusKnot(name: string, options: {
  105469. radius?: number;
  105470. tube?: number;
  105471. radialSegments?: number;
  105472. tubularSegments?: number;
  105473. p?: number;
  105474. q?: number;
  105475. updatable?: boolean;
  105476. sideOrientation?: number;
  105477. frontUVs?: Vector4;
  105478. backUVs?: Vector4;
  105479. }, scene: any): Mesh;
  105480. }
  105481. }
  105482. declare module BABYLON {
  105483. /**
  105484. * Polygon
  105485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105486. */
  105487. export class Polygon {
  105488. /**
  105489. * Creates a rectangle
  105490. * @param xmin bottom X coord
  105491. * @param ymin bottom Y coord
  105492. * @param xmax top X coord
  105493. * @param ymax top Y coord
  105494. * @returns points that make the resulting rectation
  105495. */
  105496. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  105497. /**
  105498. * Creates a circle
  105499. * @param radius radius of circle
  105500. * @param cx scale in x
  105501. * @param cy scale in y
  105502. * @param numberOfSides number of sides that make up the circle
  105503. * @returns points that make the resulting circle
  105504. */
  105505. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  105506. /**
  105507. * Creates a polygon from input string
  105508. * @param input Input polygon data
  105509. * @returns the parsed points
  105510. */
  105511. static Parse(input: string): Vector2[];
  105512. /**
  105513. * Starts building a polygon from x and y coordinates
  105514. * @param x x coordinate
  105515. * @param y y coordinate
  105516. * @returns the started path2
  105517. */
  105518. static StartingAt(x: number, y: number): Path2;
  105519. }
  105520. /**
  105521. * Builds a polygon
  105522. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  105523. */
  105524. export class PolygonMeshBuilder {
  105525. private _points;
  105526. private _outlinepoints;
  105527. private _holes;
  105528. private _name;
  105529. private _scene;
  105530. private _epoints;
  105531. private _eholes;
  105532. private _addToepoint;
  105533. /**
  105534. * Babylon reference to the earcut plugin.
  105535. */
  105536. bjsEarcut: any;
  105537. /**
  105538. * Creates a PolygonMeshBuilder
  105539. * @param name name of the builder
  105540. * @param contours Path of the polygon
  105541. * @param scene scene to add to
  105542. * @param earcutInjection can be used to inject your own earcut reference
  105543. */
  105544. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  105545. /**
  105546. * Adds a whole within the polygon
  105547. * @param hole Array of points defining the hole
  105548. * @returns this
  105549. */
  105550. addHole(hole: Vector2[]): PolygonMeshBuilder;
  105551. /**
  105552. * Creates the polygon
  105553. * @param updatable If the mesh should be updatable
  105554. * @param depth The depth of the mesh created
  105555. * @returns the created mesh
  105556. */
  105557. build(updatable?: boolean, depth?: number): Mesh;
  105558. /**
  105559. * Adds a side to the polygon
  105560. * @param positions points that make the polygon
  105561. * @param normals normals of the polygon
  105562. * @param uvs uvs of the polygon
  105563. * @param indices indices of the polygon
  105564. * @param bounds bounds of the polygon
  105565. * @param points points of the polygon
  105566. * @param depth depth of the polygon
  105567. * @param flip flip of the polygon
  105568. */
  105569. private addSide;
  105570. }
  105571. }
  105572. declare module BABYLON {
  105573. /**
  105574. * Class containing static functions to help procedurally build meshes
  105575. */
  105576. export class PolygonBuilder {
  105577. /**
  105578. * Creates a polygon mesh
  105579. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  105580. * * 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
  105581. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  105584. * * Remember you can only change the shape positions, not their number when updating a polygon
  105585. * @param name defines the name of the mesh
  105586. * @param options defines the options used to create the mesh
  105587. * @param scene defines the hosting scene
  105588. * @param earcutInjection can be used to inject your own earcut reference
  105589. * @returns the polygon mesh
  105590. */
  105591. static CreatePolygon(name: string, options: {
  105592. shape: Vector3[];
  105593. holes?: Vector3[][];
  105594. depth?: number;
  105595. faceUV?: Vector4[];
  105596. faceColors?: Color4[];
  105597. updatable?: boolean;
  105598. sideOrientation?: number;
  105599. frontUVs?: Vector4;
  105600. backUVs?: Vector4;
  105601. }, scene: Scene, earcutInjection?: any): Mesh;
  105602. /**
  105603. * Creates an extruded polygon mesh, with depth in the Y direction.
  105604. * * 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)
  105605. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105606. * @param name defines the name of the mesh
  105607. * @param options defines the options used to create the mesh
  105608. * @param scene defines the hosting scene
  105609. * @param earcutInjection can be used to inject your own earcut reference
  105610. * @returns the polygon mesh
  105611. */
  105612. static ExtrudePolygon(name: string, options: {
  105613. shape: Vector3[];
  105614. holes?: Vector3[][];
  105615. depth?: number;
  105616. faceUV?: Vector4[];
  105617. faceColors?: Color4[];
  105618. updatable?: boolean;
  105619. sideOrientation?: number;
  105620. frontUVs?: Vector4;
  105621. backUVs?: Vector4;
  105622. }, scene: Scene, earcutInjection?: any): Mesh;
  105623. }
  105624. }
  105625. declare module BABYLON {
  105626. /**
  105627. * Class containing static functions to help procedurally build meshes
  105628. */
  105629. export class ShapeBuilder {
  105630. /**
  105631. * 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.
  105632. * * 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.
  105633. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105634. * * 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.
  105635. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  105636. * * 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
  105637. * * 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
  105638. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  105639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105641. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  105642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105643. * @param name defines the name of the mesh
  105644. * @param options defines the options used to create the mesh
  105645. * @param scene defines the hosting scene
  105646. * @returns the extruded shape mesh
  105647. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105649. */
  105650. static ExtrudeShape(name: string, options: {
  105651. shape: Vector3[];
  105652. path: Vector3[];
  105653. scale?: number;
  105654. rotation?: number;
  105655. cap?: number;
  105656. updatable?: boolean;
  105657. sideOrientation?: number;
  105658. frontUVs?: Vector4;
  105659. backUVs?: Vector4;
  105660. instance?: Mesh;
  105661. invertUV?: boolean;
  105662. }, scene?: Nullable<Scene>): Mesh;
  105663. /**
  105664. * Creates an custom extruded shape mesh.
  105665. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  105666. * * 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.
  105667. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  105668. * * 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
  105669. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  105670. * * 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
  105671. * * It must returns a float value that will be the scale value applied to the shape on each path point
  105672. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105673. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  105674. * * 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
  105675. * * 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
  105676. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  105677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105679. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105681. * @param name defines the name of the mesh
  105682. * @param options defines the options used to create the mesh
  105683. * @param scene defines the hosting scene
  105684. * @returns the custom extruded shape mesh
  105685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  105686. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105688. */
  105689. static ExtrudeShapeCustom(name: string, options: {
  105690. shape: Vector3[];
  105691. path: Vector3[];
  105692. scaleFunction?: any;
  105693. rotationFunction?: any;
  105694. ribbonCloseArray?: boolean;
  105695. ribbonClosePath?: boolean;
  105696. cap?: number;
  105697. updatable?: boolean;
  105698. sideOrientation?: number;
  105699. frontUVs?: Vector4;
  105700. backUVs?: Vector4;
  105701. instance?: Mesh;
  105702. invertUV?: boolean;
  105703. }, scene: Scene): Mesh;
  105704. private static _ExtrudeShapeGeneric;
  105705. }
  105706. }
  105707. declare module BABYLON {
  105708. /**
  105709. * Class containing static functions to help procedurally build meshes
  105710. */
  105711. export class LatheBuilder {
  105712. /**
  105713. * Creates lathe mesh.
  105714. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  105715. * * 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
  105716. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  105717. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  105718. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  105719. * * 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
  105720. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  105721. * * 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
  105722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105724. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105726. * @param name defines the name of the mesh
  105727. * @param options defines the options used to create the mesh
  105728. * @param scene defines the hosting scene
  105729. * @returns the lathe mesh
  105730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  105731. */
  105732. static CreateLathe(name: string, options: {
  105733. shape: Vector3[];
  105734. radius?: number;
  105735. tessellation?: number;
  105736. clip?: number;
  105737. arc?: number;
  105738. closed?: boolean;
  105739. updatable?: boolean;
  105740. sideOrientation?: number;
  105741. frontUVs?: Vector4;
  105742. backUVs?: Vector4;
  105743. cap?: number;
  105744. invertUV?: boolean;
  105745. }, scene: Scene): Mesh;
  105746. }
  105747. }
  105748. declare module BABYLON {
  105749. /**
  105750. * Class containing static functions to help procedurally build meshes
  105751. */
  105752. export class TubeBuilder {
  105753. /**
  105754. * Creates a tube mesh.
  105755. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105756. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  105757. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  105758. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  105759. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  105760. * * 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)
  105761. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  105762. * * 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
  105763. * * 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
  105764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105768. * @param name defines the name of the mesh
  105769. * @param options defines the options used to create the mesh
  105770. * @param scene defines the hosting scene
  105771. * @returns the tube mesh
  105772. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105773. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  105774. */
  105775. static CreateTube(name: string, options: {
  105776. path: Vector3[];
  105777. radius?: number;
  105778. tessellation?: number;
  105779. radiusFunction?: {
  105780. (i: number, distance: number): number;
  105781. };
  105782. cap?: number;
  105783. arc?: number;
  105784. updatable?: boolean;
  105785. sideOrientation?: number;
  105786. frontUVs?: Vector4;
  105787. backUVs?: Vector4;
  105788. instance?: Mesh;
  105789. invertUV?: boolean;
  105790. }, scene: Scene): Mesh;
  105791. }
  105792. }
  105793. declare module BABYLON {
  105794. /**
  105795. * Class containing static functions to help procedurally build meshes
  105796. */
  105797. export class IcoSphereBuilder {
  105798. /**
  105799. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105800. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105801. * * 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`)
  105802. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105803. * * 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
  105804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105807. * @param name defines the name of the mesh
  105808. * @param options defines the options used to create the mesh
  105809. * @param scene defines the hosting scene
  105810. * @returns the icosahedron mesh
  105811. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105812. */
  105813. static CreateIcoSphere(name: string, options: {
  105814. radius?: number;
  105815. radiusX?: number;
  105816. radiusY?: number;
  105817. radiusZ?: number;
  105818. flat?: boolean;
  105819. subdivisions?: number;
  105820. sideOrientation?: number;
  105821. frontUVs?: Vector4;
  105822. backUVs?: Vector4;
  105823. updatable?: boolean;
  105824. }, scene: Scene): Mesh;
  105825. }
  105826. }
  105827. declare module BABYLON {
  105828. /**
  105829. * Class containing static functions to help procedurally build meshes
  105830. */
  105831. export class DecalBuilder {
  105832. /**
  105833. * Creates a decal mesh.
  105834. * 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
  105835. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  105836. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  105837. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  105838. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  105839. * @param name defines the name of the mesh
  105840. * @param sourceMesh defines the mesh where the decal must be applied
  105841. * @param options defines the options used to create the mesh
  105842. * @param scene defines the hosting scene
  105843. * @returns the decal mesh
  105844. * @see https://doc.babylonjs.com/how_to/decals
  105845. */
  105846. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  105847. position?: Vector3;
  105848. normal?: Vector3;
  105849. size?: Vector3;
  105850. angle?: number;
  105851. }): Mesh;
  105852. }
  105853. }
  105854. declare module BABYLON {
  105855. /**
  105856. * Class containing static functions to help procedurally build meshes
  105857. */
  105858. export class MeshBuilder {
  105859. /**
  105860. * Creates a box mesh
  105861. * * The parameter `size` sets the size (float) of each box side (default 1)
  105862. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  105863. * * 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)
  105864. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  105865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105868. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  105869. * @param name defines the name of the mesh
  105870. * @param options defines the options used to create the mesh
  105871. * @param scene defines the hosting scene
  105872. * @returns the box mesh
  105873. */
  105874. static CreateBox(name: string, options: {
  105875. size?: number;
  105876. width?: number;
  105877. height?: number;
  105878. depth?: number;
  105879. faceUV?: Vector4[];
  105880. faceColors?: Color4[];
  105881. sideOrientation?: number;
  105882. frontUVs?: Vector4;
  105883. backUVs?: Vector4;
  105884. updatable?: boolean;
  105885. }, scene?: Nullable<Scene>): Mesh;
  105886. /**
  105887. * Creates a sphere mesh
  105888. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  105889. * * 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`)
  105890. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  105891. * * 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
  105892. * * 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)
  105893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105896. * @param name defines the name of the mesh
  105897. * @param options defines the options used to create the mesh
  105898. * @param scene defines the hosting scene
  105899. * @returns the sphere mesh
  105900. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  105901. */
  105902. static CreateSphere(name: string, options: {
  105903. segments?: number;
  105904. diameter?: number;
  105905. diameterX?: number;
  105906. diameterY?: number;
  105907. diameterZ?: number;
  105908. arc?: number;
  105909. slice?: number;
  105910. sideOrientation?: number;
  105911. frontUVs?: Vector4;
  105912. backUVs?: Vector4;
  105913. updatable?: boolean;
  105914. }, scene: any): Mesh;
  105915. /**
  105916. * Creates a plane polygonal mesh. By default, this is a disc
  105917. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  105918. * * 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
  105919. * * 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
  105920. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105921. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105923. * @param name defines the name of the mesh
  105924. * @param options defines the options used to create the mesh
  105925. * @param scene defines the hosting scene
  105926. * @returns the plane polygonal mesh
  105927. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  105928. */
  105929. static CreateDisc(name: string, options: {
  105930. radius?: number;
  105931. tessellation?: number;
  105932. arc?: number;
  105933. updatable?: boolean;
  105934. sideOrientation?: number;
  105935. frontUVs?: Vector4;
  105936. backUVs?: Vector4;
  105937. }, scene?: Nullable<Scene>): Mesh;
  105938. /**
  105939. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105940. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105941. * * 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`)
  105942. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105943. * * 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
  105944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105947. * @param name defines the name of the mesh
  105948. * @param options defines the options used to create the mesh
  105949. * @param scene defines the hosting scene
  105950. * @returns the icosahedron mesh
  105951. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105952. */
  105953. static CreateIcoSphere(name: string, options: {
  105954. radius?: number;
  105955. radiusX?: number;
  105956. radiusY?: number;
  105957. radiusZ?: number;
  105958. flat?: boolean;
  105959. subdivisions?: number;
  105960. sideOrientation?: number;
  105961. frontUVs?: Vector4;
  105962. backUVs?: Vector4;
  105963. updatable?: boolean;
  105964. }, scene: Scene): Mesh;
  105965. /**
  105966. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  105967. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  105968. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  105969. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  105970. * * 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
  105971. * * 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
  105972. * * 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
  105973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  105976. * * 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
  105977. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  105978. * * 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
  105979. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  105980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105981. * @param name defines the name of the mesh
  105982. * @param options defines the options used to create the mesh
  105983. * @param scene defines the hosting scene
  105984. * @returns the ribbon mesh
  105985. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  105986. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  105987. */
  105988. static CreateRibbon(name: string, options: {
  105989. pathArray: Vector3[][];
  105990. closeArray?: boolean;
  105991. closePath?: boolean;
  105992. offset?: number;
  105993. updatable?: boolean;
  105994. sideOrientation?: number;
  105995. frontUVs?: Vector4;
  105996. backUVs?: Vector4;
  105997. instance?: Mesh;
  105998. invertUV?: boolean;
  105999. uvs?: Vector2[];
  106000. colors?: Color4[];
  106001. }, scene?: Nullable<Scene>): Mesh;
  106002. /**
  106003. * Creates a cylinder or a cone mesh
  106004. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106005. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106006. * * 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.
  106007. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106008. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106009. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106010. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106011. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106012. * * 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).
  106013. * * 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
  106014. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106015. * * 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
  106016. * * 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.
  106017. * * If `enclose` is false, a ring surface is one element.
  106018. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106019. * * 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
  106020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106023. * @param name defines the name of the mesh
  106024. * @param options defines the options used to create the mesh
  106025. * @param scene defines the hosting scene
  106026. * @returns the cylinder mesh
  106027. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106028. */
  106029. static CreateCylinder(name: string, options: {
  106030. height?: number;
  106031. diameterTop?: number;
  106032. diameterBottom?: number;
  106033. diameter?: number;
  106034. tessellation?: number;
  106035. subdivisions?: number;
  106036. arc?: number;
  106037. faceColors?: Color4[];
  106038. faceUV?: Vector4[];
  106039. updatable?: boolean;
  106040. hasRings?: boolean;
  106041. enclose?: boolean;
  106042. sideOrientation?: number;
  106043. frontUVs?: Vector4;
  106044. backUVs?: Vector4;
  106045. }, scene: any): Mesh;
  106046. /**
  106047. * Creates a torus mesh
  106048. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106049. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106050. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106054. * @param name defines the name of the mesh
  106055. * @param options defines the options used to create the mesh
  106056. * @param scene defines the hosting scene
  106057. * @returns the torus mesh
  106058. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106059. */
  106060. static CreateTorus(name: string, options: {
  106061. diameter?: number;
  106062. thickness?: number;
  106063. tessellation?: number;
  106064. updatable?: boolean;
  106065. sideOrientation?: number;
  106066. frontUVs?: Vector4;
  106067. backUVs?: Vector4;
  106068. }, scene: any): Mesh;
  106069. /**
  106070. * Creates a torus knot mesh
  106071. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106072. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106073. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106074. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106078. * @param name defines the name of the mesh
  106079. * @param options defines the options used to create the mesh
  106080. * @param scene defines the hosting scene
  106081. * @returns the torus knot mesh
  106082. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106083. */
  106084. static CreateTorusKnot(name: string, options: {
  106085. radius?: number;
  106086. tube?: number;
  106087. radialSegments?: number;
  106088. tubularSegments?: number;
  106089. p?: number;
  106090. q?: number;
  106091. updatable?: boolean;
  106092. sideOrientation?: number;
  106093. frontUVs?: Vector4;
  106094. backUVs?: Vector4;
  106095. }, scene: any): Mesh;
  106096. /**
  106097. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106098. * * 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
  106099. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106100. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106101. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106102. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106103. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106104. * * 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
  106105. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106108. * @param name defines the name of the new line system
  106109. * @param options defines the options used to create the line system
  106110. * @param scene defines the hosting scene
  106111. * @returns a new line system mesh
  106112. */
  106113. static CreateLineSystem(name: string, options: {
  106114. lines: Vector3[][];
  106115. updatable?: boolean;
  106116. instance?: Nullable<LinesMesh>;
  106117. colors?: Nullable<Color4[][]>;
  106118. useVertexAlpha?: boolean;
  106119. }, scene: Nullable<Scene>): LinesMesh;
  106120. /**
  106121. * Creates a line mesh
  106122. * 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
  106123. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106124. * * The parameter `points` is an array successive Vector3
  106125. * * 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
  106126. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106127. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106128. * * When updating an instance, remember that only point positions can change, not the number of points
  106129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106131. * @param name defines the name of the new line system
  106132. * @param options defines the options used to create the line system
  106133. * @param scene defines the hosting scene
  106134. * @returns a new line mesh
  106135. */
  106136. static CreateLines(name: string, options: {
  106137. points: Vector3[];
  106138. updatable?: boolean;
  106139. instance?: Nullable<LinesMesh>;
  106140. colors?: Color4[];
  106141. useVertexAlpha?: boolean;
  106142. }, scene?: Nullable<Scene>): LinesMesh;
  106143. /**
  106144. * Creates a dashed line mesh
  106145. * * 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
  106146. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106147. * * The parameter `points` is an array successive Vector3
  106148. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106149. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106150. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106151. * * 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
  106152. * * When updating an instance, remember that only point positions can change, not the number of points
  106153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106154. * @param name defines the name of the mesh
  106155. * @param options defines the options used to create the mesh
  106156. * @param scene defines the hosting scene
  106157. * @returns the dashed line mesh
  106158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106159. */
  106160. static CreateDashedLines(name: string, options: {
  106161. points: Vector3[];
  106162. dashSize?: number;
  106163. gapSize?: number;
  106164. dashNb?: number;
  106165. updatable?: boolean;
  106166. instance?: LinesMesh;
  106167. }, scene?: Nullable<Scene>): LinesMesh;
  106168. /**
  106169. * 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.
  106170. * * 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.
  106171. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106172. * * 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.
  106173. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106174. * * 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
  106175. * * 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
  106176. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106178. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106179. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106181. * @param name defines the name of the mesh
  106182. * @param options defines the options used to create the mesh
  106183. * @param scene defines the hosting scene
  106184. * @returns the extruded shape mesh
  106185. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106187. */
  106188. static ExtrudeShape(name: string, options: {
  106189. shape: Vector3[];
  106190. path: Vector3[];
  106191. scale?: number;
  106192. rotation?: number;
  106193. cap?: number;
  106194. updatable?: boolean;
  106195. sideOrientation?: number;
  106196. frontUVs?: Vector4;
  106197. backUVs?: Vector4;
  106198. instance?: Mesh;
  106199. invertUV?: boolean;
  106200. }, scene?: Nullable<Scene>): Mesh;
  106201. /**
  106202. * Creates an custom extruded shape mesh.
  106203. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106204. * * 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.
  106205. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106206. * * 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
  106207. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106208. * * 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
  106209. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106210. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106211. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106212. * * 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
  106213. * * 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
  106214. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106219. * @param name defines the name of the mesh
  106220. * @param options defines the options used to create the mesh
  106221. * @param scene defines the hosting scene
  106222. * @returns the custom extruded shape mesh
  106223. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106224. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106226. */
  106227. static ExtrudeShapeCustom(name: string, options: {
  106228. shape: Vector3[];
  106229. path: Vector3[];
  106230. scaleFunction?: any;
  106231. rotationFunction?: any;
  106232. ribbonCloseArray?: boolean;
  106233. ribbonClosePath?: boolean;
  106234. cap?: number;
  106235. updatable?: boolean;
  106236. sideOrientation?: number;
  106237. frontUVs?: Vector4;
  106238. backUVs?: Vector4;
  106239. instance?: Mesh;
  106240. invertUV?: boolean;
  106241. }, scene: Scene): Mesh;
  106242. /**
  106243. * Creates lathe mesh.
  106244. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106245. * * 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
  106246. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106247. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106248. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106249. * * 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
  106250. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106251. * * 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
  106252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106256. * @param name defines the name of the mesh
  106257. * @param options defines the options used to create the mesh
  106258. * @param scene defines the hosting scene
  106259. * @returns the lathe mesh
  106260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106261. */
  106262. static CreateLathe(name: string, options: {
  106263. shape: Vector3[];
  106264. radius?: number;
  106265. tessellation?: number;
  106266. clip?: number;
  106267. arc?: number;
  106268. closed?: boolean;
  106269. updatable?: boolean;
  106270. sideOrientation?: number;
  106271. frontUVs?: Vector4;
  106272. backUVs?: Vector4;
  106273. cap?: number;
  106274. invertUV?: boolean;
  106275. }, scene: Scene): Mesh;
  106276. /**
  106277. * Creates a plane mesh
  106278. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  106279. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  106280. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  106281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106284. * @param name defines the name of the mesh
  106285. * @param options defines the options used to create the mesh
  106286. * @param scene defines the hosting scene
  106287. * @returns the plane mesh
  106288. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  106289. */
  106290. static CreatePlane(name: string, options: {
  106291. size?: number;
  106292. width?: number;
  106293. height?: number;
  106294. sideOrientation?: number;
  106295. frontUVs?: Vector4;
  106296. backUVs?: Vector4;
  106297. updatable?: boolean;
  106298. sourcePlane?: Plane;
  106299. }, scene: Scene): Mesh;
  106300. /**
  106301. * Creates a ground mesh
  106302. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106303. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106305. * @param name defines the name of the mesh
  106306. * @param options defines the options used to create the mesh
  106307. * @param scene defines the hosting scene
  106308. * @returns the ground mesh
  106309. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106310. */
  106311. static CreateGround(name: string, options: {
  106312. width?: number;
  106313. height?: number;
  106314. subdivisions?: number;
  106315. subdivisionsX?: number;
  106316. subdivisionsY?: number;
  106317. updatable?: boolean;
  106318. }, scene: any): Mesh;
  106319. /**
  106320. * Creates a tiled ground mesh
  106321. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106322. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106323. * * 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
  106324. * * 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
  106325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106326. * @param name defines the name of the mesh
  106327. * @param options defines the options used to create the mesh
  106328. * @param scene defines the hosting scene
  106329. * @returns the tiled ground mesh
  106330. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106331. */
  106332. static CreateTiledGround(name: string, options: {
  106333. xmin: number;
  106334. zmin: number;
  106335. xmax: number;
  106336. zmax: number;
  106337. subdivisions?: {
  106338. w: number;
  106339. h: number;
  106340. };
  106341. precision?: {
  106342. w: number;
  106343. h: number;
  106344. };
  106345. updatable?: boolean;
  106346. }, scene: Scene): Mesh;
  106347. /**
  106348. * Creates a ground mesh from a height map
  106349. * * The parameter `url` sets the URL of the height map image resource.
  106350. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106351. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106352. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106353. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106354. * * 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.
  106355. * * 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).
  106356. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106358. * @param name defines the name of the mesh
  106359. * @param url defines the url to the height map
  106360. * @param options defines the options used to create the mesh
  106361. * @param scene defines the hosting scene
  106362. * @returns the ground mesh
  106363. * @see https://doc.babylonjs.com/babylon101/height_map
  106364. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106365. */
  106366. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106367. width?: number;
  106368. height?: number;
  106369. subdivisions?: number;
  106370. minHeight?: number;
  106371. maxHeight?: number;
  106372. colorFilter?: Color3;
  106373. alphaFilter?: number;
  106374. updatable?: boolean;
  106375. onReady?: (mesh: GroundMesh) => void;
  106376. }, scene: Scene): GroundMesh;
  106377. /**
  106378. * Creates a polygon mesh
  106379. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106380. * * 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
  106381. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106384. * * Remember you can only change the shape positions, not their number when updating a polygon
  106385. * @param name defines the name of the mesh
  106386. * @param options defines the options used to create the mesh
  106387. * @param scene defines the hosting scene
  106388. * @param earcutInjection can be used to inject your own earcut reference
  106389. * @returns the polygon mesh
  106390. */
  106391. static CreatePolygon(name: string, options: {
  106392. shape: Vector3[];
  106393. holes?: Vector3[][];
  106394. depth?: number;
  106395. faceUV?: Vector4[];
  106396. faceColors?: Color4[];
  106397. updatable?: boolean;
  106398. sideOrientation?: number;
  106399. frontUVs?: Vector4;
  106400. backUVs?: Vector4;
  106401. }, scene: Scene, earcutInjection?: any): Mesh;
  106402. /**
  106403. * Creates an extruded polygon mesh, with depth in the Y direction.
  106404. * * 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)
  106405. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106406. * @param name defines the name of the mesh
  106407. * @param options defines the options used to create the mesh
  106408. * @param scene defines the hosting scene
  106409. * @param earcutInjection can be used to inject your own earcut reference
  106410. * @returns the polygon mesh
  106411. */
  106412. static ExtrudePolygon(name: string, options: {
  106413. shape: Vector3[];
  106414. holes?: Vector3[][];
  106415. depth?: number;
  106416. faceUV?: Vector4[];
  106417. faceColors?: Color4[];
  106418. updatable?: boolean;
  106419. sideOrientation?: number;
  106420. frontUVs?: Vector4;
  106421. backUVs?: Vector4;
  106422. }, scene: Scene, earcutInjection?: any): Mesh;
  106423. /**
  106424. * Creates a tube mesh.
  106425. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106426. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106427. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106428. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106429. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106430. * * 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)
  106431. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106432. * * 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
  106433. * * 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
  106434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106436. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106438. * @param name defines the name of the mesh
  106439. * @param options defines the options used to create the mesh
  106440. * @param scene defines the hosting scene
  106441. * @returns the tube mesh
  106442. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106443. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106444. */
  106445. static CreateTube(name: string, options: {
  106446. path: Vector3[];
  106447. radius?: number;
  106448. tessellation?: number;
  106449. radiusFunction?: {
  106450. (i: number, distance: number): number;
  106451. };
  106452. cap?: number;
  106453. arc?: number;
  106454. updatable?: boolean;
  106455. sideOrientation?: number;
  106456. frontUVs?: Vector4;
  106457. backUVs?: Vector4;
  106458. instance?: Mesh;
  106459. invertUV?: boolean;
  106460. }, scene: Scene): Mesh;
  106461. /**
  106462. * Creates a polyhedron mesh
  106463. * * 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
  106464. * * The parameter `size` (positive float, default 1) sets the polygon size
  106465. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106466. * * 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`
  106467. * * 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
  106468. * * 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)`)
  106469. * * 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
  106470. * * 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
  106471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106474. * @param name defines the name of the mesh
  106475. * @param options defines the options used to create the mesh
  106476. * @param scene defines the hosting scene
  106477. * @returns the polyhedron mesh
  106478. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  106479. */
  106480. static CreatePolyhedron(name: string, options: {
  106481. type?: number;
  106482. size?: number;
  106483. sizeX?: number;
  106484. sizeY?: number;
  106485. sizeZ?: number;
  106486. custom?: any;
  106487. faceUV?: Vector4[];
  106488. faceColors?: Color4[];
  106489. flat?: boolean;
  106490. updatable?: boolean;
  106491. sideOrientation?: number;
  106492. frontUVs?: Vector4;
  106493. backUVs?: Vector4;
  106494. }, scene: Scene): Mesh;
  106495. /**
  106496. * Creates a decal mesh.
  106497. * 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
  106498. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  106499. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  106500. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  106501. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  106502. * @param name defines the name of the mesh
  106503. * @param sourceMesh defines the mesh where the decal must be applied
  106504. * @param options defines the options used to create the mesh
  106505. * @param scene defines the hosting scene
  106506. * @returns the decal mesh
  106507. * @see https://doc.babylonjs.com/how_to/decals
  106508. */
  106509. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  106510. position?: Vector3;
  106511. normal?: Vector3;
  106512. size?: Vector3;
  106513. angle?: number;
  106514. }): Mesh;
  106515. }
  106516. }
  106517. declare module BABYLON {
  106518. /**
  106519. * A simplifier interface for future simplification implementations
  106520. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106521. */
  106522. export interface ISimplifier {
  106523. /**
  106524. * Simplification of a given mesh according to the given settings.
  106525. * Since this requires computation, it is assumed that the function runs async.
  106526. * @param settings The settings of the simplification, including quality and distance
  106527. * @param successCallback A callback that will be called after the mesh was simplified.
  106528. * @param errorCallback in case of an error, this callback will be called. optional.
  106529. */
  106530. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  106531. }
  106532. /**
  106533. * Expected simplification settings.
  106534. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  106535. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106536. */
  106537. export interface ISimplificationSettings {
  106538. /**
  106539. * Gets or sets the expected quality
  106540. */
  106541. quality: number;
  106542. /**
  106543. * Gets or sets the distance when this optimized version should be used
  106544. */
  106545. distance: number;
  106546. /**
  106547. * Gets an already optimized mesh
  106548. */
  106549. optimizeMesh?: boolean;
  106550. }
  106551. /**
  106552. * Class used to specify simplification options
  106553. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106554. */
  106555. export class SimplificationSettings implements ISimplificationSettings {
  106556. /** expected quality */
  106557. quality: number;
  106558. /** distance when this optimized version should be used */
  106559. distance: number;
  106560. /** already optimized mesh */
  106561. optimizeMesh?: boolean | undefined;
  106562. /**
  106563. * Creates a SimplificationSettings
  106564. * @param quality expected quality
  106565. * @param distance distance when this optimized version should be used
  106566. * @param optimizeMesh already optimized mesh
  106567. */
  106568. constructor(
  106569. /** expected quality */
  106570. quality: number,
  106571. /** distance when this optimized version should be used */
  106572. distance: number,
  106573. /** already optimized mesh */
  106574. optimizeMesh?: boolean | undefined);
  106575. }
  106576. /**
  106577. * Interface used to define a simplification task
  106578. */
  106579. export interface ISimplificationTask {
  106580. /**
  106581. * Array of settings
  106582. */
  106583. settings: Array<ISimplificationSettings>;
  106584. /**
  106585. * Simplification type
  106586. */
  106587. simplificationType: SimplificationType;
  106588. /**
  106589. * Mesh to simplify
  106590. */
  106591. mesh: Mesh;
  106592. /**
  106593. * Callback called on success
  106594. */
  106595. successCallback?: () => void;
  106596. /**
  106597. * Defines if parallel processing can be used
  106598. */
  106599. parallelProcessing: boolean;
  106600. }
  106601. /**
  106602. * Queue used to order the simplification tasks
  106603. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106604. */
  106605. export class SimplificationQueue {
  106606. private _simplificationArray;
  106607. /**
  106608. * Gets a boolean indicating that the process is still running
  106609. */
  106610. running: boolean;
  106611. /**
  106612. * Creates a new queue
  106613. */
  106614. constructor();
  106615. /**
  106616. * Adds a new simplification task
  106617. * @param task defines a task to add
  106618. */
  106619. addTask(task: ISimplificationTask): void;
  106620. /**
  106621. * Execute next task
  106622. */
  106623. executeNext(): void;
  106624. /**
  106625. * Execute a simplification task
  106626. * @param task defines the task to run
  106627. */
  106628. runSimplification(task: ISimplificationTask): void;
  106629. private getSimplifier;
  106630. }
  106631. /**
  106632. * The implemented types of simplification
  106633. * At the moment only Quadratic Error Decimation is implemented
  106634. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106635. */
  106636. export enum SimplificationType {
  106637. /** Quadratic error decimation */
  106638. QUADRATIC = 0
  106639. }
  106640. }
  106641. declare module BABYLON {
  106642. interface Scene {
  106643. /** @hidden (Backing field) */
  106644. _simplificationQueue: SimplificationQueue;
  106645. /**
  106646. * Gets or sets the simplification queue attached to the scene
  106647. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  106648. */
  106649. simplificationQueue: SimplificationQueue;
  106650. }
  106651. interface Mesh {
  106652. /**
  106653. * Simplify the mesh according to the given array of settings.
  106654. * Function will return immediately and will simplify async
  106655. * @param settings a collection of simplification settings
  106656. * @param parallelProcessing should all levels calculate parallel or one after the other
  106657. * @param simplificationType the type of simplification to run
  106658. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  106659. * @returns the current mesh
  106660. */
  106661. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  106662. }
  106663. /**
  106664. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  106665. * created in a scene
  106666. */
  106667. export class SimplicationQueueSceneComponent implements ISceneComponent {
  106668. /**
  106669. * The component name helpfull to identify the component in the list of scene components.
  106670. */
  106671. readonly name: string;
  106672. /**
  106673. * The scene the component belongs to.
  106674. */
  106675. scene: Scene;
  106676. /**
  106677. * Creates a new instance of the component for the given scene
  106678. * @param scene Defines the scene to register the component in
  106679. */
  106680. constructor(scene: Scene);
  106681. /**
  106682. * Registers the component in a given scene
  106683. */
  106684. register(): void;
  106685. /**
  106686. * Rebuilds the elements related to this component in case of
  106687. * context lost for instance.
  106688. */
  106689. rebuild(): void;
  106690. /**
  106691. * Disposes the component and the associated ressources
  106692. */
  106693. dispose(): void;
  106694. private _beforeCameraUpdate;
  106695. }
  106696. }
  106697. declare module BABYLON {
  106698. /**
  106699. * Class used to enable access to IndexedDB
  106700. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106701. */
  106702. export class Database implements IOfflineProvider {
  106703. private _callbackManifestChecked;
  106704. private _currentSceneUrl;
  106705. private _db;
  106706. private _enableSceneOffline;
  106707. private _enableTexturesOffline;
  106708. private _manifestVersionFound;
  106709. private _mustUpdateRessources;
  106710. private _hasReachedQuota;
  106711. private _isSupported;
  106712. private _idbFactory;
  106713. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106714. private static IsUASupportingBlobStorage;
  106715. /**
  106716. * Gets a boolean indicating if Database storate is enabled (off by default)
  106717. */
  106718. static IDBStorageEnabled: boolean;
  106719. /**
  106720. * Gets a boolean indicating if scene must be saved in the database
  106721. */
  106722. readonly enableSceneOffline: boolean;
  106723. /**
  106724. * Gets a boolean indicating if textures must be saved in the database
  106725. */
  106726. readonly enableTexturesOffline: boolean;
  106727. /**
  106728. * Creates a new Database
  106729. * @param urlToScene defines the url to load the scene
  106730. * @param callbackManifestChecked defines the callback to use when manifest is checked
  106731. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  106732. */
  106733. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  106734. private static _ParseURL;
  106735. private static _ReturnFullUrlLocation;
  106736. private _checkManifestFile;
  106737. /**
  106738. * Open the database and make it available
  106739. * @param successCallback defines the callback to call on success
  106740. * @param errorCallback defines the callback to call on error
  106741. */
  106742. open(successCallback: () => void, errorCallback: () => void): void;
  106743. /**
  106744. * Loads an image from the database
  106745. * @param url defines the url to load from
  106746. * @param image defines the target DOM image
  106747. */
  106748. loadImage(url: string, image: HTMLImageElement): void;
  106749. private _loadImageFromDBAsync;
  106750. private _saveImageIntoDBAsync;
  106751. private _checkVersionFromDB;
  106752. private _loadVersionFromDBAsync;
  106753. private _saveVersionIntoDBAsync;
  106754. /**
  106755. * Loads a file from database
  106756. * @param url defines the URL to load from
  106757. * @param sceneLoaded defines a callback to call on success
  106758. * @param progressCallBack defines a callback to call when progress changed
  106759. * @param errorCallback defines a callback to call on error
  106760. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106761. */
  106762. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  106763. private _loadFileAsync;
  106764. private _saveFileAsync;
  106765. /**
  106766. * Validates if xhr data is correct
  106767. * @param xhr defines the request to validate
  106768. * @param dataType defines the expected data type
  106769. * @returns true if data is correct
  106770. */
  106771. private static _ValidateXHRData;
  106772. }
  106773. }
  106774. declare module BABYLON {
  106775. /** @hidden */
  106776. export var gpuUpdateParticlesPixelShader: {
  106777. name: string;
  106778. shader: string;
  106779. };
  106780. }
  106781. declare module BABYLON {
  106782. /** @hidden */
  106783. export var gpuUpdateParticlesVertexShader: {
  106784. name: string;
  106785. shader: string;
  106786. };
  106787. }
  106788. declare module BABYLON {
  106789. /** @hidden */
  106790. export var clipPlaneFragmentDeclaration2: {
  106791. name: string;
  106792. shader: string;
  106793. };
  106794. }
  106795. declare module BABYLON {
  106796. /** @hidden */
  106797. export var gpuRenderParticlesPixelShader: {
  106798. name: string;
  106799. shader: string;
  106800. };
  106801. }
  106802. declare module BABYLON {
  106803. /** @hidden */
  106804. export var clipPlaneVertexDeclaration2: {
  106805. name: string;
  106806. shader: string;
  106807. };
  106808. }
  106809. declare module BABYLON {
  106810. /** @hidden */
  106811. export var gpuRenderParticlesVertexShader: {
  106812. name: string;
  106813. shader: string;
  106814. };
  106815. }
  106816. declare module BABYLON {
  106817. /**
  106818. * This represents a GPU particle system in Babylon
  106819. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  106820. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  106821. */
  106822. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  106823. /**
  106824. * The layer mask we are rendering the particles through.
  106825. */
  106826. layerMask: number;
  106827. private _capacity;
  106828. private _activeCount;
  106829. private _currentActiveCount;
  106830. private _accumulatedCount;
  106831. private _renderEffect;
  106832. private _updateEffect;
  106833. private _buffer0;
  106834. private _buffer1;
  106835. private _spriteBuffer;
  106836. private _updateVAO;
  106837. private _renderVAO;
  106838. private _targetIndex;
  106839. private _sourceBuffer;
  106840. private _targetBuffer;
  106841. private _engine;
  106842. private _currentRenderId;
  106843. private _started;
  106844. private _stopped;
  106845. private _timeDelta;
  106846. private _randomTexture;
  106847. private _randomTexture2;
  106848. private _attributesStrideSize;
  106849. private _updateEffectOptions;
  106850. private _randomTextureSize;
  106851. private _actualFrame;
  106852. private readonly _rawTextureWidth;
  106853. /**
  106854. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  106855. */
  106856. static readonly IsSupported: boolean;
  106857. /**
  106858. * An event triggered when the system is disposed.
  106859. */
  106860. onDisposeObservable: Observable<GPUParticleSystem>;
  106861. /**
  106862. * Gets the maximum number of particles active at the same time.
  106863. * @returns The max number of active particles.
  106864. */
  106865. getCapacity(): number;
  106866. /**
  106867. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  106868. * to override the particles.
  106869. */
  106870. forceDepthWrite: boolean;
  106871. /**
  106872. * Gets or set the number of active particles
  106873. */
  106874. activeParticleCount: number;
  106875. private _preWarmDone;
  106876. /**
  106877. * Is this system ready to be used/rendered
  106878. * @return true if the system is ready
  106879. */
  106880. isReady(): boolean;
  106881. /**
  106882. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106883. * @returns True if it has been started, otherwise false.
  106884. */
  106885. isStarted(): boolean;
  106886. /**
  106887. * Starts the particle system and begins to emit
  106888. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106889. */
  106890. start(delay?: number): void;
  106891. /**
  106892. * Stops the particle system.
  106893. */
  106894. stop(): void;
  106895. /**
  106896. * Remove all active particles
  106897. */
  106898. reset(): void;
  106899. /**
  106900. * Returns the string "GPUParticleSystem"
  106901. * @returns a string containing the class name
  106902. */
  106903. getClassName(): string;
  106904. private _colorGradientsTexture;
  106905. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  106906. /**
  106907. * Adds a new color gradient
  106908. * @param gradient defines the gradient to use (between 0 and 1)
  106909. * @param color1 defines the color to affect to the specified gradient
  106910. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106911. * @returns the current particle system
  106912. */
  106913. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  106914. /**
  106915. * Remove a specific color gradient
  106916. * @param gradient defines the gradient to remove
  106917. * @returns the current particle system
  106918. */
  106919. removeColorGradient(gradient: number): GPUParticleSystem;
  106920. private _angularSpeedGradientsTexture;
  106921. private _sizeGradientsTexture;
  106922. private _velocityGradientsTexture;
  106923. private _limitVelocityGradientsTexture;
  106924. private _dragGradientsTexture;
  106925. private _addFactorGradient;
  106926. /**
  106927. * Adds a new size gradient
  106928. * @param gradient defines the gradient to use (between 0 and 1)
  106929. * @param factor defines the size factor to affect to the specified gradient
  106930. * @returns the current particle system
  106931. */
  106932. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  106933. /**
  106934. * Remove a specific size gradient
  106935. * @param gradient defines the gradient to remove
  106936. * @returns the current particle system
  106937. */
  106938. removeSizeGradient(gradient: number): GPUParticleSystem;
  106939. /**
  106940. * Adds a new angular speed gradient
  106941. * @param gradient defines the gradient to use (between 0 and 1)
  106942. * @param factor defines the angular speed to affect to the specified gradient
  106943. * @returns the current particle system
  106944. */
  106945. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  106946. /**
  106947. * Remove a specific angular speed gradient
  106948. * @param gradient defines the gradient to remove
  106949. * @returns the current particle system
  106950. */
  106951. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  106952. /**
  106953. * Adds a new velocity gradient
  106954. * @param gradient defines the gradient to use (between 0 and 1)
  106955. * @param factor defines the velocity to affect to the specified gradient
  106956. * @returns the current particle system
  106957. */
  106958. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106959. /**
  106960. * Remove a specific velocity gradient
  106961. * @param gradient defines the gradient to remove
  106962. * @returns the current particle system
  106963. */
  106964. removeVelocityGradient(gradient: number): GPUParticleSystem;
  106965. /**
  106966. * Adds a new limit velocity gradient
  106967. * @param gradient defines the gradient to use (between 0 and 1)
  106968. * @param factor defines the limit velocity value to affect to the specified gradient
  106969. * @returns the current particle system
  106970. */
  106971. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  106972. /**
  106973. * Remove a specific limit velocity gradient
  106974. * @param gradient defines the gradient to remove
  106975. * @returns the current particle system
  106976. */
  106977. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  106978. /**
  106979. * Adds a new drag gradient
  106980. * @param gradient defines the gradient to use (between 0 and 1)
  106981. * @param factor defines the drag value to affect to the specified gradient
  106982. * @returns the current particle system
  106983. */
  106984. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  106985. /**
  106986. * Remove a specific drag gradient
  106987. * @param gradient defines the gradient to remove
  106988. * @returns the current particle system
  106989. */
  106990. removeDragGradient(gradient: number): GPUParticleSystem;
  106991. /**
  106992. * Not supported by GPUParticleSystem
  106993. * @param gradient defines the gradient to use (between 0 and 1)
  106994. * @param factor defines the emit rate value to affect to the specified gradient
  106995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106996. * @returns the current particle system
  106997. */
  106998. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  106999. /**
  107000. * Not supported by GPUParticleSystem
  107001. * @param gradient defines the gradient to remove
  107002. * @returns the current particle system
  107003. */
  107004. removeEmitRateGradient(gradient: number): IParticleSystem;
  107005. /**
  107006. * Not supported by GPUParticleSystem
  107007. * @param gradient defines the gradient to use (between 0 and 1)
  107008. * @param factor defines the start size value to affect to the specified gradient
  107009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107010. * @returns the current particle system
  107011. */
  107012. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107013. /**
  107014. * Not supported by GPUParticleSystem
  107015. * @param gradient defines the gradient to remove
  107016. * @returns the current particle system
  107017. */
  107018. removeStartSizeGradient(gradient: number): IParticleSystem;
  107019. /**
  107020. * Not supported by GPUParticleSystem
  107021. * @param gradient defines the gradient to use (between 0 and 1)
  107022. * @param min defines the color remap minimal range
  107023. * @param max defines the color remap maximal range
  107024. * @returns the current particle system
  107025. */
  107026. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107027. /**
  107028. * Not supported by GPUParticleSystem
  107029. * @param gradient defines the gradient to remove
  107030. * @returns the current particle system
  107031. */
  107032. removeColorRemapGradient(): IParticleSystem;
  107033. /**
  107034. * Not supported by GPUParticleSystem
  107035. * @param gradient defines the gradient to use (between 0 and 1)
  107036. * @param min defines the alpha remap minimal range
  107037. * @param max defines the alpha remap maximal range
  107038. * @returns the current particle system
  107039. */
  107040. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  107041. /**
  107042. * Not supported by GPUParticleSystem
  107043. * @param gradient defines the gradient to remove
  107044. * @returns the current particle system
  107045. */
  107046. removeAlphaRemapGradient(): IParticleSystem;
  107047. /**
  107048. * Not supported by GPUParticleSystem
  107049. * @param gradient defines the gradient to use (between 0 and 1)
  107050. * @param color defines the color to affect to the specified gradient
  107051. * @returns the current particle system
  107052. */
  107053. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  107054. /**
  107055. * Not supported by GPUParticleSystem
  107056. * @param gradient defines the gradient to remove
  107057. * @returns the current particle system
  107058. */
  107059. removeRampGradient(): IParticleSystem;
  107060. /**
  107061. * Not supported by GPUParticleSystem
  107062. * @returns the list of ramp gradients
  107063. */
  107064. getRampGradients(): Nullable<Array<Color3Gradient>>;
  107065. /**
  107066. * Not supported by GPUParticleSystem
  107067. * Gets or sets a boolean indicating that ramp gradients must be used
  107068. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  107069. */
  107070. useRampGradients: boolean;
  107071. /**
  107072. * Not supported by GPUParticleSystem
  107073. * @param gradient defines the gradient to use (between 0 and 1)
  107074. * @param factor defines the life time factor to affect to the specified gradient
  107075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  107076. * @returns the current particle system
  107077. */
  107078. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  107079. /**
  107080. * Not supported by GPUParticleSystem
  107081. * @param gradient defines the gradient to remove
  107082. * @returns the current particle system
  107083. */
  107084. removeLifeTimeGradient(gradient: number): IParticleSystem;
  107085. /**
  107086. * Instantiates a GPU particle system.
  107087. * 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.
  107088. * @param name The name of the particle system
  107089. * @param options The options used to create the system
  107090. * @param scene The scene the particle system belongs to
  107091. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  107092. */
  107093. constructor(name: string, options: Partial<{
  107094. capacity: number;
  107095. randomTextureSize: number;
  107096. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  107097. protected _reset(): void;
  107098. private _createUpdateVAO;
  107099. private _createRenderVAO;
  107100. private _initialize;
  107101. /** @hidden */
  107102. _recreateUpdateEffect(): void;
  107103. /** @hidden */
  107104. _recreateRenderEffect(): void;
  107105. /**
  107106. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107107. * @param preWarm defines if we are in the pre-warmimg phase
  107108. */
  107109. animate(preWarm?: boolean): void;
  107110. private _createFactorGradientTexture;
  107111. private _createSizeGradientTexture;
  107112. private _createAngularSpeedGradientTexture;
  107113. private _createVelocityGradientTexture;
  107114. private _createLimitVelocityGradientTexture;
  107115. private _createDragGradientTexture;
  107116. private _createColorGradientTexture;
  107117. /**
  107118. * Renders the particle system in its current state
  107119. * @param preWarm defines if the system should only update the particles but not render them
  107120. * @returns the current number of particles
  107121. */
  107122. render(preWarm?: boolean): number;
  107123. /**
  107124. * Rebuilds the particle system
  107125. */
  107126. rebuild(): void;
  107127. private _releaseBuffers;
  107128. private _releaseVAOs;
  107129. /**
  107130. * Disposes the particle system and free the associated resources
  107131. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107132. */
  107133. dispose(disposeTexture?: boolean): void;
  107134. /**
  107135. * Clones the particle system.
  107136. * @param name The name of the cloned object
  107137. * @param newEmitter The new emitter to use
  107138. * @returns the cloned particle system
  107139. */
  107140. clone(name: string, newEmitter: any): GPUParticleSystem;
  107141. /**
  107142. * Serializes the particle system to a JSON object.
  107143. * @returns the JSON object
  107144. */
  107145. serialize(): any;
  107146. /**
  107147. * Parses a JSON object to create a GPU particle system.
  107148. * @param parsedParticleSystem The JSON object to parse
  107149. * @param scene The scene to create the particle system in
  107150. * @param rootUrl The root url to use to load external dependencies like texture
  107151. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107152. * @returns the parsed GPU particle system
  107153. */
  107154. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  107155. }
  107156. }
  107157. declare module BABYLON {
  107158. /**
  107159. * Represents a set of particle systems working together to create a specific effect
  107160. */
  107161. export class ParticleSystemSet implements IDisposable {
  107162. private _emitterCreationOptions;
  107163. private _emitterNode;
  107164. /**
  107165. * Gets the particle system list
  107166. */
  107167. systems: IParticleSystem[];
  107168. /**
  107169. * Gets the emitter node used with this set
  107170. */
  107171. readonly emitterNode: Nullable<TransformNode>;
  107172. /**
  107173. * Creates a new emitter mesh as a sphere
  107174. * @param options defines the options used to create the sphere
  107175. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  107176. * @param scene defines the hosting scene
  107177. */
  107178. setEmitterAsSphere(options: {
  107179. diameter: number;
  107180. segments: number;
  107181. color: Color3;
  107182. }, renderingGroupId: number, scene: Scene): void;
  107183. /**
  107184. * Starts all particle systems of the set
  107185. * @param emitter defines an optional mesh to use as emitter for the particle systems
  107186. */
  107187. start(emitter?: AbstractMesh): void;
  107188. /**
  107189. * Release all associated resources
  107190. */
  107191. dispose(): void;
  107192. /**
  107193. * Serialize the set into a JSON compatible object
  107194. * @returns a JSON compatible representation of the set
  107195. */
  107196. serialize(): any;
  107197. /**
  107198. * Parse a new ParticleSystemSet from a serialized source
  107199. * @param data defines a JSON compatible representation of the set
  107200. * @param scene defines the hosting scene
  107201. * @param gpu defines if we want GPU particles or CPU particles
  107202. * @returns a new ParticleSystemSet
  107203. */
  107204. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  107205. }
  107206. }
  107207. declare module BABYLON {
  107208. /**
  107209. * This class is made for on one-liner static method to help creating particle system set.
  107210. */
  107211. export class ParticleHelper {
  107212. /**
  107213. * Gets or sets base Assets URL
  107214. */
  107215. static BaseAssetsUrl: string;
  107216. /**
  107217. * Create a default particle system that you can tweak
  107218. * @param emitter defines the emitter to use
  107219. * @param capacity defines the system capacity (default is 500 particles)
  107220. * @param scene defines the hosting scene
  107221. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  107222. * @returns the new Particle system
  107223. */
  107224. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  107225. /**
  107226. * This is the main static method (one-liner) of this helper to create different particle systems
  107227. * @param type This string represents the type to the particle system to create
  107228. * @param scene The scene where the particle system should live
  107229. * @param gpu If the system will use gpu
  107230. * @returns the ParticleSystemSet created
  107231. */
  107232. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  107233. /**
  107234. * Static function used to export a particle system to a ParticleSystemSet variable.
  107235. * Please note that the emitter shape is not exported
  107236. * @param systems defines the particle systems to export
  107237. * @returns the created particle system set
  107238. */
  107239. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  107240. }
  107241. }
  107242. declare module BABYLON {
  107243. interface Engine {
  107244. /**
  107245. * Create an effect to use with particle systems.
  107246. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  107247. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  107248. * @param uniformsNames defines a list of attribute names
  107249. * @param samplers defines an array of string used to represent textures
  107250. * @param defines defines the string containing the defines to use to compile the shaders
  107251. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  107252. * @param onCompiled defines a function to call when the effect creation is successful
  107253. * @param onError defines a function to call when the effect creation has failed
  107254. * @returns the new Effect
  107255. */
  107256. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  107257. }
  107258. interface Mesh {
  107259. /**
  107260. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  107261. * @returns an array of IParticleSystem
  107262. */
  107263. getEmittedParticleSystems(): IParticleSystem[];
  107264. /**
  107265. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  107266. * @returns an array of IParticleSystem
  107267. */
  107268. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  107269. }
  107270. /**
  107271. * @hidden
  107272. */
  107273. export var _IDoNeedToBeInTheBuild: number;
  107274. }
  107275. declare module BABYLON {
  107276. interface Scene {
  107277. /** @hidden (Backing field) */
  107278. _physicsEngine: Nullable<IPhysicsEngine>;
  107279. /**
  107280. * Gets the current physics engine
  107281. * @returns a IPhysicsEngine or null if none attached
  107282. */
  107283. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  107284. /**
  107285. * Enables physics to the current scene
  107286. * @param gravity defines the scene's gravity for the physics engine
  107287. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  107288. * @return a boolean indicating if the physics engine was initialized
  107289. */
  107290. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  107291. /**
  107292. * Disables and disposes the physics engine associated with the scene
  107293. */
  107294. disablePhysicsEngine(): void;
  107295. /**
  107296. * Gets a boolean indicating if there is an active physics engine
  107297. * @returns a boolean indicating if there is an active physics engine
  107298. */
  107299. isPhysicsEnabled(): boolean;
  107300. /**
  107301. * Deletes a physics compound impostor
  107302. * @param compound defines the compound to delete
  107303. */
  107304. deleteCompoundImpostor(compound: any): void;
  107305. /**
  107306. * An event triggered when physic simulation is about to be run
  107307. */
  107308. onBeforePhysicsObservable: Observable<Scene>;
  107309. /**
  107310. * An event triggered when physic simulation has been done
  107311. */
  107312. onAfterPhysicsObservable: Observable<Scene>;
  107313. }
  107314. interface AbstractMesh {
  107315. /** @hidden */
  107316. _physicsImpostor: Nullable<PhysicsImpostor>;
  107317. /**
  107318. * Gets or sets impostor used for physic simulation
  107319. * @see http://doc.babylonjs.com/features/physics_engine
  107320. */
  107321. physicsImpostor: Nullable<PhysicsImpostor>;
  107322. /**
  107323. * Gets the current physics impostor
  107324. * @see http://doc.babylonjs.com/features/physics_engine
  107325. * @returns a physics impostor or null
  107326. */
  107327. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  107328. /** Apply a physic impulse to the mesh
  107329. * @param force defines the force to apply
  107330. * @param contactPoint defines where to apply the force
  107331. * @returns the current mesh
  107332. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107333. */
  107334. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  107335. /**
  107336. * Creates a physic joint between two meshes
  107337. * @param otherMesh defines the other mesh to use
  107338. * @param pivot1 defines the pivot to use on this mesh
  107339. * @param pivot2 defines the pivot to use on the other mesh
  107340. * @param options defines additional options (can be plugin dependent)
  107341. * @returns the current mesh
  107342. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  107343. */
  107344. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  107345. /** @hidden */
  107346. _disposePhysicsObserver: Nullable<Observer<Node>>;
  107347. }
  107348. /**
  107349. * Defines the physics engine scene component responsible to manage a physics engine
  107350. */
  107351. export class PhysicsEngineSceneComponent implements ISceneComponent {
  107352. /**
  107353. * The component name helpful to identify the component in the list of scene components.
  107354. */
  107355. readonly name: string;
  107356. /**
  107357. * The scene the component belongs to.
  107358. */
  107359. scene: Scene;
  107360. /**
  107361. * Creates a new instance of the component for the given scene
  107362. * @param scene Defines the scene to register the component in
  107363. */
  107364. constructor(scene: Scene);
  107365. /**
  107366. * Registers the component in a given scene
  107367. */
  107368. register(): void;
  107369. /**
  107370. * Rebuilds the elements related to this component in case of
  107371. * context lost for instance.
  107372. */
  107373. rebuild(): void;
  107374. /**
  107375. * Disposes the component and the associated ressources
  107376. */
  107377. dispose(): void;
  107378. }
  107379. }
  107380. declare module BABYLON {
  107381. /**
  107382. * A helper for physics simulations
  107383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107384. */
  107385. export class PhysicsHelper {
  107386. private _scene;
  107387. private _physicsEngine;
  107388. /**
  107389. * Initializes the Physics helper
  107390. * @param scene Babylon.js scene
  107391. */
  107392. constructor(scene: Scene);
  107393. /**
  107394. * Applies a radial explosion impulse
  107395. * @param origin the origin of the explosion
  107396. * @param radius the explosion radius
  107397. * @param strength the explosion strength
  107398. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107399. * @returns A physics radial explosion event, or null
  107400. */
  107401. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107402. /**
  107403. * Applies a radial explosion force
  107404. * @param origin the origin of the explosion
  107405. * @param radius the explosion radius
  107406. * @param strength the explosion strength
  107407. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107408. * @returns A physics radial explosion event, or null
  107409. */
  107410. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  107411. /**
  107412. * Creates a gravitational field
  107413. * @param origin the origin of the explosion
  107414. * @param radius the explosion radius
  107415. * @param strength the explosion strength
  107416. * @param falloff possible options: Constant & Linear. Defaults to Constant
  107417. * @returns A physics gravitational field event, or null
  107418. */
  107419. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  107420. /**
  107421. * Creates a physics updraft event
  107422. * @param origin the origin of the updraft
  107423. * @param radius the radius of the updraft
  107424. * @param strength the strength of the updraft
  107425. * @param height the height of the updraft
  107426. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  107427. * @returns A physics updraft event, or null
  107428. */
  107429. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  107430. /**
  107431. * Creates a physics vortex event
  107432. * @param origin the of the vortex
  107433. * @param radius the radius of the vortex
  107434. * @param strength the strength of the vortex
  107435. * @param height the height of the vortex
  107436. * @returns a Physics vortex event, or null
  107437. * A physics vortex event or null
  107438. */
  107439. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  107440. }
  107441. /**
  107442. * Represents a physics radial explosion event
  107443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107444. */
  107445. export class PhysicsRadialExplosionEvent {
  107446. private _scene;
  107447. private _sphere;
  107448. private _sphereOptions;
  107449. private _rays;
  107450. private _dataFetched;
  107451. /**
  107452. * Initializes a radial explosioin event
  107453. * @param scene BabylonJS scene
  107454. */
  107455. constructor(scene: Scene);
  107456. /**
  107457. * Returns the data related to the radial explosion event (sphere & rays).
  107458. * @returns The radial explosion event data
  107459. */
  107460. getData(): PhysicsRadialExplosionEventData;
  107461. /**
  107462. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  107463. * @param impostor A physics imposter
  107464. * @param origin the origin of the explosion
  107465. * @param radius the explosion radius
  107466. * @param strength the explosion strength
  107467. * @param falloff possible options: Constant & Linear
  107468. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  107469. */
  107470. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  107471. /**
  107472. * Disposes the sphere.
  107473. * @param force Specifies if the sphere should be disposed by force
  107474. */
  107475. dispose(force?: boolean): void;
  107476. /*** Helpers ***/
  107477. private _prepareSphere;
  107478. private _intersectsWithSphere;
  107479. }
  107480. /**
  107481. * Represents a gravitational field event
  107482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107483. */
  107484. export class PhysicsGravitationalFieldEvent {
  107485. private _physicsHelper;
  107486. private _scene;
  107487. private _origin;
  107488. private _radius;
  107489. private _strength;
  107490. private _falloff;
  107491. private _tickCallback;
  107492. private _sphere;
  107493. private _dataFetched;
  107494. /**
  107495. * Initializes the physics gravitational field event
  107496. * @param physicsHelper A physics helper
  107497. * @param scene BabylonJS scene
  107498. * @param origin The origin position of the gravitational field event
  107499. * @param radius The radius of the gravitational field event
  107500. * @param strength The strength of the gravitational field event
  107501. * @param falloff The falloff for the gravitational field event
  107502. */
  107503. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  107504. /**
  107505. * Returns the data related to the gravitational field event (sphere).
  107506. * @returns A gravitational field event
  107507. */
  107508. getData(): PhysicsGravitationalFieldEventData;
  107509. /**
  107510. * Enables the gravitational field.
  107511. */
  107512. enable(): void;
  107513. /**
  107514. * Disables the gravitational field.
  107515. */
  107516. disable(): void;
  107517. /**
  107518. * Disposes the sphere.
  107519. * @param force The force to dispose from the gravitational field event
  107520. */
  107521. dispose(force?: boolean): void;
  107522. private _tick;
  107523. }
  107524. /**
  107525. * Represents a physics updraft event
  107526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107527. */
  107528. export class PhysicsUpdraftEvent {
  107529. private _scene;
  107530. private _origin;
  107531. private _radius;
  107532. private _strength;
  107533. private _height;
  107534. private _updraftMode;
  107535. private _physicsEngine;
  107536. private _originTop;
  107537. private _originDirection;
  107538. private _tickCallback;
  107539. private _cylinder;
  107540. private _cylinderPosition;
  107541. private _dataFetched;
  107542. /**
  107543. * Initializes the physics updraft event
  107544. * @param _scene BabylonJS scene
  107545. * @param _origin The origin position of the updraft
  107546. * @param _radius The radius of the updraft
  107547. * @param _strength The strength of the updraft
  107548. * @param _height The height of the updraft
  107549. * @param _updraftMode The mode of the updraft
  107550. */
  107551. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  107552. /**
  107553. * Returns the data related to the updraft event (cylinder).
  107554. * @returns A physics updraft event
  107555. */
  107556. getData(): PhysicsUpdraftEventData;
  107557. /**
  107558. * Enables the updraft.
  107559. */
  107560. enable(): void;
  107561. /**
  107562. * Disables the cortex.
  107563. */
  107564. disable(): void;
  107565. /**
  107566. * Disposes the sphere.
  107567. * @param force Specifies if the updraft should be disposed by force
  107568. */
  107569. dispose(force?: boolean): void;
  107570. private getImpostorForceAndContactPoint;
  107571. private _tick;
  107572. /*** Helpers ***/
  107573. private _prepareCylinder;
  107574. private _intersectsWithCylinder;
  107575. }
  107576. /**
  107577. * Represents a physics vortex event
  107578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107579. */
  107580. export class PhysicsVortexEvent {
  107581. private _scene;
  107582. private _origin;
  107583. private _radius;
  107584. private _strength;
  107585. private _height;
  107586. private _physicsEngine;
  107587. private _originTop;
  107588. private _centripetalForceThreshold;
  107589. private _updraftMultiplier;
  107590. private _tickCallback;
  107591. private _cylinder;
  107592. private _cylinderPosition;
  107593. private _dataFetched;
  107594. /**
  107595. * Initializes the physics vortex event
  107596. * @param _scene The BabylonJS scene
  107597. * @param _origin The origin position of the vortex
  107598. * @param _radius The radius of the vortex
  107599. * @param _strength The strength of the vortex
  107600. * @param _height The height of the vortex
  107601. */
  107602. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  107603. /**
  107604. * Returns the data related to the vortex event (cylinder).
  107605. * @returns The physics vortex event data
  107606. */
  107607. getData(): PhysicsVortexEventData;
  107608. /**
  107609. * Enables the vortex.
  107610. */
  107611. enable(): void;
  107612. /**
  107613. * Disables the cortex.
  107614. */
  107615. disable(): void;
  107616. /**
  107617. * Disposes the sphere.
  107618. * @param force
  107619. */
  107620. dispose(force?: boolean): void;
  107621. private getImpostorForceAndContactPoint;
  107622. private _tick;
  107623. /*** Helpers ***/
  107624. private _prepareCylinder;
  107625. private _intersectsWithCylinder;
  107626. }
  107627. /**
  107628. * The strenght of the force in correspondence to the distance of the affected object
  107629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107630. */
  107631. export enum PhysicsRadialImpulseFalloff {
  107632. /** Defines that impulse is constant in strength across it's whole radius */
  107633. Constant = 0,
  107634. /** DEfines that impulse gets weaker if it's further from the origin */
  107635. Linear = 1
  107636. }
  107637. /**
  107638. * The strength of the force in correspondence to the distance of the affected object
  107639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107640. */
  107641. export enum PhysicsUpdraftMode {
  107642. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  107643. Center = 0,
  107644. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  107645. Perpendicular = 1
  107646. }
  107647. /**
  107648. * Interface for a physics force and contact point
  107649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107650. */
  107651. export interface PhysicsForceAndContactPoint {
  107652. /**
  107653. * The force applied at the contact point
  107654. */
  107655. force: Vector3;
  107656. /**
  107657. * The contact point
  107658. */
  107659. contactPoint: Vector3;
  107660. }
  107661. /**
  107662. * Interface for radial explosion event data
  107663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107664. */
  107665. export interface PhysicsRadialExplosionEventData {
  107666. /**
  107667. * A sphere used for the radial explosion event
  107668. */
  107669. sphere: Mesh;
  107670. /**
  107671. * An array of rays for the radial explosion event
  107672. */
  107673. rays: Array<Ray>;
  107674. }
  107675. /**
  107676. * Interface for gravitational field event data
  107677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107678. */
  107679. export interface PhysicsGravitationalFieldEventData {
  107680. /**
  107681. * A sphere mesh used for the gravitational field event
  107682. */
  107683. sphere: Mesh;
  107684. }
  107685. /**
  107686. * Interface for updraft event data
  107687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107688. */
  107689. export interface PhysicsUpdraftEventData {
  107690. /**
  107691. * A cylinder used for the updraft event
  107692. */
  107693. cylinder: Mesh;
  107694. }
  107695. /**
  107696. * Interface for vortex event data
  107697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107698. */
  107699. export interface PhysicsVortexEventData {
  107700. /**
  107701. * A cylinder used for the vortex event
  107702. */
  107703. cylinder: Mesh;
  107704. }
  107705. }
  107706. declare module BABYLON {
  107707. /**
  107708. * AmmoJS Physics plugin
  107709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107710. * @see https://github.com/kripken/ammo.js/
  107711. */
  107712. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107713. private _useDeltaForWorldStep;
  107714. /**
  107715. * Reference to the Ammo library
  107716. */
  107717. bjsAMMO: any;
  107718. /**
  107719. * Created ammoJS world which physics bodies are added to
  107720. */
  107721. world: any;
  107722. /**
  107723. * Name of the plugin
  107724. */
  107725. name: string;
  107726. private _timeStep;
  107727. private _fixedTimeStep;
  107728. private _maxSteps;
  107729. private _tmpQuaternion;
  107730. private _tmpAmmoTransform;
  107731. private _tmpAmmoQuaternion;
  107732. private _tmpAmmoConcreteContactResultCallback;
  107733. private _collisionConfiguration;
  107734. private _dispatcher;
  107735. private _overlappingPairCache;
  107736. private _solver;
  107737. private _tmpAmmoVectorA;
  107738. private _tmpAmmoVectorB;
  107739. private _tmpAmmoVectorC;
  107740. private _tmpContactCallbackResult;
  107741. private static readonly DISABLE_COLLISION_FLAG;
  107742. private static readonly KINEMATIC_FLAG;
  107743. private static readonly DISABLE_DEACTIVATION_FLAG;
  107744. /**
  107745. * Initializes the ammoJS plugin
  107746. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107747. * @param ammoInjection can be used to inject your own ammo reference
  107748. */
  107749. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107750. /**
  107751. * Sets the gravity of the physics world (m/(s^2))
  107752. * @param gravity Gravity to set
  107753. */
  107754. setGravity(gravity: Vector3): void;
  107755. /**
  107756. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107757. * @param timeStep timestep to use in seconds
  107758. */
  107759. setTimeStep(timeStep: number): void;
  107760. /**
  107761. * 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)
  107762. * @param fixedTimeStep fixedTimeStep to use in seconds
  107763. */
  107764. setFixedTimeStep(fixedTimeStep: number): void;
  107765. /**
  107766. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107767. * @param maxSteps the maximum number of steps by the physics engine per frame
  107768. */
  107769. setMaxSteps(maxSteps: number): void;
  107770. /**
  107771. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107772. * @returns the current timestep in seconds
  107773. */
  107774. getTimeStep(): number;
  107775. private _isImpostorInContact;
  107776. private _isImpostorPairInContact;
  107777. private _stepSimulation;
  107778. /**
  107779. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107780. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107781. * After the step the babylon meshes are set to the position of the physics imposters
  107782. * @param delta amount of time to step forward
  107783. * @param impostors array of imposters to update before/after the step
  107784. */
  107785. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107786. private _tmpVector;
  107787. private _tmpMatrix;
  107788. /**
  107789. * Applies an implulse on the imposter
  107790. * @param impostor imposter to apply impulse
  107791. * @param force amount of force to be applied to the imposter
  107792. * @param contactPoint the location to apply the impulse on the imposter
  107793. */
  107794. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107795. /**
  107796. * Applies a force on the imposter
  107797. * @param impostor imposter to apply force
  107798. * @param force amount of force to be applied to the imposter
  107799. * @param contactPoint the location to apply the force on the imposter
  107800. */
  107801. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107802. /**
  107803. * Creates a physics body using the plugin
  107804. * @param impostor the imposter to create the physics body on
  107805. */
  107806. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107807. /**
  107808. * Removes the physics body from the imposter and disposes of the body's memory
  107809. * @param impostor imposter to remove the physics body from
  107810. */
  107811. removePhysicsBody(impostor: PhysicsImpostor): void;
  107812. /**
  107813. * Generates a joint
  107814. * @param impostorJoint the imposter joint to create the joint with
  107815. */
  107816. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107817. /**
  107818. * Removes a joint
  107819. * @param impostorJoint the imposter joint to remove the joint from
  107820. */
  107821. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107822. private _addMeshVerts;
  107823. private _createShape;
  107824. /**
  107825. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107826. * @param impostor imposter containing the physics body and babylon object
  107827. */
  107828. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107829. /**
  107830. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107831. * @param impostor imposter containing the physics body and babylon object
  107832. * @param newPosition new position
  107833. * @param newRotation new rotation
  107834. */
  107835. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107836. /**
  107837. * If this plugin is supported
  107838. * @returns true if its supported
  107839. */
  107840. isSupported(): boolean;
  107841. /**
  107842. * Sets the linear velocity of the physics body
  107843. * @param impostor imposter to set the velocity on
  107844. * @param velocity velocity to set
  107845. */
  107846. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107847. /**
  107848. * Sets the angular velocity of the physics body
  107849. * @param impostor imposter to set the velocity on
  107850. * @param velocity velocity to set
  107851. */
  107852. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107853. /**
  107854. * gets the linear velocity
  107855. * @param impostor imposter to get linear velocity from
  107856. * @returns linear velocity
  107857. */
  107858. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107859. /**
  107860. * gets the angular velocity
  107861. * @param impostor imposter to get angular velocity from
  107862. * @returns angular velocity
  107863. */
  107864. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107865. /**
  107866. * Sets the mass of physics body
  107867. * @param impostor imposter to set the mass on
  107868. * @param mass mass to set
  107869. */
  107870. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107871. /**
  107872. * Gets the mass of the physics body
  107873. * @param impostor imposter to get the mass from
  107874. * @returns mass
  107875. */
  107876. getBodyMass(impostor: PhysicsImpostor): number;
  107877. /**
  107878. * Gets friction of the impostor
  107879. * @param impostor impostor to get friction from
  107880. * @returns friction value
  107881. */
  107882. getBodyFriction(impostor: PhysicsImpostor): number;
  107883. /**
  107884. * Sets friction of the impostor
  107885. * @param impostor impostor to set friction on
  107886. * @param friction friction value
  107887. */
  107888. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107889. /**
  107890. * Gets restitution of the impostor
  107891. * @param impostor impostor to get restitution from
  107892. * @returns restitution value
  107893. */
  107894. getBodyRestitution(impostor: PhysicsImpostor): number;
  107895. /**
  107896. * Sets resitution of the impostor
  107897. * @param impostor impostor to set resitution on
  107898. * @param restitution resitution value
  107899. */
  107900. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107901. /**
  107902. * Sleeps the physics body and stops it from being active
  107903. * @param impostor impostor to sleep
  107904. */
  107905. sleepBody(impostor: PhysicsImpostor): void;
  107906. /**
  107907. * Activates the physics body
  107908. * @param impostor impostor to activate
  107909. */
  107910. wakeUpBody(impostor: PhysicsImpostor): void;
  107911. /**
  107912. * Updates the distance parameters of the joint
  107913. * @param joint joint to update
  107914. * @param maxDistance maximum distance of the joint
  107915. * @param minDistance minimum distance of the joint
  107916. */
  107917. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107918. /**
  107919. * Sets a motor on the joint
  107920. * @param joint joint to set motor on
  107921. * @param speed speed of the motor
  107922. * @param maxForce maximum force of the motor
  107923. * @param motorIndex index of the motor
  107924. */
  107925. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107926. /**
  107927. * Sets the motors limit
  107928. * @param joint joint to set limit on
  107929. * @param upperLimit upper limit
  107930. * @param lowerLimit lower limit
  107931. */
  107932. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107933. /**
  107934. * Syncs the position and rotation of a mesh with the impostor
  107935. * @param mesh mesh to sync
  107936. * @param impostor impostor to update the mesh with
  107937. */
  107938. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107939. /**
  107940. * Gets the radius of the impostor
  107941. * @param impostor impostor to get radius from
  107942. * @returns the radius
  107943. */
  107944. getRadius(impostor: PhysicsImpostor): number;
  107945. /**
  107946. * Gets the box size of the impostor
  107947. * @param impostor impostor to get box size from
  107948. * @param result the resulting box size
  107949. */
  107950. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107951. /**
  107952. * Disposes of the impostor
  107953. */
  107954. dispose(): void;
  107955. }
  107956. }
  107957. declare module BABYLON {
  107958. /** @hidden */
  107959. export var blackAndWhitePixelShader: {
  107960. name: string;
  107961. shader: string;
  107962. };
  107963. }
  107964. declare module BABYLON {
  107965. /**
  107966. * Post process used to render in black and white
  107967. */
  107968. export class BlackAndWhitePostProcess extends PostProcess {
  107969. /**
  107970. * Linear about to convert he result to black and white (default: 1)
  107971. */
  107972. degree: number;
  107973. /**
  107974. * Creates a black and white post process
  107975. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  107976. * @param name The name of the effect.
  107977. * @param options The required width/height ratio to downsize to before computing the render pass.
  107978. * @param camera The camera to apply the render pass to.
  107979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  107980. * @param engine The engine which the post process will be applied. (default: current engine)
  107981. * @param reusable If the post process can be reused on the same frame. (default: false)
  107982. */
  107983. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  107984. }
  107985. }
  107986. declare module BABYLON {
  107987. /**
  107988. * This represents a set of one or more post processes in Babylon.
  107989. * A post process can be used to apply a shader to a texture after it is rendered.
  107990. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107991. */
  107992. export class PostProcessRenderEffect {
  107993. private _postProcesses;
  107994. private _getPostProcesses;
  107995. private _singleInstance;
  107996. private _cameras;
  107997. private _indicesForCamera;
  107998. /**
  107999. * Name of the effect
  108000. * @hidden
  108001. */
  108002. _name: string;
  108003. /**
  108004. * Instantiates a post process render effect.
  108005. * A post process can be used to apply a shader to a texture after it is rendered.
  108006. * @param engine The engine the effect is tied to
  108007. * @param name The name of the effect
  108008. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  108009. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  108010. */
  108011. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  108012. /**
  108013. * Checks if all the post processes in the effect are supported.
  108014. */
  108015. readonly isSupported: boolean;
  108016. /**
  108017. * Updates the current state of the effect
  108018. * @hidden
  108019. */
  108020. _update(): void;
  108021. /**
  108022. * Attaches the effect on cameras
  108023. * @param cameras The camera to attach to.
  108024. * @hidden
  108025. */
  108026. _attachCameras(cameras: Camera): void;
  108027. /**
  108028. * Attaches the effect on cameras
  108029. * @param cameras The camera to attach to.
  108030. * @hidden
  108031. */
  108032. _attachCameras(cameras: Camera[]): void;
  108033. /**
  108034. * Detatches the effect on cameras
  108035. * @param cameras The camera to detatch from.
  108036. * @hidden
  108037. */
  108038. _detachCameras(cameras: Camera): void;
  108039. /**
  108040. * Detatches the effect on cameras
  108041. * @param cameras The camera to detatch from.
  108042. * @hidden
  108043. */
  108044. _detachCameras(cameras: Camera[]): void;
  108045. /**
  108046. * Enables the effect on given cameras
  108047. * @param cameras The camera to enable.
  108048. * @hidden
  108049. */
  108050. _enable(cameras: Camera): void;
  108051. /**
  108052. * Enables the effect on given cameras
  108053. * @param cameras The camera to enable.
  108054. * @hidden
  108055. */
  108056. _enable(cameras: Nullable<Camera[]>): void;
  108057. /**
  108058. * Disables the effect on the given cameras
  108059. * @param cameras The camera to disable.
  108060. * @hidden
  108061. */
  108062. _disable(cameras: Camera): void;
  108063. /**
  108064. * Disables the effect on the given cameras
  108065. * @param cameras The camera to disable.
  108066. * @hidden
  108067. */
  108068. _disable(cameras: Nullable<Camera[]>): void;
  108069. /**
  108070. * Gets a list of the post processes contained in the effect.
  108071. * @param camera The camera to get the post processes on.
  108072. * @returns The list of the post processes in the effect.
  108073. */
  108074. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  108075. }
  108076. }
  108077. declare module BABYLON {
  108078. /** @hidden */
  108079. export var extractHighlightsPixelShader: {
  108080. name: string;
  108081. shader: string;
  108082. };
  108083. }
  108084. declare module BABYLON {
  108085. /**
  108086. * 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.
  108087. */
  108088. export class ExtractHighlightsPostProcess extends PostProcess {
  108089. /**
  108090. * The luminance threshold, pixels below this value will be set to black.
  108091. */
  108092. threshold: number;
  108093. /** @hidden */
  108094. _exposure: number;
  108095. /**
  108096. * Post process which has the input texture to be used when performing highlight extraction
  108097. * @hidden
  108098. */
  108099. _inputPostProcess: Nullable<PostProcess>;
  108100. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108101. }
  108102. }
  108103. declare module BABYLON {
  108104. /** @hidden */
  108105. export var bloomMergePixelShader: {
  108106. name: string;
  108107. shader: string;
  108108. };
  108109. }
  108110. declare module BABYLON {
  108111. /**
  108112. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108113. */
  108114. export class BloomMergePostProcess extends PostProcess {
  108115. /** Weight of the bloom to be added to the original input. */
  108116. weight: number;
  108117. /**
  108118. * Creates a new instance of @see BloomMergePostProcess
  108119. * @param name The name of the effect.
  108120. * @param originalFromInput Post process which's input will be used for the merge.
  108121. * @param blurred Blurred highlights post process which's output will be used.
  108122. * @param weight Weight of the bloom to be added to the original input.
  108123. * @param options The required width/height ratio to downsize to before computing the render pass.
  108124. * @param camera The camera to apply the render pass to.
  108125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108126. * @param engine The engine which the post process will be applied. (default: current engine)
  108127. * @param reusable If the post process can be reused on the same frame. (default: false)
  108128. * @param textureType Type of textures used when performing the post process. (default: 0)
  108129. * @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)
  108130. */
  108131. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  108132. /** Weight of the bloom to be added to the original input. */
  108133. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108134. }
  108135. }
  108136. declare module BABYLON {
  108137. /**
  108138. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  108139. */
  108140. export class BloomEffect extends PostProcessRenderEffect {
  108141. private bloomScale;
  108142. /**
  108143. * @hidden Internal
  108144. */
  108145. _effects: Array<PostProcess>;
  108146. /**
  108147. * @hidden Internal
  108148. */
  108149. _downscale: ExtractHighlightsPostProcess;
  108150. private _blurX;
  108151. private _blurY;
  108152. private _merge;
  108153. /**
  108154. * The luminance threshold to find bright areas of the image to bloom.
  108155. */
  108156. threshold: number;
  108157. /**
  108158. * The strength of the bloom.
  108159. */
  108160. weight: number;
  108161. /**
  108162. * Specifies the size of the bloom blur kernel, relative to the final output size
  108163. */
  108164. kernel: number;
  108165. /**
  108166. * Creates a new instance of @see BloomEffect
  108167. * @param scene The scene the effect belongs to.
  108168. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  108169. * @param bloomKernel The size of the kernel to be used when applying the blur.
  108170. * @param bloomWeight The the strength of bloom.
  108171. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108172. * @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)
  108173. */
  108174. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  108175. /**
  108176. * Disposes each of the internal effects for a given camera.
  108177. * @param camera The camera to dispose the effect on.
  108178. */
  108179. disposeEffects(camera: Camera): void;
  108180. /**
  108181. * @hidden Internal
  108182. */
  108183. _updateEffects(): void;
  108184. /**
  108185. * Internal
  108186. * @returns if all the contained post processes are ready.
  108187. * @hidden
  108188. */
  108189. _isReady(): boolean;
  108190. }
  108191. }
  108192. declare module BABYLON {
  108193. /** @hidden */
  108194. export var chromaticAberrationPixelShader: {
  108195. name: string;
  108196. shader: string;
  108197. };
  108198. }
  108199. declare module BABYLON {
  108200. /**
  108201. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  108202. */
  108203. export class ChromaticAberrationPostProcess extends PostProcess {
  108204. /**
  108205. * The amount of seperation of rgb channels (default: 30)
  108206. */
  108207. aberrationAmount: number;
  108208. /**
  108209. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  108210. */
  108211. radialIntensity: number;
  108212. /**
  108213. * 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))
  108214. */
  108215. direction: Vector2;
  108216. /**
  108217. * 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))
  108218. */
  108219. centerPosition: Vector2;
  108220. /**
  108221. * Creates a new instance ChromaticAberrationPostProcess
  108222. * @param name The name of the effect.
  108223. * @param screenWidth The width of the screen to apply the effect on.
  108224. * @param screenHeight The height of the screen to apply the effect on.
  108225. * @param options The required width/height ratio to downsize to before computing the render pass.
  108226. * @param camera The camera to apply the render pass to.
  108227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108228. * @param engine The engine which the post process will be applied. (default: current engine)
  108229. * @param reusable If the post process can be reused on the same frame. (default: false)
  108230. * @param textureType Type of textures used when performing the post process. (default: 0)
  108231. * @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)
  108232. */
  108233. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108234. }
  108235. }
  108236. declare module BABYLON {
  108237. /** @hidden */
  108238. export var circleOfConfusionPixelShader: {
  108239. name: string;
  108240. shader: string;
  108241. };
  108242. }
  108243. declare module BABYLON {
  108244. /**
  108245. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  108246. */
  108247. export class CircleOfConfusionPostProcess extends PostProcess {
  108248. /**
  108249. * 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.
  108250. */
  108251. lensSize: number;
  108252. /**
  108253. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108254. */
  108255. fStop: number;
  108256. /**
  108257. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108258. */
  108259. focusDistance: number;
  108260. /**
  108261. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  108262. */
  108263. focalLength: number;
  108264. private _depthTexture;
  108265. /**
  108266. * Creates a new instance CircleOfConfusionPostProcess
  108267. * @param name The name of the effect.
  108268. * @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.
  108269. * @param options The required width/height ratio to downsize to before computing the render pass.
  108270. * @param camera The camera to apply the render pass to.
  108271. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108272. * @param engine The engine which the post process will be applied. (default: current engine)
  108273. * @param reusable If the post process can be reused on the same frame. (default: false)
  108274. * @param textureType Type of textures used when performing the post process. (default: 0)
  108275. * @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)
  108276. */
  108277. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108278. /**
  108279. * 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.
  108280. */
  108281. depthTexture: RenderTargetTexture;
  108282. }
  108283. }
  108284. declare module BABYLON {
  108285. /** @hidden */
  108286. export var colorCorrectionPixelShader: {
  108287. name: string;
  108288. shader: string;
  108289. };
  108290. }
  108291. declare module BABYLON {
  108292. /**
  108293. *
  108294. * This post-process allows the modification of rendered colors by using
  108295. * a 'look-up table' (LUT). This effect is also called Color Grading.
  108296. *
  108297. * The object needs to be provided an url to a texture containing the color
  108298. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  108299. * Use an image editing software to tweak the LUT to match your needs.
  108300. *
  108301. * For an example of a color LUT, see here:
  108302. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  108303. * For explanations on color grading, see here:
  108304. * @see http://udn.epicgames.com/Three/ColorGrading.html
  108305. *
  108306. */
  108307. export class ColorCorrectionPostProcess extends PostProcess {
  108308. private _colorTableTexture;
  108309. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108310. }
  108311. }
  108312. declare module BABYLON {
  108313. /** @hidden */
  108314. export var convolutionPixelShader: {
  108315. name: string;
  108316. shader: string;
  108317. };
  108318. }
  108319. declare module BABYLON {
  108320. /**
  108321. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  108322. * input texture to perform effects such as edge detection or sharpening
  108323. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108324. */
  108325. export class ConvolutionPostProcess extends PostProcess {
  108326. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108327. kernel: number[];
  108328. /**
  108329. * Creates a new instance ConvolutionPostProcess
  108330. * @param name The name of the effect.
  108331. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  108332. * @param options The required width/height ratio to downsize to before computing the render pass.
  108333. * @param camera The camera to apply the render pass to.
  108334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108335. * @param engine The engine which the post process will be applied. (default: current engine)
  108336. * @param reusable If the post process can be reused on the same frame. (default: false)
  108337. * @param textureType Type of textures used when performing the post process. (default: 0)
  108338. */
  108339. constructor(name: string,
  108340. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  108341. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108342. /**
  108343. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108344. */
  108345. static EdgeDetect0Kernel: number[];
  108346. /**
  108347. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108348. */
  108349. static EdgeDetect1Kernel: number[];
  108350. /**
  108351. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108352. */
  108353. static EdgeDetect2Kernel: number[];
  108354. /**
  108355. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108356. */
  108357. static SharpenKernel: number[];
  108358. /**
  108359. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108360. */
  108361. static EmbossKernel: number[];
  108362. /**
  108363. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  108364. */
  108365. static GaussianKernel: number[];
  108366. }
  108367. }
  108368. declare module BABYLON {
  108369. /**
  108370. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  108371. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  108372. * based on samples that have a large difference in distance than the center pixel.
  108373. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  108374. */
  108375. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  108376. direction: Vector2;
  108377. /**
  108378. * Creates a new instance CircleOfConfusionPostProcess
  108379. * @param name The name of the effect.
  108380. * @param scene The scene the effect belongs to.
  108381. * @param direction The direction the blur should be applied.
  108382. * @param kernel The size of the kernel used to blur.
  108383. * @param options The required width/height ratio to downsize to before computing the render pass.
  108384. * @param camera The camera to apply the render pass to.
  108385. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  108386. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  108387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108388. * @param engine The engine which the post process will be applied. (default: current engine)
  108389. * @param reusable If the post process can be reused on the same frame. (default: false)
  108390. * @param textureType Type of textures used when performing the post process. (default: 0)
  108391. * @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)
  108392. */
  108393. 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);
  108394. }
  108395. }
  108396. declare module BABYLON {
  108397. /** @hidden */
  108398. export var depthOfFieldMergePixelShader: {
  108399. name: string;
  108400. shader: string;
  108401. };
  108402. }
  108403. declare module BABYLON {
  108404. /**
  108405. * Options to be set when merging outputs from the default pipeline.
  108406. */
  108407. export class DepthOfFieldMergePostProcessOptions {
  108408. /**
  108409. * The original image to merge on top of
  108410. */
  108411. originalFromInput: PostProcess;
  108412. /**
  108413. * Parameters to perform the merge of the depth of field effect
  108414. */
  108415. depthOfField?: {
  108416. circleOfConfusion: PostProcess;
  108417. blurSteps: Array<PostProcess>;
  108418. };
  108419. /**
  108420. * Parameters to perform the merge of bloom effect
  108421. */
  108422. bloom?: {
  108423. blurred: PostProcess;
  108424. weight: number;
  108425. };
  108426. }
  108427. /**
  108428. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  108429. */
  108430. export class DepthOfFieldMergePostProcess extends PostProcess {
  108431. private blurSteps;
  108432. /**
  108433. * Creates a new instance of DepthOfFieldMergePostProcess
  108434. * @param name The name of the effect.
  108435. * @param originalFromInput Post process which's input will be used for the merge.
  108436. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  108437. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  108438. * @param options The required width/height ratio to downsize to before computing the render pass.
  108439. * @param camera The camera to apply the render pass to.
  108440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108441. * @param engine The engine which the post process will be applied. (default: current engine)
  108442. * @param reusable If the post process can be reused on the same frame. (default: false)
  108443. * @param textureType Type of textures used when performing the post process. (default: 0)
  108444. * @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)
  108445. */
  108446. 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);
  108447. /**
  108448. * Updates the effect with the current post process compile time values and recompiles the shader.
  108449. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  108450. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  108451. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  108452. * @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
  108453. * @param onCompiled Called when the shader has been compiled.
  108454. * @param onError Called if there is an error when compiling a shader.
  108455. */
  108456. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  108457. }
  108458. }
  108459. declare module BABYLON {
  108460. /**
  108461. * Specifies the level of max blur that should be applied when using the depth of field effect
  108462. */
  108463. export enum DepthOfFieldEffectBlurLevel {
  108464. /**
  108465. * Subtle blur
  108466. */
  108467. Low = 0,
  108468. /**
  108469. * Medium blur
  108470. */
  108471. Medium = 1,
  108472. /**
  108473. * Large blur
  108474. */
  108475. High = 2
  108476. }
  108477. /**
  108478. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  108479. */
  108480. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  108481. private _circleOfConfusion;
  108482. /**
  108483. * @hidden Internal, blurs from high to low
  108484. */
  108485. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  108486. private _depthOfFieldBlurY;
  108487. private _dofMerge;
  108488. /**
  108489. * @hidden Internal post processes in depth of field effect
  108490. */
  108491. _effects: Array<PostProcess>;
  108492. /**
  108493. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  108494. */
  108495. focalLength: number;
  108496. /**
  108497. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  108498. */
  108499. fStop: number;
  108500. /**
  108501. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  108502. */
  108503. focusDistance: number;
  108504. /**
  108505. * 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.
  108506. */
  108507. lensSize: number;
  108508. /**
  108509. * Creates a new instance DepthOfFieldEffect
  108510. * @param scene The scene the effect belongs to.
  108511. * @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.
  108512. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  108513. * @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)
  108514. */
  108515. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  108516. /**
  108517. * 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.
  108518. */
  108519. depthTexture: RenderTargetTexture;
  108520. /**
  108521. * Disposes each of the internal effects for a given camera.
  108522. * @param camera The camera to dispose the effect on.
  108523. */
  108524. disposeEffects(camera: Camera): void;
  108525. /**
  108526. * @hidden Internal
  108527. */
  108528. _updateEffects(): void;
  108529. /**
  108530. * Internal
  108531. * @returns if all the contained post processes are ready.
  108532. * @hidden
  108533. */
  108534. _isReady(): boolean;
  108535. }
  108536. }
  108537. declare module BABYLON {
  108538. /** @hidden */
  108539. export var displayPassPixelShader: {
  108540. name: string;
  108541. shader: string;
  108542. };
  108543. }
  108544. declare module BABYLON {
  108545. /**
  108546. * DisplayPassPostProcess which produces an output the same as it's input
  108547. */
  108548. export class DisplayPassPostProcess extends PostProcess {
  108549. /**
  108550. * Creates the DisplayPassPostProcess
  108551. * @param name The name of the effect.
  108552. * @param options The required width/height ratio to downsize to before computing the render pass.
  108553. * @param camera The camera to apply the render pass to.
  108554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108555. * @param engine The engine which the post process will be applied. (default: current engine)
  108556. * @param reusable If the post process can be reused on the same frame. (default: false)
  108557. */
  108558. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108559. }
  108560. }
  108561. declare module BABYLON {
  108562. /** @hidden */
  108563. export var filterPixelShader: {
  108564. name: string;
  108565. shader: string;
  108566. };
  108567. }
  108568. declare module BABYLON {
  108569. /**
  108570. * Applies a kernel filter to the image
  108571. */
  108572. export class FilterPostProcess extends PostProcess {
  108573. /** The matrix to be applied to the image */
  108574. kernelMatrix: Matrix;
  108575. /**
  108576. *
  108577. * @param name The name of the effect.
  108578. * @param kernelMatrix The matrix to be applied to the image
  108579. * @param options The required width/height ratio to downsize to before computing the render pass.
  108580. * @param camera The camera to apply the render pass to.
  108581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108582. * @param engine The engine which the post process will be applied. (default: current engine)
  108583. * @param reusable If the post process can be reused on the same frame. (default: false)
  108584. */
  108585. constructor(name: string,
  108586. /** The matrix to be applied to the image */
  108587. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108588. }
  108589. }
  108590. declare module BABYLON {
  108591. /** @hidden */
  108592. export var fxaaPixelShader: {
  108593. name: string;
  108594. shader: string;
  108595. };
  108596. }
  108597. declare module BABYLON {
  108598. /** @hidden */
  108599. export var fxaaVertexShader: {
  108600. name: string;
  108601. shader: string;
  108602. };
  108603. }
  108604. declare module BABYLON {
  108605. /**
  108606. * Fxaa post process
  108607. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  108608. */
  108609. export class FxaaPostProcess extends PostProcess {
  108610. /** @hidden */
  108611. texelWidth: number;
  108612. /** @hidden */
  108613. texelHeight: number;
  108614. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108615. private _getDefines;
  108616. }
  108617. }
  108618. declare module BABYLON {
  108619. /** @hidden */
  108620. export var grainPixelShader: {
  108621. name: string;
  108622. shader: string;
  108623. };
  108624. }
  108625. declare module BABYLON {
  108626. /**
  108627. * The GrainPostProcess adds noise to the image at mid luminance levels
  108628. */
  108629. export class GrainPostProcess extends PostProcess {
  108630. /**
  108631. * The intensity of the grain added (default: 30)
  108632. */
  108633. intensity: number;
  108634. /**
  108635. * If the grain should be randomized on every frame
  108636. */
  108637. animated: boolean;
  108638. /**
  108639. * Creates a new instance of @see GrainPostProcess
  108640. * @param name The name of the effect.
  108641. * @param options The required width/height ratio to downsize to before computing the render pass.
  108642. * @param camera The camera to apply the render pass to.
  108643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108644. * @param engine The engine which the post process will be applied. (default: current engine)
  108645. * @param reusable If the post process can be reused on the same frame. (default: false)
  108646. * @param textureType Type of textures used when performing the post process. (default: 0)
  108647. * @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)
  108648. */
  108649. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108650. }
  108651. }
  108652. declare module BABYLON {
  108653. /** @hidden */
  108654. export var highlightsPixelShader: {
  108655. name: string;
  108656. shader: string;
  108657. };
  108658. }
  108659. declare module BABYLON {
  108660. /**
  108661. * Extracts highlights from the image
  108662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108663. */
  108664. export class HighlightsPostProcess extends PostProcess {
  108665. /**
  108666. * Extracts highlights from the image
  108667. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108668. * @param name The name of the effect.
  108669. * @param options The required width/height ratio to downsize to before computing the render pass.
  108670. * @param camera The camera to apply the render pass to.
  108671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108672. * @param engine The engine which the post process will be applied. (default: current engine)
  108673. * @param reusable If the post process can be reused on the same frame. (default: false)
  108674. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  108675. */
  108676. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  108677. }
  108678. }
  108679. declare module BABYLON {
  108680. /** @hidden */
  108681. export var mrtFragmentDeclaration: {
  108682. name: string;
  108683. shader: string;
  108684. };
  108685. }
  108686. declare module BABYLON {
  108687. /** @hidden */
  108688. export var geometryPixelShader: {
  108689. name: string;
  108690. shader: string;
  108691. };
  108692. }
  108693. declare module BABYLON {
  108694. /** @hidden */
  108695. export var geometryVertexShader: {
  108696. name: string;
  108697. shader: string;
  108698. };
  108699. }
  108700. declare module BABYLON {
  108701. /**
  108702. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108703. */
  108704. export class GeometryBufferRenderer {
  108705. /**
  108706. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108707. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108708. */
  108709. static readonly POSITION_TEXTURE_TYPE: number;
  108710. /**
  108711. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108712. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108713. */
  108714. static readonly VELOCITY_TEXTURE_TYPE: number;
  108715. /**
  108716. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108717. * in order to compute objects velocities when enableVelocity is set to "true"
  108718. * @hidden
  108719. */
  108720. _previousTransformationMatrices: {
  108721. [index: number]: Matrix;
  108722. };
  108723. private _scene;
  108724. private _multiRenderTarget;
  108725. private _ratio;
  108726. private _enablePosition;
  108727. private _enableVelocity;
  108728. private _positionIndex;
  108729. private _velocityIndex;
  108730. protected _effect: Effect;
  108731. protected _cachedDefines: string;
  108732. /**
  108733. * Set the render list (meshes to be rendered) used in the G buffer.
  108734. */
  108735. renderList: Mesh[];
  108736. /**
  108737. * Gets wether or not G buffer are supported by the running hardware.
  108738. * This requires draw buffer supports
  108739. */
  108740. readonly isSupported: boolean;
  108741. /**
  108742. * Returns the index of the given texture type in the G-Buffer textures array
  108743. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108744. * @returns the index of the given texture type in the G-Buffer textures array
  108745. */
  108746. getTextureIndex(textureType: number): number;
  108747. /**
  108748. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108749. */
  108750. /**
  108751. * Sets whether or not objects positions are enabled for the G buffer.
  108752. */
  108753. enablePosition: boolean;
  108754. /**
  108755. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108756. */
  108757. /**
  108758. * Sets wether or not objects velocities are enabled for the G buffer.
  108759. */
  108760. enableVelocity: boolean;
  108761. /**
  108762. * Gets the scene associated with the buffer.
  108763. */
  108764. readonly scene: Scene;
  108765. /**
  108766. * Gets the ratio used by the buffer during its creation.
  108767. * How big is the buffer related to the main canvas.
  108768. */
  108769. readonly ratio: number;
  108770. /** @hidden */
  108771. static _SceneComponentInitialization: (scene: Scene) => void;
  108772. /**
  108773. * Creates a new G Buffer for the scene
  108774. * @param scene The scene the buffer belongs to
  108775. * @param ratio How big is the buffer related to the main canvas.
  108776. */
  108777. constructor(scene: Scene, ratio?: number);
  108778. /**
  108779. * Checks wether everything is ready to render a submesh to the G buffer.
  108780. * @param subMesh the submesh to check readiness for
  108781. * @param useInstances is the mesh drawn using instance or not
  108782. * @returns true if ready otherwise false
  108783. */
  108784. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108785. /**
  108786. * Gets the current underlying G Buffer.
  108787. * @returns the buffer
  108788. */
  108789. getGBuffer(): MultiRenderTarget;
  108790. /**
  108791. * Gets the number of samples used to render the buffer (anti aliasing).
  108792. */
  108793. /**
  108794. * Sets the number of samples used to render the buffer (anti aliasing).
  108795. */
  108796. samples: number;
  108797. /**
  108798. * Disposes the renderer and frees up associated resources.
  108799. */
  108800. dispose(): void;
  108801. protected _createRenderTargets(): void;
  108802. }
  108803. }
  108804. declare module BABYLON {
  108805. interface Scene {
  108806. /** @hidden (Backing field) */
  108807. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108808. /**
  108809. * Gets or Sets the current geometry buffer associated to the scene.
  108810. */
  108811. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108812. /**
  108813. * Enables a GeometryBufferRender and associates it with the scene
  108814. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108815. * @returns the GeometryBufferRenderer
  108816. */
  108817. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108818. /**
  108819. * Disables the GeometryBufferRender associated with the scene
  108820. */
  108821. disableGeometryBufferRenderer(): void;
  108822. }
  108823. /**
  108824. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108825. * in several rendering techniques.
  108826. */
  108827. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108828. /**
  108829. * The component name helpful to identify the component in the list of scene components.
  108830. */
  108831. readonly name: string;
  108832. /**
  108833. * The scene the component belongs to.
  108834. */
  108835. scene: Scene;
  108836. /**
  108837. * Creates a new instance of the component for the given scene
  108838. * @param scene Defines the scene to register the component in
  108839. */
  108840. constructor(scene: Scene);
  108841. /**
  108842. * Registers the component in a given scene
  108843. */
  108844. register(): void;
  108845. /**
  108846. * Rebuilds the elements related to this component in case of
  108847. * context lost for instance.
  108848. */
  108849. rebuild(): void;
  108850. /**
  108851. * Disposes the component and the associated ressources
  108852. */
  108853. dispose(): void;
  108854. private _gatherRenderTargets;
  108855. }
  108856. }
  108857. declare module BABYLON {
  108858. /** @hidden */
  108859. export var motionBlurPixelShader: {
  108860. name: string;
  108861. shader: string;
  108862. };
  108863. }
  108864. declare module BABYLON {
  108865. /**
  108866. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  108867. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  108868. * As an example, all you have to do is to create the post-process:
  108869. * var mb = new BABYLON.MotionBlurPostProcess(
  108870. * 'mb', // The name of the effect.
  108871. * scene, // The scene containing the objects to blur according to their velocity.
  108872. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  108873. * camera // The camera to apply the render pass to.
  108874. * );
  108875. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  108876. */
  108877. export class MotionBlurPostProcess extends PostProcess {
  108878. /**
  108879. * Defines how much the image is blurred by the movement. Default value is equal to 1
  108880. */
  108881. motionStrength: number;
  108882. /**
  108883. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  108884. */
  108885. /**
  108886. * Sets the number of iterations to be used for motion blur quality
  108887. */
  108888. motionBlurSamples: number;
  108889. private _motionBlurSamples;
  108890. private _geometryBufferRenderer;
  108891. /**
  108892. * Creates a new instance MotionBlurPostProcess
  108893. * @param name The name of the effect.
  108894. * @param scene The scene containing the objects to blur according to their velocity.
  108895. * @param options The required width/height ratio to downsize to before computing the render pass.
  108896. * @param camera The camera to apply the render pass to.
  108897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108898. * @param engine The engine which the post process will be applied. (default: current engine)
  108899. * @param reusable If the post process can be reused on the same frame. (default: false)
  108900. * @param textureType Type of textures used when performing the post process. (default: 0)
  108901. * @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)
  108902. */
  108903. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108904. /**
  108905. * Disposes the post process.
  108906. * @param camera The camera to dispose the post process on.
  108907. */
  108908. dispose(camera?: Camera): void;
  108909. }
  108910. }
  108911. declare module BABYLON {
  108912. /** @hidden */
  108913. export var refractionPixelShader: {
  108914. name: string;
  108915. shader: string;
  108916. };
  108917. }
  108918. declare module BABYLON {
  108919. /**
  108920. * Post process which applies a refractin texture
  108921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108922. */
  108923. export class RefractionPostProcess extends PostProcess {
  108924. /** the base color of the refraction (used to taint the rendering) */
  108925. color: Color3;
  108926. /** simulated refraction depth */
  108927. depth: number;
  108928. /** the coefficient of the base color (0 to remove base color tainting) */
  108929. colorLevel: number;
  108930. private _refTexture;
  108931. private _ownRefractionTexture;
  108932. /**
  108933. * Gets or sets the refraction texture
  108934. * Please note that you are responsible for disposing the texture if you set it manually
  108935. */
  108936. refractionTexture: Texture;
  108937. /**
  108938. * Initializes the RefractionPostProcess
  108939. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  108940. * @param name The name of the effect.
  108941. * @param refractionTextureUrl Url of the refraction texture to use
  108942. * @param color the base color of the refraction (used to taint the rendering)
  108943. * @param depth simulated refraction depth
  108944. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  108945. * @param camera The camera to apply the render pass to.
  108946. * @param options The required width/height ratio to downsize to before computing the render pass.
  108947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108948. * @param engine The engine which the post process will be applied. (default: current engine)
  108949. * @param reusable If the post process can be reused on the same frame. (default: false)
  108950. */
  108951. constructor(name: string, refractionTextureUrl: string,
  108952. /** the base color of the refraction (used to taint the rendering) */
  108953. color: Color3,
  108954. /** simulated refraction depth */
  108955. depth: number,
  108956. /** the coefficient of the base color (0 to remove base color tainting) */
  108957. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108958. /**
  108959. * Disposes of the post process
  108960. * @param camera Camera to dispose post process on
  108961. */
  108962. dispose(camera: Camera): void;
  108963. }
  108964. }
  108965. declare module BABYLON {
  108966. /** @hidden */
  108967. export var sharpenPixelShader: {
  108968. name: string;
  108969. shader: string;
  108970. };
  108971. }
  108972. declare module BABYLON {
  108973. /**
  108974. * The SharpenPostProcess applies a sharpen kernel to every pixel
  108975. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  108976. */
  108977. export class SharpenPostProcess extends PostProcess {
  108978. /**
  108979. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  108980. */
  108981. colorAmount: number;
  108982. /**
  108983. * How much sharpness should be applied (default: 0.3)
  108984. */
  108985. edgeAmount: number;
  108986. /**
  108987. * Creates a new instance ConvolutionPostProcess
  108988. * @param name The name of the effect.
  108989. * @param options The required width/height ratio to downsize to before computing the render pass.
  108990. * @param camera The camera to apply the render pass to.
  108991. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108992. * @param engine The engine which the post process will be applied. (default: current engine)
  108993. * @param reusable If the post process can be reused on the same frame. (default: false)
  108994. * @param textureType Type of textures used when performing the post process. (default: 0)
  108995. * @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)
  108996. */
  108997. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108998. }
  108999. }
  109000. declare module BABYLON {
  109001. /**
  109002. * PostProcessRenderPipeline
  109003. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109004. */
  109005. export class PostProcessRenderPipeline {
  109006. private engine;
  109007. private _renderEffects;
  109008. private _renderEffectsForIsolatedPass;
  109009. /**
  109010. * @hidden
  109011. */
  109012. protected _cameras: Camera[];
  109013. /** @hidden */
  109014. _name: string;
  109015. /**
  109016. * Gets pipeline name
  109017. */
  109018. readonly name: string;
  109019. /**
  109020. * Initializes a PostProcessRenderPipeline
  109021. * @param engine engine to add the pipeline to
  109022. * @param name name of the pipeline
  109023. */
  109024. constructor(engine: Engine, name: string);
  109025. /**
  109026. * Gets the class name
  109027. * @returns "PostProcessRenderPipeline"
  109028. */
  109029. getClassName(): string;
  109030. /**
  109031. * If all the render effects in the pipeline are supported
  109032. */
  109033. readonly isSupported: boolean;
  109034. /**
  109035. * Adds an effect to the pipeline
  109036. * @param renderEffect the effect to add
  109037. */
  109038. addEffect(renderEffect: PostProcessRenderEffect): void;
  109039. /** @hidden */
  109040. _rebuild(): void;
  109041. /** @hidden */
  109042. _enableEffect(renderEffectName: string, cameras: Camera): void;
  109043. /** @hidden */
  109044. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  109045. /** @hidden */
  109046. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109047. /** @hidden */
  109048. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  109049. /** @hidden */
  109050. _attachCameras(cameras: Camera, unique: boolean): void;
  109051. /** @hidden */
  109052. _attachCameras(cameras: Camera[], unique: boolean): void;
  109053. /** @hidden */
  109054. _detachCameras(cameras: Camera): void;
  109055. /** @hidden */
  109056. _detachCameras(cameras: Nullable<Camera[]>): void;
  109057. /** @hidden */
  109058. _update(): void;
  109059. /** @hidden */
  109060. _reset(): void;
  109061. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  109062. /**
  109063. * Disposes of the pipeline
  109064. */
  109065. dispose(): void;
  109066. }
  109067. }
  109068. declare module BABYLON {
  109069. /**
  109070. * PostProcessRenderPipelineManager class
  109071. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109072. */
  109073. export class PostProcessRenderPipelineManager {
  109074. private _renderPipelines;
  109075. /**
  109076. * Initializes a PostProcessRenderPipelineManager
  109077. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109078. */
  109079. constructor();
  109080. /**
  109081. * Gets the list of supported render pipelines
  109082. */
  109083. readonly supportedPipelines: PostProcessRenderPipeline[];
  109084. /**
  109085. * Adds a pipeline to the manager
  109086. * @param renderPipeline The pipeline to add
  109087. */
  109088. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  109089. /**
  109090. * Attaches a camera to the pipeline
  109091. * @param renderPipelineName The name of the pipeline to attach to
  109092. * @param cameras the camera to attach
  109093. * @param unique if the camera can be attached multiple times to the pipeline
  109094. */
  109095. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  109096. /**
  109097. * Detaches a camera from the pipeline
  109098. * @param renderPipelineName The name of the pipeline to detach from
  109099. * @param cameras the camera to detach
  109100. */
  109101. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  109102. /**
  109103. * Enables an effect by name on a pipeline
  109104. * @param renderPipelineName the name of the pipeline to enable the effect in
  109105. * @param renderEffectName the name of the effect to enable
  109106. * @param cameras the cameras that the effect should be enabled on
  109107. */
  109108. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109109. /**
  109110. * Disables an effect by name on a pipeline
  109111. * @param renderPipelineName the name of the pipeline to disable the effect in
  109112. * @param renderEffectName the name of the effect to disable
  109113. * @param cameras the cameras that the effect should be disabled on
  109114. */
  109115. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  109116. /**
  109117. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  109118. */
  109119. update(): void;
  109120. /** @hidden */
  109121. _rebuild(): void;
  109122. /**
  109123. * Disposes of the manager and pipelines
  109124. */
  109125. dispose(): void;
  109126. }
  109127. }
  109128. declare module BABYLON {
  109129. interface Scene {
  109130. /** @hidden (Backing field) */
  109131. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109132. /**
  109133. * Gets the postprocess render pipeline manager
  109134. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109135. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109136. */
  109137. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  109138. }
  109139. /**
  109140. * Defines the Render Pipeline scene component responsible to rendering pipelines
  109141. */
  109142. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  109143. /**
  109144. * The component name helpfull to identify the component in the list of scene components.
  109145. */
  109146. readonly name: string;
  109147. /**
  109148. * The scene the component belongs to.
  109149. */
  109150. scene: Scene;
  109151. /**
  109152. * Creates a new instance of the component for the given scene
  109153. * @param scene Defines the scene to register the component in
  109154. */
  109155. constructor(scene: Scene);
  109156. /**
  109157. * Registers the component in a given scene
  109158. */
  109159. register(): void;
  109160. /**
  109161. * Rebuilds the elements related to this component in case of
  109162. * context lost for instance.
  109163. */
  109164. rebuild(): void;
  109165. /**
  109166. * Disposes the component and the associated ressources
  109167. */
  109168. dispose(): void;
  109169. private _gatherRenderTargets;
  109170. }
  109171. }
  109172. declare module BABYLON {
  109173. /**
  109174. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  109175. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  109176. */
  109177. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109178. private _scene;
  109179. private _camerasToBeAttached;
  109180. /**
  109181. * ID of the sharpen post process,
  109182. */
  109183. private readonly SharpenPostProcessId;
  109184. /**
  109185. * @ignore
  109186. * ID of the image processing post process;
  109187. */
  109188. readonly ImageProcessingPostProcessId: string;
  109189. /**
  109190. * @ignore
  109191. * ID of the Fast Approximate Anti-Aliasing post process;
  109192. */
  109193. readonly FxaaPostProcessId: string;
  109194. /**
  109195. * ID of the chromatic aberration post process,
  109196. */
  109197. private readonly ChromaticAberrationPostProcessId;
  109198. /**
  109199. * ID of the grain post process
  109200. */
  109201. private readonly GrainPostProcessId;
  109202. /**
  109203. * Sharpen post process which will apply a sharpen convolution to enhance edges
  109204. */
  109205. sharpen: SharpenPostProcess;
  109206. private _sharpenEffect;
  109207. private bloom;
  109208. /**
  109209. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  109210. */
  109211. depthOfField: DepthOfFieldEffect;
  109212. /**
  109213. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109214. */
  109215. fxaa: FxaaPostProcess;
  109216. /**
  109217. * Image post processing pass used to perform operations such as tone mapping or color grading.
  109218. */
  109219. imageProcessing: ImageProcessingPostProcess;
  109220. /**
  109221. * Chromatic aberration post process which will shift rgb colors in the image
  109222. */
  109223. chromaticAberration: ChromaticAberrationPostProcess;
  109224. private _chromaticAberrationEffect;
  109225. /**
  109226. * Grain post process which add noise to the image
  109227. */
  109228. grain: GrainPostProcess;
  109229. private _grainEffect;
  109230. /**
  109231. * Glow post process which adds a glow to emissive areas of the image
  109232. */
  109233. private _glowLayer;
  109234. /**
  109235. * Animations which can be used to tweak settings over a period of time
  109236. */
  109237. animations: Animation[];
  109238. private _imageProcessingConfigurationObserver;
  109239. private _sharpenEnabled;
  109240. private _bloomEnabled;
  109241. private _depthOfFieldEnabled;
  109242. private _depthOfFieldBlurLevel;
  109243. private _fxaaEnabled;
  109244. private _imageProcessingEnabled;
  109245. private _defaultPipelineTextureType;
  109246. private _bloomScale;
  109247. private _chromaticAberrationEnabled;
  109248. private _grainEnabled;
  109249. private _buildAllowed;
  109250. /**
  109251. * Gets active scene
  109252. */
  109253. readonly scene: Scene;
  109254. /**
  109255. * Enable or disable the sharpen process from the pipeline
  109256. */
  109257. sharpenEnabled: boolean;
  109258. private _resizeObserver;
  109259. private _hardwareScaleLevel;
  109260. private _bloomKernel;
  109261. /**
  109262. * Specifies the size of the bloom blur kernel, relative to the final output size
  109263. */
  109264. bloomKernel: number;
  109265. /**
  109266. * Specifies the weight of the bloom in the final rendering
  109267. */
  109268. private _bloomWeight;
  109269. /**
  109270. * Specifies the luma threshold for the area that will be blurred by the bloom
  109271. */
  109272. private _bloomThreshold;
  109273. private _hdr;
  109274. /**
  109275. * The strength of the bloom.
  109276. */
  109277. bloomWeight: number;
  109278. /**
  109279. * The strength of the bloom.
  109280. */
  109281. bloomThreshold: number;
  109282. /**
  109283. * The scale of the bloom, lower value will provide better performance.
  109284. */
  109285. bloomScale: number;
  109286. /**
  109287. * Enable or disable the bloom from the pipeline
  109288. */
  109289. bloomEnabled: boolean;
  109290. private _rebuildBloom;
  109291. /**
  109292. * If the depth of field is enabled.
  109293. */
  109294. depthOfFieldEnabled: boolean;
  109295. /**
  109296. * Blur level of the depth of field effect. (Higher blur will effect performance)
  109297. */
  109298. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  109299. /**
  109300. * If the anti aliasing is enabled.
  109301. */
  109302. fxaaEnabled: boolean;
  109303. private _samples;
  109304. /**
  109305. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  109306. */
  109307. samples: number;
  109308. /**
  109309. * If image processing is enabled.
  109310. */
  109311. imageProcessingEnabled: boolean;
  109312. /**
  109313. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  109314. */
  109315. glowLayerEnabled: boolean;
  109316. /**
  109317. * Enable or disable the chromaticAberration process from the pipeline
  109318. */
  109319. chromaticAberrationEnabled: boolean;
  109320. /**
  109321. * Enable or disable the grain process from the pipeline
  109322. */
  109323. grainEnabled: boolean;
  109324. /**
  109325. * @constructor
  109326. * @param name - The rendering pipeline name (default: "")
  109327. * @param hdr - If high dynamic range textures should be used (default: true)
  109328. * @param scene - The scene linked to this pipeline (default: the last created scene)
  109329. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  109330. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  109331. */
  109332. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  109333. /**
  109334. * Get the class name
  109335. * @returns "DefaultRenderingPipeline"
  109336. */
  109337. getClassName(): string;
  109338. /**
  109339. * Force the compilation of the entire pipeline.
  109340. */
  109341. prepare(): void;
  109342. private _hasCleared;
  109343. private _prevPostProcess;
  109344. private _prevPrevPostProcess;
  109345. private _setAutoClearAndTextureSharing;
  109346. private _depthOfFieldSceneObserver;
  109347. private _buildPipeline;
  109348. private _disposePostProcesses;
  109349. /**
  109350. * Adds a camera to the pipeline
  109351. * @param camera the camera to be added
  109352. */
  109353. addCamera(camera: Camera): void;
  109354. /**
  109355. * Removes a camera from the pipeline
  109356. * @param camera the camera to remove
  109357. */
  109358. removeCamera(camera: Camera): void;
  109359. /**
  109360. * Dispose of the pipeline and stop all post processes
  109361. */
  109362. dispose(): void;
  109363. /**
  109364. * Serialize the rendering pipeline (Used when exporting)
  109365. * @returns the serialized object
  109366. */
  109367. serialize(): any;
  109368. /**
  109369. * Parse the serialized pipeline
  109370. * @param source Source pipeline.
  109371. * @param scene The scene to load the pipeline to.
  109372. * @param rootUrl The URL of the serialized pipeline.
  109373. * @returns An instantiated pipeline from the serialized object.
  109374. */
  109375. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  109376. }
  109377. }
  109378. declare module BABYLON {
  109379. /** @hidden */
  109380. export var lensHighlightsPixelShader: {
  109381. name: string;
  109382. shader: string;
  109383. };
  109384. }
  109385. declare module BABYLON {
  109386. /** @hidden */
  109387. export var depthOfFieldPixelShader: {
  109388. name: string;
  109389. shader: string;
  109390. };
  109391. }
  109392. declare module BABYLON {
  109393. /**
  109394. * BABYLON.JS Chromatic Aberration GLSL Shader
  109395. * Author: Olivier Guyot
  109396. * Separates very slightly R, G and B colors on the edges of the screen
  109397. * Inspired by Francois Tarlier & Martins Upitis
  109398. */
  109399. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  109400. /**
  109401. * @ignore
  109402. * The chromatic aberration PostProcess id in the pipeline
  109403. */
  109404. LensChromaticAberrationEffect: string;
  109405. /**
  109406. * @ignore
  109407. * The highlights enhancing PostProcess id in the pipeline
  109408. */
  109409. HighlightsEnhancingEffect: string;
  109410. /**
  109411. * @ignore
  109412. * The depth-of-field PostProcess id in the pipeline
  109413. */
  109414. LensDepthOfFieldEffect: string;
  109415. private _scene;
  109416. private _depthTexture;
  109417. private _grainTexture;
  109418. private _chromaticAberrationPostProcess;
  109419. private _highlightsPostProcess;
  109420. private _depthOfFieldPostProcess;
  109421. private _edgeBlur;
  109422. private _grainAmount;
  109423. private _chromaticAberration;
  109424. private _distortion;
  109425. private _highlightsGain;
  109426. private _highlightsThreshold;
  109427. private _dofDistance;
  109428. private _dofAperture;
  109429. private _dofDarken;
  109430. private _dofPentagon;
  109431. private _blurNoise;
  109432. /**
  109433. * @constructor
  109434. *
  109435. * Effect parameters are as follow:
  109436. * {
  109437. * chromatic_aberration: number; // from 0 to x (1 for realism)
  109438. * edge_blur: number; // from 0 to x (1 for realism)
  109439. * distortion: number; // from 0 to x (1 for realism)
  109440. * grain_amount: number; // from 0 to 1
  109441. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  109442. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  109443. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  109444. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  109445. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  109446. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  109447. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  109448. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  109449. * }
  109450. * Note: if an effect parameter is unset, effect is disabled
  109451. *
  109452. * @param name The rendering pipeline name
  109453. * @param parameters - An object containing all parameters (see above)
  109454. * @param scene The scene linked to this pipeline
  109455. * @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)
  109456. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109457. */
  109458. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  109459. /**
  109460. * Sets the amount of blur at the edges
  109461. * @param amount blur amount
  109462. */
  109463. setEdgeBlur(amount: number): void;
  109464. /**
  109465. * Sets edge blur to 0
  109466. */
  109467. disableEdgeBlur(): void;
  109468. /**
  109469. * Sets the amout of grain
  109470. * @param amount Amount of grain
  109471. */
  109472. setGrainAmount(amount: number): void;
  109473. /**
  109474. * Set grain amount to 0
  109475. */
  109476. disableGrain(): void;
  109477. /**
  109478. * Sets the chromatic aberration amount
  109479. * @param amount amount of chromatic aberration
  109480. */
  109481. setChromaticAberration(amount: number): void;
  109482. /**
  109483. * Sets chromatic aberration amount to 0
  109484. */
  109485. disableChromaticAberration(): void;
  109486. /**
  109487. * Sets the EdgeDistortion amount
  109488. * @param amount amount of EdgeDistortion
  109489. */
  109490. setEdgeDistortion(amount: number): void;
  109491. /**
  109492. * Sets edge distortion to 0
  109493. */
  109494. disableEdgeDistortion(): void;
  109495. /**
  109496. * Sets the FocusDistance amount
  109497. * @param amount amount of FocusDistance
  109498. */
  109499. setFocusDistance(amount: number): void;
  109500. /**
  109501. * Disables depth of field
  109502. */
  109503. disableDepthOfField(): void;
  109504. /**
  109505. * Sets the Aperture amount
  109506. * @param amount amount of Aperture
  109507. */
  109508. setAperture(amount: number): void;
  109509. /**
  109510. * Sets the DarkenOutOfFocus amount
  109511. * @param amount amount of DarkenOutOfFocus
  109512. */
  109513. setDarkenOutOfFocus(amount: number): void;
  109514. /**
  109515. * Creates a pentagon bokeh effect
  109516. */
  109517. enablePentagonBokeh(): void;
  109518. /**
  109519. * Disables the pentagon bokeh effect
  109520. */
  109521. disablePentagonBokeh(): void;
  109522. /**
  109523. * Enables noise blur
  109524. */
  109525. enableNoiseBlur(): void;
  109526. /**
  109527. * Disables noise blur
  109528. */
  109529. disableNoiseBlur(): void;
  109530. /**
  109531. * Sets the HighlightsGain amount
  109532. * @param amount amount of HighlightsGain
  109533. */
  109534. setHighlightsGain(amount: number): void;
  109535. /**
  109536. * Sets the HighlightsThreshold amount
  109537. * @param amount amount of HighlightsThreshold
  109538. */
  109539. setHighlightsThreshold(amount: number): void;
  109540. /**
  109541. * Disables highlights
  109542. */
  109543. disableHighlights(): void;
  109544. /**
  109545. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  109546. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  109547. */
  109548. dispose(disableDepthRender?: boolean): void;
  109549. private _createChromaticAberrationPostProcess;
  109550. private _createHighlightsPostProcess;
  109551. private _createDepthOfFieldPostProcess;
  109552. private _createGrainTexture;
  109553. }
  109554. }
  109555. declare module BABYLON {
  109556. /** @hidden */
  109557. export var ssao2PixelShader: {
  109558. name: string;
  109559. shader: string;
  109560. };
  109561. }
  109562. declare module BABYLON {
  109563. /** @hidden */
  109564. export var ssaoCombinePixelShader: {
  109565. name: string;
  109566. shader: string;
  109567. };
  109568. }
  109569. declare module BABYLON {
  109570. /**
  109571. * Render pipeline to produce ssao effect
  109572. */
  109573. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  109574. /**
  109575. * @ignore
  109576. * The PassPostProcess id in the pipeline that contains the original scene color
  109577. */
  109578. SSAOOriginalSceneColorEffect: string;
  109579. /**
  109580. * @ignore
  109581. * The SSAO PostProcess id in the pipeline
  109582. */
  109583. SSAORenderEffect: string;
  109584. /**
  109585. * @ignore
  109586. * The horizontal blur PostProcess id in the pipeline
  109587. */
  109588. SSAOBlurHRenderEffect: string;
  109589. /**
  109590. * @ignore
  109591. * The vertical blur PostProcess id in the pipeline
  109592. */
  109593. SSAOBlurVRenderEffect: string;
  109594. /**
  109595. * @ignore
  109596. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109597. */
  109598. SSAOCombineRenderEffect: string;
  109599. /**
  109600. * The output strength of the SSAO post-process. Default value is 1.0.
  109601. */
  109602. totalStrength: number;
  109603. /**
  109604. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  109605. */
  109606. maxZ: number;
  109607. /**
  109608. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  109609. */
  109610. minZAspect: number;
  109611. private _samples;
  109612. /**
  109613. * Number of samples used for the SSAO calculations. Default value is 8
  109614. */
  109615. samples: number;
  109616. private _textureSamples;
  109617. /**
  109618. * Number of samples to use for antialiasing
  109619. */
  109620. textureSamples: number;
  109621. /**
  109622. * Ratio object used for SSAO ratio and blur ratio
  109623. */
  109624. private _ratio;
  109625. /**
  109626. * Dynamically generated sphere sampler.
  109627. */
  109628. private _sampleSphere;
  109629. /**
  109630. * Blur filter offsets
  109631. */
  109632. private _samplerOffsets;
  109633. private _expensiveBlur;
  109634. /**
  109635. * If bilateral blur should be used
  109636. */
  109637. expensiveBlur: boolean;
  109638. /**
  109639. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  109640. */
  109641. radius: number;
  109642. /**
  109643. * The base color of the SSAO post-process
  109644. * The final result is "base + ssao" between [0, 1]
  109645. */
  109646. base: number;
  109647. /**
  109648. * Support test.
  109649. */
  109650. static readonly IsSupported: boolean;
  109651. private _scene;
  109652. private _depthTexture;
  109653. private _normalTexture;
  109654. private _randomTexture;
  109655. private _originalColorPostProcess;
  109656. private _ssaoPostProcess;
  109657. private _blurHPostProcess;
  109658. private _blurVPostProcess;
  109659. private _ssaoCombinePostProcess;
  109660. private _firstUpdate;
  109661. /**
  109662. * Gets active scene
  109663. */
  109664. readonly scene: Scene;
  109665. /**
  109666. * @constructor
  109667. * @param name The rendering pipeline name
  109668. * @param scene The scene linked to this pipeline
  109669. * @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 }
  109670. * @param cameras The array of cameras that the rendering pipeline will be attached to
  109671. */
  109672. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109673. /**
  109674. * Get the class name
  109675. * @returns "SSAO2RenderingPipeline"
  109676. */
  109677. getClassName(): string;
  109678. /**
  109679. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109680. */
  109681. dispose(disableGeometryBufferRenderer?: boolean): void;
  109682. private _createBlurPostProcess;
  109683. /** @hidden */
  109684. _rebuild(): void;
  109685. private _bits;
  109686. private _radicalInverse_VdC;
  109687. private _hammersley;
  109688. private _hemisphereSample_uniform;
  109689. private _generateHemisphere;
  109690. private _createSSAOPostProcess;
  109691. private _createSSAOCombinePostProcess;
  109692. private _createRandomTexture;
  109693. /**
  109694. * Serialize the rendering pipeline (Used when exporting)
  109695. * @returns the serialized object
  109696. */
  109697. serialize(): any;
  109698. /**
  109699. * Parse the serialized pipeline
  109700. * @param source Source pipeline.
  109701. * @param scene The scene to load the pipeline to.
  109702. * @param rootUrl The URL of the serialized pipeline.
  109703. * @returns An instantiated pipeline from the serialized object.
  109704. */
  109705. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  109706. }
  109707. }
  109708. declare module BABYLON {
  109709. /** @hidden */
  109710. export var ssaoPixelShader: {
  109711. name: string;
  109712. shader: string;
  109713. };
  109714. }
  109715. declare module BABYLON {
  109716. /**
  109717. * Render pipeline to produce ssao effect
  109718. */
  109719. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  109720. /**
  109721. * @ignore
  109722. * The PassPostProcess id in the pipeline that contains the original scene color
  109723. */
  109724. SSAOOriginalSceneColorEffect: string;
  109725. /**
  109726. * @ignore
  109727. * The SSAO PostProcess id in the pipeline
  109728. */
  109729. SSAORenderEffect: string;
  109730. /**
  109731. * @ignore
  109732. * The horizontal blur PostProcess id in the pipeline
  109733. */
  109734. SSAOBlurHRenderEffect: string;
  109735. /**
  109736. * @ignore
  109737. * The vertical blur PostProcess id in the pipeline
  109738. */
  109739. SSAOBlurVRenderEffect: string;
  109740. /**
  109741. * @ignore
  109742. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  109743. */
  109744. SSAOCombineRenderEffect: string;
  109745. /**
  109746. * The output strength of the SSAO post-process. Default value is 1.0.
  109747. */
  109748. totalStrength: number;
  109749. /**
  109750. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  109751. */
  109752. radius: number;
  109753. /**
  109754. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  109755. * Must not be equal to fallOff and superior to fallOff.
  109756. * Default value is 0.0075
  109757. */
  109758. area: number;
  109759. /**
  109760. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  109761. * Must not be equal to area and inferior to area.
  109762. * Default value is 0.000001
  109763. */
  109764. fallOff: number;
  109765. /**
  109766. * The base color of the SSAO post-process
  109767. * The final result is "base + ssao" between [0, 1]
  109768. */
  109769. base: number;
  109770. private _scene;
  109771. private _depthTexture;
  109772. private _randomTexture;
  109773. private _originalColorPostProcess;
  109774. private _ssaoPostProcess;
  109775. private _blurHPostProcess;
  109776. private _blurVPostProcess;
  109777. private _ssaoCombinePostProcess;
  109778. private _firstUpdate;
  109779. /**
  109780. * Gets active scene
  109781. */
  109782. readonly scene: Scene;
  109783. /**
  109784. * @constructor
  109785. * @param name - The rendering pipeline name
  109786. * @param scene - The scene linked to this pipeline
  109787. * @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 }
  109788. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  109789. */
  109790. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  109791. /**
  109792. * Get the class name
  109793. * @returns "SSAORenderingPipeline"
  109794. */
  109795. getClassName(): string;
  109796. /**
  109797. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  109798. */
  109799. dispose(disableDepthRender?: boolean): void;
  109800. private _createBlurPostProcess;
  109801. /** @hidden */
  109802. _rebuild(): void;
  109803. private _createSSAOPostProcess;
  109804. private _createSSAOCombinePostProcess;
  109805. private _createRandomTexture;
  109806. }
  109807. }
  109808. declare module BABYLON {
  109809. /** @hidden */
  109810. export var standardPixelShader: {
  109811. name: string;
  109812. shader: string;
  109813. };
  109814. }
  109815. declare module BABYLON {
  109816. /**
  109817. * Standard rendering pipeline
  109818. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  109819. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  109820. */
  109821. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  109822. /**
  109823. * Public members
  109824. */
  109825. /**
  109826. * Post-process which contains the original scene color before the pipeline applies all the effects
  109827. */
  109828. originalPostProcess: Nullable<PostProcess>;
  109829. /**
  109830. * Post-process used to down scale an image x4
  109831. */
  109832. downSampleX4PostProcess: Nullable<PostProcess>;
  109833. /**
  109834. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  109835. */
  109836. brightPassPostProcess: Nullable<PostProcess>;
  109837. /**
  109838. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  109839. */
  109840. blurHPostProcesses: PostProcess[];
  109841. /**
  109842. * Post-process array storing all the vertical blur post-processes used by the pipeline
  109843. */
  109844. blurVPostProcesses: PostProcess[];
  109845. /**
  109846. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  109847. */
  109848. textureAdderPostProcess: Nullable<PostProcess>;
  109849. /**
  109850. * Post-process used to create volumetric lighting effect
  109851. */
  109852. volumetricLightPostProcess: Nullable<PostProcess>;
  109853. /**
  109854. * Post-process used to smooth the previous volumetric light post-process on the X axis
  109855. */
  109856. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  109857. /**
  109858. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  109859. */
  109860. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  109861. /**
  109862. * Post-process used to merge the volumetric light effect and the real scene color
  109863. */
  109864. volumetricLightMergePostProces: Nullable<PostProcess>;
  109865. /**
  109866. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  109867. */
  109868. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  109869. /**
  109870. * Base post-process used to calculate the average luminance of the final image for HDR
  109871. */
  109872. luminancePostProcess: Nullable<PostProcess>;
  109873. /**
  109874. * Post-processes used to create down sample post-processes in order to get
  109875. * the average luminance of the final image for HDR
  109876. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  109877. */
  109878. luminanceDownSamplePostProcesses: PostProcess[];
  109879. /**
  109880. * Post-process used to create a HDR effect (light adaptation)
  109881. */
  109882. hdrPostProcess: Nullable<PostProcess>;
  109883. /**
  109884. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  109885. */
  109886. textureAdderFinalPostProcess: Nullable<PostProcess>;
  109887. /**
  109888. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  109889. */
  109890. lensFlareFinalPostProcess: Nullable<PostProcess>;
  109891. /**
  109892. * Post-process used to merge the final HDR post-process and the real scene color
  109893. */
  109894. hdrFinalPostProcess: Nullable<PostProcess>;
  109895. /**
  109896. * Post-process used to create a lens flare effect
  109897. */
  109898. lensFlarePostProcess: Nullable<PostProcess>;
  109899. /**
  109900. * Post-process that merges the result of the lens flare post-process and the real scene color
  109901. */
  109902. lensFlareComposePostProcess: Nullable<PostProcess>;
  109903. /**
  109904. * Post-process used to create a motion blur effect
  109905. */
  109906. motionBlurPostProcess: Nullable<PostProcess>;
  109907. /**
  109908. * Post-process used to create a depth of field effect
  109909. */
  109910. depthOfFieldPostProcess: Nullable<PostProcess>;
  109911. /**
  109912. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  109913. */
  109914. fxaaPostProcess: Nullable<FxaaPostProcess>;
  109915. /**
  109916. * Represents the brightness threshold in order to configure the illuminated surfaces
  109917. */
  109918. brightThreshold: number;
  109919. /**
  109920. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  109921. */
  109922. blurWidth: number;
  109923. /**
  109924. * Sets if the blur for highlighted surfaces must be only horizontal
  109925. */
  109926. horizontalBlur: boolean;
  109927. /**
  109928. * Sets the overall exposure used by the pipeline
  109929. */
  109930. exposure: number;
  109931. /**
  109932. * Texture used typically to simulate "dirty" on camera lens
  109933. */
  109934. lensTexture: Nullable<Texture>;
  109935. /**
  109936. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  109937. */
  109938. volumetricLightCoefficient: number;
  109939. /**
  109940. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  109941. */
  109942. volumetricLightPower: number;
  109943. /**
  109944. * Used the set the blur intensity to smooth the volumetric lights
  109945. */
  109946. volumetricLightBlurScale: number;
  109947. /**
  109948. * Light (spot or directional) used to generate the volumetric lights rays
  109949. * The source light must have a shadow generate so the pipeline can get its
  109950. * depth map
  109951. */
  109952. sourceLight: Nullable<SpotLight | DirectionalLight>;
  109953. /**
  109954. * For eye adaptation, represents the minimum luminance the eye can see
  109955. */
  109956. hdrMinimumLuminance: number;
  109957. /**
  109958. * For eye adaptation, represents the decrease luminance speed
  109959. */
  109960. hdrDecreaseRate: number;
  109961. /**
  109962. * For eye adaptation, represents the increase luminance speed
  109963. */
  109964. hdrIncreaseRate: number;
  109965. /**
  109966. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  109967. */
  109968. lensColorTexture: Nullable<Texture>;
  109969. /**
  109970. * The overall strengh for the lens flare effect
  109971. */
  109972. lensFlareStrength: number;
  109973. /**
  109974. * Dispersion coefficient for lens flare ghosts
  109975. */
  109976. lensFlareGhostDispersal: number;
  109977. /**
  109978. * Main lens flare halo width
  109979. */
  109980. lensFlareHaloWidth: number;
  109981. /**
  109982. * Based on the lens distortion effect, defines how much the lens flare result
  109983. * is distorted
  109984. */
  109985. lensFlareDistortionStrength: number;
  109986. /**
  109987. * Lens star texture must be used to simulate rays on the flares and is available
  109988. * in the documentation
  109989. */
  109990. lensStarTexture: Nullable<Texture>;
  109991. /**
  109992. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  109993. * flare effect by taking account of the dirt texture
  109994. */
  109995. lensFlareDirtTexture: Nullable<Texture>;
  109996. /**
  109997. * Represents the focal length for the depth of field effect
  109998. */
  109999. depthOfFieldDistance: number;
  110000. /**
  110001. * Represents the blur intensity for the blurred part of the depth of field effect
  110002. */
  110003. depthOfFieldBlurWidth: number;
  110004. /**
  110005. * For motion blur, defines how much the image is blurred by the movement
  110006. */
  110007. motionStrength: number;
  110008. /**
  110009. * List of animations for the pipeline (IAnimatable implementation)
  110010. */
  110011. animations: Animation[];
  110012. /**
  110013. * Private members
  110014. */
  110015. private _scene;
  110016. private _currentDepthOfFieldSource;
  110017. private _basePostProcess;
  110018. private _hdrCurrentLuminance;
  110019. private _floatTextureType;
  110020. private _ratio;
  110021. private _bloomEnabled;
  110022. private _depthOfFieldEnabled;
  110023. private _vlsEnabled;
  110024. private _lensFlareEnabled;
  110025. private _hdrEnabled;
  110026. private _motionBlurEnabled;
  110027. private _fxaaEnabled;
  110028. private _motionBlurSamples;
  110029. private _volumetricLightStepsCount;
  110030. private _samples;
  110031. /**
  110032. * @ignore
  110033. * Specifies if the bloom pipeline is enabled
  110034. */
  110035. BloomEnabled: boolean;
  110036. /**
  110037. * @ignore
  110038. * Specifies if the depth of field pipeline is enabed
  110039. */
  110040. DepthOfFieldEnabled: boolean;
  110041. /**
  110042. * @ignore
  110043. * Specifies if the lens flare pipeline is enabed
  110044. */
  110045. LensFlareEnabled: boolean;
  110046. /**
  110047. * @ignore
  110048. * Specifies if the HDR pipeline is enabled
  110049. */
  110050. HDREnabled: boolean;
  110051. /**
  110052. * @ignore
  110053. * Specifies if the volumetric lights scattering effect is enabled
  110054. */
  110055. VLSEnabled: boolean;
  110056. /**
  110057. * @ignore
  110058. * Specifies if the motion blur effect is enabled
  110059. */
  110060. MotionBlurEnabled: boolean;
  110061. /**
  110062. * Specifies if anti-aliasing is enabled
  110063. */
  110064. fxaaEnabled: boolean;
  110065. /**
  110066. * Specifies the number of steps used to calculate the volumetric lights
  110067. * Typically in interval [50, 200]
  110068. */
  110069. volumetricLightStepsCount: number;
  110070. /**
  110071. * Specifies the number of samples used for the motion blur effect
  110072. * Typically in interval [16, 64]
  110073. */
  110074. motionBlurSamples: number;
  110075. /**
  110076. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110077. */
  110078. samples: number;
  110079. /**
  110080. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  110081. * @constructor
  110082. * @param name The rendering pipeline name
  110083. * @param scene The scene linked to this pipeline
  110084. * @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)
  110085. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  110086. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110087. */
  110088. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  110089. private _buildPipeline;
  110090. private _createDownSampleX4PostProcess;
  110091. private _createBrightPassPostProcess;
  110092. private _createBlurPostProcesses;
  110093. private _createTextureAdderPostProcess;
  110094. private _createVolumetricLightPostProcess;
  110095. private _createLuminancePostProcesses;
  110096. private _createHdrPostProcess;
  110097. private _createLensFlarePostProcess;
  110098. private _createDepthOfFieldPostProcess;
  110099. private _createMotionBlurPostProcess;
  110100. private _getDepthTexture;
  110101. private _disposePostProcesses;
  110102. /**
  110103. * Dispose of the pipeline and stop all post processes
  110104. */
  110105. dispose(): void;
  110106. /**
  110107. * Serialize the rendering pipeline (Used when exporting)
  110108. * @returns the serialized object
  110109. */
  110110. serialize(): any;
  110111. /**
  110112. * Parse the serialized pipeline
  110113. * @param source Source pipeline.
  110114. * @param scene The scene to load the pipeline to.
  110115. * @param rootUrl The URL of the serialized pipeline.
  110116. * @returns An instantiated pipeline from the serialized object.
  110117. */
  110118. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  110119. /**
  110120. * Luminance steps
  110121. */
  110122. static LuminanceSteps: number;
  110123. }
  110124. }
  110125. declare module BABYLON {
  110126. /** @hidden */
  110127. export var tonemapPixelShader: {
  110128. name: string;
  110129. shader: string;
  110130. };
  110131. }
  110132. declare module BABYLON {
  110133. /** Defines operator used for tonemapping */
  110134. export enum TonemappingOperator {
  110135. /** Hable */
  110136. Hable = 0,
  110137. /** Reinhard */
  110138. Reinhard = 1,
  110139. /** HejiDawson */
  110140. HejiDawson = 2,
  110141. /** Photographic */
  110142. Photographic = 3
  110143. }
  110144. /**
  110145. * Defines a post process to apply tone mapping
  110146. */
  110147. export class TonemapPostProcess extends PostProcess {
  110148. private _operator;
  110149. /** Defines the required exposure adjustement */
  110150. exposureAdjustment: number;
  110151. /**
  110152. * Creates a new TonemapPostProcess
  110153. * @param name defines the name of the postprocess
  110154. * @param _operator defines the operator to use
  110155. * @param exposureAdjustment defines the required exposure adjustement
  110156. * @param camera defines the camera to use (can be null)
  110157. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  110158. * @param engine defines the hosting engine (can be ignore if camera is set)
  110159. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  110160. */
  110161. constructor(name: string, _operator: TonemappingOperator,
  110162. /** Defines the required exposure adjustement */
  110163. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  110164. }
  110165. }
  110166. declare module BABYLON {
  110167. /** @hidden */
  110168. export var depthVertexShader: {
  110169. name: string;
  110170. shader: string;
  110171. };
  110172. }
  110173. declare module BABYLON {
  110174. /** @hidden */
  110175. export var volumetricLightScatteringPixelShader: {
  110176. name: string;
  110177. shader: string;
  110178. };
  110179. }
  110180. declare module BABYLON {
  110181. /** @hidden */
  110182. export var volumetricLightScatteringPassPixelShader: {
  110183. name: string;
  110184. shader: string;
  110185. };
  110186. }
  110187. declare module BABYLON {
  110188. /**
  110189. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  110190. */
  110191. export class VolumetricLightScatteringPostProcess extends PostProcess {
  110192. private _volumetricLightScatteringPass;
  110193. private _volumetricLightScatteringRTT;
  110194. private _viewPort;
  110195. private _screenCoordinates;
  110196. private _cachedDefines;
  110197. /**
  110198. * If not undefined, the mesh position is computed from the attached node position
  110199. */
  110200. attachedNode: {
  110201. position: Vector3;
  110202. };
  110203. /**
  110204. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  110205. */
  110206. customMeshPosition: Vector3;
  110207. /**
  110208. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  110209. */
  110210. useCustomMeshPosition: boolean;
  110211. /**
  110212. * If the post-process should inverse the light scattering direction
  110213. */
  110214. invert: boolean;
  110215. /**
  110216. * The internal mesh used by the post-process
  110217. */
  110218. mesh: Mesh;
  110219. /**
  110220. * @hidden
  110221. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  110222. */
  110223. useDiffuseColor: boolean;
  110224. /**
  110225. * Array containing the excluded meshes not rendered in the internal pass
  110226. */
  110227. excludedMeshes: AbstractMesh[];
  110228. /**
  110229. * Controls the overall intensity of the post-process
  110230. */
  110231. exposure: number;
  110232. /**
  110233. * Dissipates each sample's contribution in range [0, 1]
  110234. */
  110235. decay: number;
  110236. /**
  110237. * Controls the overall intensity of each sample
  110238. */
  110239. weight: number;
  110240. /**
  110241. * Controls the density of each sample
  110242. */
  110243. density: number;
  110244. /**
  110245. * @constructor
  110246. * @param name The post-process name
  110247. * @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)
  110248. * @param camera The camera that the post-process will be attached to
  110249. * @param mesh The mesh used to create the light scattering
  110250. * @param samples The post-process quality, default 100
  110251. * @param samplingModeThe post-process filtering mode
  110252. * @param engine The babylon engine
  110253. * @param reusable If the post-process is reusable
  110254. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  110255. */
  110256. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  110257. /**
  110258. * Returns the string "VolumetricLightScatteringPostProcess"
  110259. * @returns "VolumetricLightScatteringPostProcess"
  110260. */
  110261. getClassName(): string;
  110262. private _isReady;
  110263. /**
  110264. * Sets the new light position for light scattering effect
  110265. * @param position The new custom light position
  110266. */
  110267. setCustomMeshPosition(position: Vector3): void;
  110268. /**
  110269. * Returns the light position for light scattering effect
  110270. * @return Vector3 The custom light position
  110271. */
  110272. getCustomMeshPosition(): Vector3;
  110273. /**
  110274. * Disposes the internal assets and detaches the post-process from the camera
  110275. */
  110276. dispose(camera: Camera): void;
  110277. /**
  110278. * Returns the render target texture used by the post-process
  110279. * @return the render target texture used by the post-process
  110280. */
  110281. getPass(): RenderTargetTexture;
  110282. private _meshExcluded;
  110283. private _createPass;
  110284. private _updateMeshScreenCoordinates;
  110285. /**
  110286. * Creates a default mesh for the Volumeric Light Scattering post-process
  110287. * @param name The mesh name
  110288. * @param scene The scene where to create the mesh
  110289. * @return the default mesh
  110290. */
  110291. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  110292. }
  110293. }
  110294. declare module BABYLON {
  110295. interface Scene {
  110296. /** @hidden (Backing field) */
  110297. _boundingBoxRenderer: BoundingBoxRenderer;
  110298. /** @hidden (Backing field) */
  110299. _forceShowBoundingBoxes: boolean;
  110300. /**
  110301. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  110302. */
  110303. forceShowBoundingBoxes: boolean;
  110304. /**
  110305. * Gets the bounding box renderer associated with the scene
  110306. * @returns a BoundingBoxRenderer
  110307. */
  110308. getBoundingBoxRenderer(): BoundingBoxRenderer;
  110309. }
  110310. interface AbstractMesh {
  110311. /** @hidden (Backing field) */
  110312. _showBoundingBox: boolean;
  110313. /**
  110314. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  110315. */
  110316. showBoundingBox: boolean;
  110317. }
  110318. /**
  110319. * Component responsible of rendering the bounding box of the meshes in a scene.
  110320. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  110321. */
  110322. export class BoundingBoxRenderer implements ISceneComponent {
  110323. /**
  110324. * The component name helpfull to identify the component in the list of scene components.
  110325. */
  110326. readonly name: string;
  110327. /**
  110328. * The scene the component belongs to.
  110329. */
  110330. scene: Scene;
  110331. /**
  110332. * Color of the bounding box lines placed in front of an object
  110333. */
  110334. frontColor: Color3;
  110335. /**
  110336. * Color of the bounding box lines placed behind an object
  110337. */
  110338. backColor: Color3;
  110339. /**
  110340. * Defines if the renderer should show the back lines or not
  110341. */
  110342. showBackLines: boolean;
  110343. /**
  110344. * @hidden
  110345. */
  110346. renderList: SmartArray<BoundingBox>;
  110347. private _colorShader;
  110348. private _vertexBuffers;
  110349. private _indexBuffer;
  110350. /**
  110351. * Instantiates a new bounding box renderer in a scene.
  110352. * @param scene the scene the renderer renders in
  110353. */
  110354. constructor(scene: Scene);
  110355. /**
  110356. * Registers the component in a given scene
  110357. */
  110358. register(): void;
  110359. private _evaluateSubMesh;
  110360. private _activeMesh;
  110361. private _prepareRessources;
  110362. private _createIndexBuffer;
  110363. /**
  110364. * Rebuilds the elements related to this component in case of
  110365. * context lost for instance.
  110366. */
  110367. rebuild(): void;
  110368. /**
  110369. * @hidden
  110370. */
  110371. reset(): void;
  110372. /**
  110373. * Render the bounding boxes of a specific rendering group
  110374. * @param renderingGroupId defines the rendering group to render
  110375. */
  110376. render(renderingGroupId: number): void;
  110377. /**
  110378. * In case of occlusion queries, we can render the occlusion bounding box through this method
  110379. * @param mesh Define the mesh to render the occlusion bounding box for
  110380. */
  110381. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  110382. /**
  110383. * Dispose and release the resources attached to this renderer.
  110384. */
  110385. dispose(): void;
  110386. }
  110387. }
  110388. declare module BABYLON {
  110389. /** @hidden */
  110390. export var depthPixelShader: {
  110391. name: string;
  110392. shader: string;
  110393. };
  110394. }
  110395. declare module BABYLON {
  110396. /**
  110397. * This represents a depth renderer in Babylon.
  110398. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  110399. */
  110400. export class DepthRenderer {
  110401. private _scene;
  110402. private _depthMap;
  110403. private _effect;
  110404. private _cachedDefines;
  110405. private _camera;
  110406. /**
  110407. * Specifiess that the depth renderer will only be used within
  110408. * the camera it is created for.
  110409. * This can help forcing its rendering during the camera processing.
  110410. */
  110411. useOnlyInActiveCamera: boolean;
  110412. /** @hidden */
  110413. static _SceneComponentInitialization: (scene: Scene) => void;
  110414. /**
  110415. * Instantiates a depth renderer
  110416. * @param scene The scene the renderer belongs to
  110417. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  110418. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  110419. */
  110420. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  110421. /**
  110422. * Creates the depth rendering effect and checks if the effect is ready.
  110423. * @param subMesh The submesh to be used to render the depth map of
  110424. * @param useInstances If multiple world instances should be used
  110425. * @returns if the depth renderer is ready to render the depth map
  110426. */
  110427. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110428. /**
  110429. * Gets the texture which the depth map will be written to.
  110430. * @returns The depth map texture
  110431. */
  110432. getDepthMap(): RenderTargetTexture;
  110433. /**
  110434. * Disposes of the depth renderer.
  110435. */
  110436. dispose(): void;
  110437. }
  110438. }
  110439. declare module BABYLON {
  110440. interface Scene {
  110441. /** @hidden (Backing field) */
  110442. _depthRenderer: {
  110443. [id: string]: DepthRenderer;
  110444. };
  110445. /**
  110446. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  110447. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  110448. * @returns the created depth renderer
  110449. */
  110450. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  110451. /**
  110452. * Disables a depth renderer for a given camera
  110453. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  110454. */
  110455. disableDepthRenderer(camera?: Nullable<Camera>): void;
  110456. }
  110457. /**
  110458. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  110459. * in several rendering techniques.
  110460. */
  110461. export class DepthRendererSceneComponent implements ISceneComponent {
  110462. /**
  110463. * The component name helpfull to identify the component in the list of scene components.
  110464. */
  110465. readonly name: string;
  110466. /**
  110467. * The scene the component belongs to.
  110468. */
  110469. scene: Scene;
  110470. /**
  110471. * Creates a new instance of the component for the given scene
  110472. * @param scene Defines the scene to register the component in
  110473. */
  110474. constructor(scene: Scene);
  110475. /**
  110476. * Registers the component in a given scene
  110477. */
  110478. register(): void;
  110479. /**
  110480. * Rebuilds the elements related to this component in case of
  110481. * context lost for instance.
  110482. */
  110483. rebuild(): void;
  110484. /**
  110485. * Disposes the component and the associated ressources
  110486. */
  110487. dispose(): void;
  110488. private _gatherRenderTargets;
  110489. private _gatherActiveCameraRenderTargets;
  110490. }
  110491. }
  110492. declare module BABYLON {
  110493. /** @hidden */
  110494. export var outlinePixelShader: {
  110495. name: string;
  110496. shader: string;
  110497. };
  110498. }
  110499. declare module BABYLON {
  110500. /** @hidden */
  110501. export var outlineVertexShader: {
  110502. name: string;
  110503. shader: string;
  110504. };
  110505. }
  110506. declare module BABYLON {
  110507. interface Scene {
  110508. /** @hidden */
  110509. _outlineRenderer: OutlineRenderer;
  110510. /**
  110511. * Gets the outline renderer associated with the scene
  110512. * @returns a OutlineRenderer
  110513. */
  110514. getOutlineRenderer(): OutlineRenderer;
  110515. }
  110516. interface AbstractMesh {
  110517. /** @hidden (Backing field) */
  110518. _renderOutline: boolean;
  110519. /**
  110520. * Gets or sets a boolean indicating if the outline must be rendered as well
  110521. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  110522. */
  110523. renderOutline: boolean;
  110524. /** @hidden (Backing field) */
  110525. _renderOverlay: boolean;
  110526. /**
  110527. * Gets or sets a boolean indicating if the overlay must be rendered as well
  110528. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  110529. */
  110530. renderOverlay: boolean;
  110531. }
  110532. /**
  110533. * This class is responsible to draw bothe outline/overlay of meshes.
  110534. * It should not be used directly but through the available method on mesh.
  110535. */
  110536. export class OutlineRenderer implements ISceneComponent {
  110537. /**
  110538. * The name of the component. Each component must have a unique name.
  110539. */
  110540. name: string;
  110541. /**
  110542. * The scene the component belongs to.
  110543. */
  110544. scene: Scene;
  110545. /**
  110546. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  110547. */
  110548. zOffset: number;
  110549. private _engine;
  110550. private _effect;
  110551. private _cachedDefines;
  110552. private _savedDepthWrite;
  110553. /**
  110554. * Instantiates a new outline renderer. (There could be only one per scene).
  110555. * @param scene Defines the scene it belongs to
  110556. */
  110557. constructor(scene: Scene);
  110558. /**
  110559. * Register the component to one instance of a scene.
  110560. */
  110561. register(): void;
  110562. /**
  110563. * Rebuilds the elements related to this component in case of
  110564. * context lost for instance.
  110565. */
  110566. rebuild(): void;
  110567. /**
  110568. * Disposes the component and the associated ressources.
  110569. */
  110570. dispose(): void;
  110571. /**
  110572. * Renders the outline in the canvas.
  110573. * @param subMesh Defines the sumesh to render
  110574. * @param batch Defines the batch of meshes in case of instances
  110575. * @param useOverlay Defines if the rendering is for the overlay or the outline
  110576. */
  110577. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  110578. /**
  110579. * Returns whether or not the outline renderer is ready for a given submesh.
  110580. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  110581. * @param subMesh Defines the submesh to check readyness for
  110582. * @param useInstances Defines wheter wee are trying to render instances or not
  110583. * @returns true if ready otherwise false
  110584. */
  110585. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110586. private _beforeRenderingMesh;
  110587. private _afterRenderingMesh;
  110588. }
  110589. }
  110590. declare module BABYLON {
  110591. /**
  110592. * Defines the list of states available for a task inside a AssetsManager
  110593. */
  110594. export enum AssetTaskState {
  110595. /**
  110596. * Initialization
  110597. */
  110598. INIT = 0,
  110599. /**
  110600. * Running
  110601. */
  110602. RUNNING = 1,
  110603. /**
  110604. * Done
  110605. */
  110606. DONE = 2,
  110607. /**
  110608. * Error
  110609. */
  110610. ERROR = 3
  110611. }
  110612. /**
  110613. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  110614. */
  110615. export abstract class AbstractAssetTask {
  110616. /**
  110617. * Task name
  110618. */ name: string;
  110619. /**
  110620. * Callback called when the task is successful
  110621. */
  110622. onSuccess: (task: any) => void;
  110623. /**
  110624. * Callback called when the task is not successful
  110625. */
  110626. onError: (task: any, message?: string, exception?: any) => void;
  110627. /**
  110628. * Creates a new AssetsManager
  110629. * @param name defines the name of the task
  110630. */
  110631. constructor(
  110632. /**
  110633. * Task name
  110634. */ name: string);
  110635. private _isCompleted;
  110636. private _taskState;
  110637. private _errorObject;
  110638. /**
  110639. * Get if the task is completed
  110640. */
  110641. readonly isCompleted: boolean;
  110642. /**
  110643. * Gets the current state of the task
  110644. */
  110645. readonly taskState: AssetTaskState;
  110646. /**
  110647. * Gets the current error object (if task is in error)
  110648. */
  110649. readonly errorObject: {
  110650. message?: string;
  110651. exception?: any;
  110652. };
  110653. /**
  110654. * Internal only
  110655. * @hidden
  110656. */
  110657. _setErrorObject(message?: string, exception?: any): void;
  110658. /**
  110659. * Execute the current task
  110660. * @param scene defines the scene where you want your assets to be loaded
  110661. * @param onSuccess is a callback called when the task is successfully executed
  110662. * @param onError is a callback called if an error occurs
  110663. */
  110664. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110665. /**
  110666. * Execute the current task
  110667. * @param scene defines the scene where you want your assets to be loaded
  110668. * @param onSuccess is a callback called when the task is successfully executed
  110669. * @param onError is a callback called if an error occurs
  110670. */
  110671. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110672. /**
  110673. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  110674. * This can be used with failed tasks that have the reason for failure fixed.
  110675. */
  110676. reset(): void;
  110677. private onErrorCallback;
  110678. private onDoneCallback;
  110679. }
  110680. /**
  110681. * Define the interface used by progress events raised during assets loading
  110682. */
  110683. export interface IAssetsProgressEvent {
  110684. /**
  110685. * Defines the number of remaining tasks to process
  110686. */
  110687. remainingCount: number;
  110688. /**
  110689. * Defines the total number of tasks
  110690. */
  110691. totalCount: number;
  110692. /**
  110693. * Defines the task that was just processed
  110694. */
  110695. task: AbstractAssetTask;
  110696. }
  110697. /**
  110698. * Class used to share progress information about assets loading
  110699. */
  110700. export class AssetsProgressEvent implements IAssetsProgressEvent {
  110701. /**
  110702. * Defines the number of remaining tasks to process
  110703. */
  110704. remainingCount: number;
  110705. /**
  110706. * Defines the total number of tasks
  110707. */
  110708. totalCount: number;
  110709. /**
  110710. * Defines the task that was just processed
  110711. */
  110712. task: AbstractAssetTask;
  110713. /**
  110714. * Creates a AssetsProgressEvent
  110715. * @param remainingCount defines the number of remaining tasks to process
  110716. * @param totalCount defines the total number of tasks
  110717. * @param task defines the task that was just processed
  110718. */
  110719. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  110720. }
  110721. /**
  110722. * Define a task used by AssetsManager to load meshes
  110723. */
  110724. export class MeshAssetTask extends AbstractAssetTask {
  110725. /**
  110726. * Defines the name of the task
  110727. */
  110728. name: string;
  110729. /**
  110730. * Defines the list of mesh's names you want to load
  110731. */
  110732. meshesNames: any;
  110733. /**
  110734. * Defines the root url to use as a base to load your meshes and associated resources
  110735. */
  110736. rootUrl: string;
  110737. /**
  110738. * Defines the filename of the scene to load from
  110739. */
  110740. sceneFilename: string;
  110741. /**
  110742. * Gets the list of loaded meshes
  110743. */
  110744. loadedMeshes: Array<AbstractMesh>;
  110745. /**
  110746. * Gets the list of loaded particle systems
  110747. */
  110748. loadedParticleSystems: Array<IParticleSystem>;
  110749. /**
  110750. * Gets the list of loaded skeletons
  110751. */
  110752. loadedSkeletons: Array<Skeleton>;
  110753. /**
  110754. * Gets the list of loaded animation groups
  110755. */
  110756. loadedAnimationGroups: Array<AnimationGroup>;
  110757. /**
  110758. * Callback called when the task is successful
  110759. */
  110760. onSuccess: (task: MeshAssetTask) => void;
  110761. /**
  110762. * Callback called when the task is successful
  110763. */
  110764. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  110765. /**
  110766. * Creates a new MeshAssetTask
  110767. * @param name defines the name of the task
  110768. * @param meshesNames defines the list of mesh's names you want to load
  110769. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  110770. * @param sceneFilename defines the filename of the scene to load from
  110771. */
  110772. constructor(
  110773. /**
  110774. * Defines the name of the task
  110775. */
  110776. name: string,
  110777. /**
  110778. * Defines the list of mesh's names you want to load
  110779. */
  110780. meshesNames: any,
  110781. /**
  110782. * Defines the root url to use as a base to load your meshes and associated resources
  110783. */
  110784. rootUrl: string,
  110785. /**
  110786. * Defines the filename of the scene to load from
  110787. */
  110788. sceneFilename: string);
  110789. /**
  110790. * Execute the current task
  110791. * @param scene defines the scene where you want your assets to be loaded
  110792. * @param onSuccess is a callback called when the task is successfully executed
  110793. * @param onError is a callback called if an error occurs
  110794. */
  110795. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110796. }
  110797. /**
  110798. * Define a task used by AssetsManager to load text content
  110799. */
  110800. export class TextFileAssetTask extends AbstractAssetTask {
  110801. /**
  110802. * Defines the name of the task
  110803. */
  110804. name: string;
  110805. /**
  110806. * Defines the location of the file to load
  110807. */
  110808. url: string;
  110809. /**
  110810. * Gets the loaded text string
  110811. */
  110812. text: string;
  110813. /**
  110814. * Callback called when the task is successful
  110815. */
  110816. onSuccess: (task: TextFileAssetTask) => void;
  110817. /**
  110818. * Callback called when the task is successful
  110819. */
  110820. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  110821. /**
  110822. * Creates a new TextFileAssetTask object
  110823. * @param name defines the name of the task
  110824. * @param url defines the location of the file to load
  110825. */
  110826. constructor(
  110827. /**
  110828. * Defines the name of the task
  110829. */
  110830. name: string,
  110831. /**
  110832. * Defines the location of the file to load
  110833. */
  110834. url: string);
  110835. /**
  110836. * Execute the current task
  110837. * @param scene defines the scene where you want your assets to be loaded
  110838. * @param onSuccess is a callback called when the task is successfully executed
  110839. * @param onError is a callback called if an error occurs
  110840. */
  110841. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110842. }
  110843. /**
  110844. * Define a task used by AssetsManager to load binary data
  110845. */
  110846. export class BinaryFileAssetTask extends AbstractAssetTask {
  110847. /**
  110848. * Defines the name of the task
  110849. */
  110850. name: string;
  110851. /**
  110852. * Defines the location of the file to load
  110853. */
  110854. url: string;
  110855. /**
  110856. * Gets the lodaded data (as an array buffer)
  110857. */
  110858. data: ArrayBuffer;
  110859. /**
  110860. * Callback called when the task is successful
  110861. */
  110862. onSuccess: (task: BinaryFileAssetTask) => void;
  110863. /**
  110864. * Callback called when the task is successful
  110865. */
  110866. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  110867. /**
  110868. * Creates a new BinaryFileAssetTask object
  110869. * @param name defines the name of the new task
  110870. * @param url defines the location of the file to load
  110871. */
  110872. constructor(
  110873. /**
  110874. * Defines the name of the task
  110875. */
  110876. name: string,
  110877. /**
  110878. * Defines the location of the file to load
  110879. */
  110880. url: string);
  110881. /**
  110882. * Execute the current task
  110883. * @param scene defines the scene where you want your assets to be loaded
  110884. * @param onSuccess is a callback called when the task is successfully executed
  110885. * @param onError is a callback called if an error occurs
  110886. */
  110887. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110888. }
  110889. /**
  110890. * Define a task used by AssetsManager to load images
  110891. */
  110892. export class ImageAssetTask extends AbstractAssetTask {
  110893. /**
  110894. * Defines the name of the task
  110895. */
  110896. name: string;
  110897. /**
  110898. * Defines the location of the image to load
  110899. */
  110900. url: string;
  110901. /**
  110902. * Gets the loaded images
  110903. */
  110904. image: HTMLImageElement;
  110905. /**
  110906. * Callback called when the task is successful
  110907. */
  110908. onSuccess: (task: ImageAssetTask) => void;
  110909. /**
  110910. * Callback called when the task is successful
  110911. */
  110912. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  110913. /**
  110914. * Creates a new ImageAssetTask
  110915. * @param name defines the name of the task
  110916. * @param url defines the location of the image to load
  110917. */
  110918. constructor(
  110919. /**
  110920. * Defines the name of the task
  110921. */
  110922. name: string,
  110923. /**
  110924. * Defines the location of the image to load
  110925. */
  110926. url: string);
  110927. /**
  110928. * Execute the current task
  110929. * @param scene defines the scene where you want your assets to be loaded
  110930. * @param onSuccess is a callback called when the task is successfully executed
  110931. * @param onError is a callback called if an error occurs
  110932. */
  110933. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  110934. }
  110935. /**
  110936. * Defines the interface used by texture loading tasks
  110937. */
  110938. export interface ITextureAssetTask<TEX extends BaseTexture> {
  110939. /**
  110940. * Gets the loaded texture
  110941. */
  110942. texture: TEX;
  110943. }
  110944. /**
  110945. * Define a task used by AssetsManager to load 2D textures
  110946. */
  110947. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  110948. /**
  110949. * Defines the name of the task
  110950. */
  110951. name: string;
  110952. /**
  110953. * Defines the location of the file to load
  110954. */
  110955. url: string;
  110956. /**
  110957. * Defines if mipmap should not be generated (default is false)
  110958. */
  110959. noMipmap?: boolean | undefined;
  110960. /**
  110961. * Defines if texture must be inverted on Y axis (default is false)
  110962. */
  110963. invertY?: boolean | undefined;
  110964. /**
  110965. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110966. */
  110967. samplingMode: number;
  110968. /**
  110969. * Gets the loaded texture
  110970. */
  110971. texture: Texture;
  110972. /**
  110973. * Callback called when the task is successful
  110974. */
  110975. onSuccess: (task: TextureAssetTask) => void;
  110976. /**
  110977. * Callback called when the task is successful
  110978. */
  110979. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  110980. /**
  110981. * Creates a new TextureAssetTask object
  110982. * @param name defines the name of the task
  110983. * @param url defines the location of the file to load
  110984. * @param noMipmap defines if mipmap should not be generated (default is false)
  110985. * @param invertY defines if texture must be inverted on Y axis (default is false)
  110986. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  110987. */
  110988. constructor(
  110989. /**
  110990. * Defines the name of the task
  110991. */
  110992. name: string,
  110993. /**
  110994. * Defines the location of the file to load
  110995. */
  110996. url: string,
  110997. /**
  110998. * Defines if mipmap should not be generated (default is false)
  110999. */
  111000. noMipmap?: boolean | undefined,
  111001. /**
  111002. * Defines if texture must be inverted on Y axis (default is false)
  111003. */
  111004. invertY?: boolean | undefined,
  111005. /**
  111006. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  111007. */
  111008. samplingMode?: number);
  111009. /**
  111010. * Execute the current task
  111011. * @param scene defines the scene where you want your assets to be loaded
  111012. * @param onSuccess is a callback called when the task is successfully executed
  111013. * @param onError is a callback called if an error occurs
  111014. */
  111015. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111016. }
  111017. /**
  111018. * Define a task used by AssetsManager to load cube textures
  111019. */
  111020. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  111021. /**
  111022. * Defines the name of the task
  111023. */
  111024. name: string;
  111025. /**
  111026. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111027. */
  111028. url: string;
  111029. /**
  111030. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111031. */
  111032. extensions?: string[] | undefined;
  111033. /**
  111034. * Defines if mipmaps should not be generated (default is false)
  111035. */
  111036. noMipmap?: boolean | undefined;
  111037. /**
  111038. * Defines the explicit list of files (undefined by default)
  111039. */
  111040. files?: string[] | undefined;
  111041. /**
  111042. * Gets the loaded texture
  111043. */
  111044. texture: CubeTexture;
  111045. /**
  111046. * Callback called when the task is successful
  111047. */
  111048. onSuccess: (task: CubeTextureAssetTask) => void;
  111049. /**
  111050. * Callback called when the task is successful
  111051. */
  111052. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  111053. /**
  111054. * Creates a new CubeTextureAssetTask
  111055. * @param name defines the name of the task
  111056. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111057. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111058. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111059. * @param files defines the explicit list of files (undefined by default)
  111060. */
  111061. constructor(
  111062. /**
  111063. * Defines the name of the task
  111064. */
  111065. name: string,
  111066. /**
  111067. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  111068. */
  111069. url: string,
  111070. /**
  111071. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  111072. */
  111073. extensions?: string[] | undefined,
  111074. /**
  111075. * Defines if mipmaps should not be generated (default is false)
  111076. */
  111077. noMipmap?: boolean | undefined,
  111078. /**
  111079. * Defines the explicit list of files (undefined by default)
  111080. */
  111081. files?: string[] | undefined);
  111082. /**
  111083. * Execute the current task
  111084. * @param scene defines the scene where you want your assets to be loaded
  111085. * @param onSuccess is a callback called when the task is successfully executed
  111086. * @param onError is a callback called if an error occurs
  111087. */
  111088. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111089. }
  111090. /**
  111091. * Define a task used by AssetsManager to load HDR cube textures
  111092. */
  111093. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  111094. /**
  111095. * Defines the name of the task
  111096. */
  111097. name: string;
  111098. /**
  111099. * Defines the location of the file to load
  111100. */
  111101. url: string;
  111102. /**
  111103. * Defines the desired size (the more it increases the longer the generation will be)
  111104. */
  111105. size: number;
  111106. /**
  111107. * Defines if mipmaps should not be generated (default is false)
  111108. */
  111109. noMipmap: boolean;
  111110. /**
  111111. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111112. */
  111113. generateHarmonics: boolean;
  111114. /**
  111115. * 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)
  111116. */
  111117. gammaSpace: boolean;
  111118. /**
  111119. * Internal Use Only
  111120. */
  111121. reserved: boolean;
  111122. /**
  111123. * Gets the loaded texture
  111124. */
  111125. texture: HDRCubeTexture;
  111126. /**
  111127. * Callback called when the task is successful
  111128. */
  111129. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  111130. /**
  111131. * Callback called when the task is successful
  111132. */
  111133. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  111134. /**
  111135. * Creates a new HDRCubeTextureAssetTask object
  111136. * @param name defines the name of the task
  111137. * @param url defines the location of the file to load
  111138. * @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.
  111139. * @param noMipmap defines if mipmaps should not be generated (default is false)
  111140. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111141. * @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)
  111142. * @param reserved Internal use only
  111143. */
  111144. constructor(
  111145. /**
  111146. * Defines the name of the task
  111147. */
  111148. name: string,
  111149. /**
  111150. * Defines the location of the file to load
  111151. */
  111152. url: string,
  111153. /**
  111154. * Defines the desired size (the more it increases the longer the generation will be)
  111155. */
  111156. size: number,
  111157. /**
  111158. * Defines if mipmaps should not be generated (default is false)
  111159. */
  111160. noMipmap?: boolean,
  111161. /**
  111162. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  111163. */
  111164. generateHarmonics?: boolean,
  111165. /**
  111166. * 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)
  111167. */
  111168. gammaSpace?: boolean,
  111169. /**
  111170. * Internal Use Only
  111171. */
  111172. reserved?: boolean);
  111173. /**
  111174. * Execute the current task
  111175. * @param scene defines the scene where you want your assets to be loaded
  111176. * @param onSuccess is a callback called when the task is successfully executed
  111177. * @param onError is a callback called if an error occurs
  111178. */
  111179. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  111180. }
  111181. /**
  111182. * This class can be used to easily import assets into a scene
  111183. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  111184. */
  111185. export class AssetsManager {
  111186. private _scene;
  111187. private _isLoading;
  111188. protected _tasks: AbstractAssetTask[];
  111189. protected _waitingTasksCount: number;
  111190. protected _totalTasksCount: number;
  111191. /**
  111192. * Callback called when all tasks are processed
  111193. */
  111194. onFinish: (tasks: AbstractAssetTask[]) => void;
  111195. /**
  111196. * Callback called when a task is successful
  111197. */
  111198. onTaskSuccess: (task: AbstractAssetTask) => void;
  111199. /**
  111200. * Callback called when a task had an error
  111201. */
  111202. onTaskError: (task: AbstractAssetTask) => void;
  111203. /**
  111204. * Callback called when a task is done (whatever the result is)
  111205. */
  111206. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  111207. /**
  111208. * Observable called when all tasks are processed
  111209. */
  111210. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  111211. /**
  111212. * Observable called when a task had an error
  111213. */
  111214. onTaskErrorObservable: Observable<AbstractAssetTask>;
  111215. /**
  111216. * Observable called when a task is successful
  111217. */
  111218. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  111219. /**
  111220. * Observable called when a task is done (whatever the result is)
  111221. */
  111222. onProgressObservable: Observable<IAssetsProgressEvent>;
  111223. /**
  111224. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  111225. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  111226. */
  111227. useDefaultLoadingScreen: boolean;
  111228. /**
  111229. * Creates a new AssetsManager
  111230. * @param scene defines the scene to work on
  111231. */
  111232. constructor(scene: Scene);
  111233. /**
  111234. * Add a MeshAssetTask to the list of active tasks
  111235. * @param taskName defines the name of the new task
  111236. * @param meshesNames defines the name of meshes to load
  111237. * @param rootUrl defines the root url to use to locate files
  111238. * @param sceneFilename defines the filename of the scene file
  111239. * @returns a new MeshAssetTask object
  111240. */
  111241. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  111242. /**
  111243. * Add a TextFileAssetTask to the list of active tasks
  111244. * @param taskName defines the name of the new task
  111245. * @param url defines the url of the file to load
  111246. * @returns a new TextFileAssetTask object
  111247. */
  111248. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  111249. /**
  111250. * Add a BinaryFileAssetTask to the list of active tasks
  111251. * @param taskName defines the name of the new task
  111252. * @param url defines the url of the file to load
  111253. * @returns a new BinaryFileAssetTask object
  111254. */
  111255. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  111256. /**
  111257. * Add a ImageAssetTask to the list of active tasks
  111258. * @param taskName defines the name of the new task
  111259. * @param url defines the url of the file to load
  111260. * @returns a new ImageAssetTask object
  111261. */
  111262. addImageTask(taskName: string, url: string): ImageAssetTask;
  111263. /**
  111264. * Add a TextureAssetTask to the list of active tasks
  111265. * @param taskName defines the name of the new task
  111266. * @param url defines the url of the file to load
  111267. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111268. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  111269. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  111270. * @returns a new TextureAssetTask object
  111271. */
  111272. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  111273. /**
  111274. * Add a CubeTextureAssetTask to the list of active tasks
  111275. * @param taskName defines the name of the new task
  111276. * @param url defines the url of the file to load
  111277. * @param extensions defines the extension to use to load the cube map (can be null)
  111278. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111279. * @param files defines the list of files to load (can be null)
  111280. * @returns a new CubeTextureAssetTask object
  111281. */
  111282. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  111283. /**
  111284. *
  111285. * Add a HDRCubeTextureAssetTask to the list of active tasks
  111286. * @param taskName defines the name of the new task
  111287. * @param url defines the url of the file to load
  111288. * @param size defines the size you want for the cubemap (can be null)
  111289. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  111290. * @param generateHarmonics defines if you want to automatically generate (true by default)
  111291. * @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)
  111292. * @param reserved Internal use only
  111293. * @returns a new HDRCubeTextureAssetTask object
  111294. */
  111295. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  111296. /**
  111297. * Remove a task from the assets manager.
  111298. * @param task the task to remove
  111299. */
  111300. removeTask(task: AbstractAssetTask): void;
  111301. private _decreaseWaitingTasksCount;
  111302. private _runTask;
  111303. /**
  111304. * Reset the AssetsManager and remove all tasks
  111305. * @return the current instance of the AssetsManager
  111306. */
  111307. reset(): AssetsManager;
  111308. /**
  111309. * Start the loading process
  111310. * @return the current instance of the AssetsManager
  111311. */
  111312. load(): AssetsManager;
  111313. }
  111314. }
  111315. declare module BABYLON {
  111316. /**
  111317. * Wrapper class for promise with external resolve and reject.
  111318. */
  111319. export class Deferred<T> {
  111320. /**
  111321. * The promise associated with this deferred object.
  111322. */
  111323. readonly promise: Promise<T>;
  111324. private _resolve;
  111325. private _reject;
  111326. /**
  111327. * The resolve method of the promise associated with this deferred object.
  111328. */
  111329. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  111330. /**
  111331. * The reject method of the promise associated with this deferred object.
  111332. */
  111333. readonly reject: (reason?: any) => void;
  111334. /**
  111335. * Constructor for this deferred object.
  111336. */
  111337. constructor();
  111338. }
  111339. }
  111340. declare module BABYLON {
  111341. /**
  111342. * Class used to help managing file picking and drag'n'drop
  111343. */
  111344. export class FilesInput {
  111345. /**
  111346. * List of files ready to be loaded
  111347. */
  111348. static readonly FilesToLoad: {
  111349. [key: string]: File;
  111350. };
  111351. /**
  111352. * Callback called when a file is processed
  111353. */
  111354. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  111355. private _engine;
  111356. private _currentScene;
  111357. private _sceneLoadedCallback;
  111358. private _progressCallback;
  111359. private _additionalRenderLoopLogicCallback;
  111360. private _textureLoadingCallback;
  111361. private _startingProcessingFilesCallback;
  111362. private _onReloadCallback;
  111363. private _errorCallback;
  111364. private _elementToMonitor;
  111365. private _sceneFileToLoad;
  111366. private _filesToLoad;
  111367. /**
  111368. * Creates a new FilesInput
  111369. * @param engine defines the rendering engine
  111370. * @param scene defines the hosting scene
  111371. * @param sceneLoadedCallback callback called when scene is loaded
  111372. * @param progressCallback callback called to track progress
  111373. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  111374. * @param textureLoadingCallback callback called when a texture is loading
  111375. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  111376. * @param onReloadCallback callback called when a reload is requested
  111377. * @param errorCallback callback call if an error occurs
  111378. */
  111379. 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);
  111380. private _dragEnterHandler;
  111381. private _dragOverHandler;
  111382. private _dropHandler;
  111383. /**
  111384. * Calls this function to listen to drag'n'drop events on a specific DOM element
  111385. * @param elementToMonitor defines the DOM element to track
  111386. */
  111387. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  111388. /**
  111389. * Release all associated resources
  111390. */
  111391. dispose(): void;
  111392. private renderFunction;
  111393. private drag;
  111394. private drop;
  111395. private _traverseFolder;
  111396. private _processFiles;
  111397. /**
  111398. * Load files from a drop event
  111399. * @param event defines the drop event to use as source
  111400. */
  111401. loadFiles(event: any): void;
  111402. private _processReload;
  111403. /**
  111404. * Reload the current scene from the loaded files
  111405. */
  111406. reload(): void;
  111407. }
  111408. }
  111409. declare module BABYLON {
  111410. /**
  111411. * Defines the root class used to create scene optimization to use with SceneOptimizer
  111412. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111413. */
  111414. export class SceneOptimization {
  111415. /**
  111416. * Defines the priority of this optimization (0 by default which means first in the list)
  111417. */
  111418. priority: number;
  111419. /**
  111420. * Gets a string describing the action executed by the current optimization
  111421. * @returns description string
  111422. */
  111423. getDescription(): string;
  111424. /**
  111425. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111426. * @param scene defines the current scene where to apply this optimization
  111427. * @param optimizer defines the current optimizer
  111428. * @returns true if everything that can be done was applied
  111429. */
  111430. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111431. /**
  111432. * Creates the SceneOptimization object
  111433. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111434. * @param desc defines the description associated with the optimization
  111435. */
  111436. constructor(
  111437. /**
  111438. * Defines the priority of this optimization (0 by default which means first in the list)
  111439. */
  111440. priority?: number);
  111441. }
  111442. /**
  111443. * Defines an optimization used to reduce the size of render target textures
  111444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111445. */
  111446. export class TextureOptimization extends SceneOptimization {
  111447. /**
  111448. * Defines the priority of this optimization (0 by default which means first in the list)
  111449. */
  111450. priority: number;
  111451. /**
  111452. * 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
  111453. */
  111454. maximumSize: number;
  111455. /**
  111456. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111457. */
  111458. step: number;
  111459. /**
  111460. * Gets a string describing the action executed by the current optimization
  111461. * @returns description string
  111462. */
  111463. getDescription(): string;
  111464. /**
  111465. * Creates the TextureOptimization object
  111466. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111467. * @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
  111468. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111469. */
  111470. constructor(
  111471. /**
  111472. * Defines the priority of this optimization (0 by default which means first in the list)
  111473. */
  111474. priority?: number,
  111475. /**
  111476. * 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
  111477. */
  111478. maximumSize?: number,
  111479. /**
  111480. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  111481. */
  111482. step?: number);
  111483. /**
  111484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111485. * @param scene defines the current scene where to apply this optimization
  111486. * @param optimizer defines the current optimizer
  111487. * @returns true if everything that can be done was applied
  111488. */
  111489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111490. }
  111491. /**
  111492. * Defines an optimization used to increase or decrease the rendering resolution
  111493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111494. */
  111495. export class HardwareScalingOptimization extends SceneOptimization {
  111496. /**
  111497. * Defines the priority of this optimization (0 by default which means first in the list)
  111498. */
  111499. priority: number;
  111500. /**
  111501. * Defines the maximum scale to use (2 by default)
  111502. */
  111503. maximumScale: number;
  111504. /**
  111505. * Defines the step to use between two passes (0.5 by default)
  111506. */
  111507. step: number;
  111508. private _currentScale;
  111509. private _directionOffset;
  111510. /**
  111511. * Gets a string describing the action executed by the current optimization
  111512. * @return description string
  111513. */
  111514. getDescription(): string;
  111515. /**
  111516. * Creates the HardwareScalingOptimization object
  111517. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111518. * @param maximumScale defines the maximum scale to use (2 by default)
  111519. * @param step defines the step to use between two passes (0.5 by default)
  111520. */
  111521. constructor(
  111522. /**
  111523. * Defines the priority of this optimization (0 by default which means first in the list)
  111524. */
  111525. priority?: number,
  111526. /**
  111527. * Defines the maximum scale to use (2 by default)
  111528. */
  111529. maximumScale?: number,
  111530. /**
  111531. * Defines the step to use between two passes (0.5 by default)
  111532. */
  111533. step?: number);
  111534. /**
  111535. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111536. * @param scene defines the current scene where to apply this optimization
  111537. * @param optimizer defines the current optimizer
  111538. * @returns true if everything that can be done was applied
  111539. */
  111540. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111541. }
  111542. /**
  111543. * Defines an optimization used to remove shadows
  111544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111545. */
  111546. export class ShadowsOptimization extends SceneOptimization {
  111547. /**
  111548. * Gets a string describing the action executed by the current optimization
  111549. * @return description string
  111550. */
  111551. getDescription(): string;
  111552. /**
  111553. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111554. * @param scene defines the current scene where to apply this optimization
  111555. * @param optimizer defines the current optimizer
  111556. * @returns true if everything that can be done was applied
  111557. */
  111558. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111559. }
  111560. /**
  111561. * Defines an optimization used to turn post-processes off
  111562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111563. */
  111564. export class PostProcessesOptimization extends SceneOptimization {
  111565. /**
  111566. * Gets a string describing the action executed by the current optimization
  111567. * @return description string
  111568. */
  111569. getDescription(): string;
  111570. /**
  111571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111572. * @param scene defines the current scene where to apply this optimization
  111573. * @param optimizer defines the current optimizer
  111574. * @returns true if everything that can be done was applied
  111575. */
  111576. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111577. }
  111578. /**
  111579. * Defines an optimization used to turn lens flares off
  111580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111581. */
  111582. export class LensFlaresOptimization extends SceneOptimization {
  111583. /**
  111584. * Gets a string describing the action executed by the current optimization
  111585. * @return description string
  111586. */
  111587. getDescription(): string;
  111588. /**
  111589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111590. * @param scene defines the current scene where to apply this optimization
  111591. * @param optimizer defines the current optimizer
  111592. * @returns true if everything that can be done was applied
  111593. */
  111594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111595. }
  111596. /**
  111597. * Defines an optimization based on user defined callback.
  111598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111599. */
  111600. export class CustomOptimization extends SceneOptimization {
  111601. /**
  111602. * Callback called to apply the custom optimization.
  111603. */
  111604. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  111605. /**
  111606. * Callback called to get custom description
  111607. */
  111608. onGetDescription: () => string;
  111609. /**
  111610. * Gets a string describing the action executed by the current optimization
  111611. * @returns description string
  111612. */
  111613. getDescription(): string;
  111614. /**
  111615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111616. * @param scene defines the current scene where to apply this optimization
  111617. * @param optimizer defines the current optimizer
  111618. * @returns true if everything that can be done was applied
  111619. */
  111620. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111621. }
  111622. /**
  111623. * Defines an optimization used to turn particles off
  111624. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111625. */
  111626. export class ParticlesOptimization extends SceneOptimization {
  111627. /**
  111628. * Gets a string describing the action executed by the current optimization
  111629. * @return description string
  111630. */
  111631. getDescription(): string;
  111632. /**
  111633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111634. * @param scene defines the current scene where to apply this optimization
  111635. * @param optimizer defines the current optimizer
  111636. * @returns true if everything that can be done was applied
  111637. */
  111638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111639. }
  111640. /**
  111641. * Defines an optimization used to turn render targets off
  111642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111643. */
  111644. export class RenderTargetsOptimization extends SceneOptimization {
  111645. /**
  111646. * Gets a string describing the action executed by the current optimization
  111647. * @return description string
  111648. */
  111649. getDescription(): string;
  111650. /**
  111651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111652. * @param scene defines the current scene where to apply this optimization
  111653. * @param optimizer defines the current optimizer
  111654. * @returns true if everything that can be done was applied
  111655. */
  111656. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  111657. }
  111658. /**
  111659. * Defines an optimization used to merge meshes with compatible materials
  111660. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111661. */
  111662. export class MergeMeshesOptimization extends SceneOptimization {
  111663. private static _UpdateSelectionTree;
  111664. /**
  111665. * Gets or sets a boolean which defines if optimization octree has to be updated
  111666. */
  111667. /**
  111668. * Gets or sets a boolean which defines if optimization octree has to be updated
  111669. */
  111670. static UpdateSelectionTree: boolean;
  111671. /**
  111672. * Gets a string describing the action executed by the current optimization
  111673. * @return description string
  111674. */
  111675. getDescription(): string;
  111676. private _canBeMerged;
  111677. /**
  111678. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  111679. * @param scene defines the current scene where to apply this optimization
  111680. * @param optimizer defines the current optimizer
  111681. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  111682. * @returns true if everything that can be done was applied
  111683. */
  111684. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  111685. }
  111686. /**
  111687. * Defines a list of options used by SceneOptimizer
  111688. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111689. */
  111690. export class SceneOptimizerOptions {
  111691. /**
  111692. * Defines the target frame rate to reach (60 by default)
  111693. */
  111694. targetFrameRate: number;
  111695. /**
  111696. * Defines the interval between two checkes (2000ms by default)
  111697. */
  111698. trackerDuration: number;
  111699. /**
  111700. * Gets the list of optimizations to apply
  111701. */
  111702. optimizations: SceneOptimization[];
  111703. /**
  111704. * Creates a new list of options used by SceneOptimizer
  111705. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  111706. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  111707. */
  111708. constructor(
  111709. /**
  111710. * Defines the target frame rate to reach (60 by default)
  111711. */
  111712. targetFrameRate?: number,
  111713. /**
  111714. * Defines the interval between two checkes (2000ms by default)
  111715. */
  111716. trackerDuration?: number);
  111717. /**
  111718. * Add a new optimization
  111719. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  111720. * @returns the current SceneOptimizerOptions
  111721. */
  111722. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  111723. /**
  111724. * Add a new custom optimization
  111725. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  111726. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  111727. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  111728. * @returns the current SceneOptimizerOptions
  111729. */
  111730. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  111731. /**
  111732. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  111733. * @param targetFrameRate defines the target frame rate (60 by default)
  111734. * @returns a SceneOptimizerOptions object
  111735. */
  111736. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111737. /**
  111738. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  111739. * @param targetFrameRate defines the target frame rate (60 by default)
  111740. * @returns a SceneOptimizerOptions object
  111741. */
  111742. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111743. /**
  111744. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  111745. * @param targetFrameRate defines the target frame rate (60 by default)
  111746. * @returns a SceneOptimizerOptions object
  111747. */
  111748. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  111749. }
  111750. /**
  111751. * Class used to run optimizations in order to reach a target frame rate
  111752. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  111753. */
  111754. export class SceneOptimizer implements IDisposable {
  111755. private _isRunning;
  111756. private _options;
  111757. private _scene;
  111758. private _currentPriorityLevel;
  111759. private _targetFrameRate;
  111760. private _trackerDuration;
  111761. private _currentFrameRate;
  111762. private _sceneDisposeObserver;
  111763. private _improvementMode;
  111764. /**
  111765. * Defines an observable called when the optimizer reaches the target frame rate
  111766. */
  111767. onSuccessObservable: Observable<SceneOptimizer>;
  111768. /**
  111769. * Defines an observable called when the optimizer enables an optimization
  111770. */
  111771. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  111772. /**
  111773. * Defines an observable called when the optimizer is not able to reach the target frame rate
  111774. */
  111775. onFailureObservable: Observable<SceneOptimizer>;
  111776. /**
  111777. * Gets a boolean indicating if the optimizer is in improvement mode
  111778. */
  111779. readonly isInImprovementMode: boolean;
  111780. /**
  111781. * Gets the current priority level (0 at start)
  111782. */
  111783. readonly currentPriorityLevel: number;
  111784. /**
  111785. * Gets the current frame rate checked by the SceneOptimizer
  111786. */
  111787. readonly currentFrameRate: number;
  111788. /**
  111789. * Gets or sets the current target frame rate (60 by default)
  111790. */
  111791. /**
  111792. * Gets or sets the current target frame rate (60 by default)
  111793. */
  111794. targetFrameRate: number;
  111795. /**
  111796. * Gets or sets the current interval between two checks (every 2000ms by default)
  111797. */
  111798. /**
  111799. * Gets or sets the current interval between two checks (every 2000ms by default)
  111800. */
  111801. trackerDuration: number;
  111802. /**
  111803. * Gets the list of active optimizations
  111804. */
  111805. readonly optimizations: SceneOptimization[];
  111806. /**
  111807. * Creates a new SceneOptimizer
  111808. * @param scene defines the scene to work on
  111809. * @param options defines the options to use with the SceneOptimizer
  111810. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  111811. * @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)
  111812. */
  111813. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  111814. /**
  111815. * Stops the current optimizer
  111816. */
  111817. stop(): void;
  111818. /**
  111819. * Reset the optimizer to initial step (current priority level = 0)
  111820. */
  111821. reset(): void;
  111822. /**
  111823. * Start the optimizer. By default it will try to reach a specific framerate
  111824. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  111825. */
  111826. start(): void;
  111827. private _checkCurrentState;
  111828. /**
  111829. * Release all resources
  111830. */
  111831. dispose(): void;
  111832. /**
  111833. * Helper function to create a SceneOptimizer with one single line of code
  111834. * @param scene defines the scene to work on
  111835. * @param options defines the options to use with the SceneOptimizer
  111836. * @param onSuccess defines a callback to call on success
  111837. * @param onFailure defines a callback to call on failure
  111838. * @returns the new SceneOptimizer object
  111839. */
  111840. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  111841. }
  111842. }
  111843. declare module BABYLON {
  111844. /**
  111845. * Class used to serialize a scene into a string
  111846. */
  111847. export class SceneSerializer {
  111848. /**
  111849. * Clear cache used by a previous serialization
  111850. */
  111851. static ClearCache(): void;
  111852. /**
  111853. * Serialize a scene into a JSON compatible object
  111854. * @param scene defines the scene to serialize
  111855. * @returns a JSON compatible object
  111856. */
  111857. static Serialize(scene: Scene): any;
  111858. /**
  111859. * Serialize a mesh into a JSON compatible object
  111860. * @param toSerialize defines the mesh to serialize
  111861. * @param withParents defines if parents must be serialized as well
  111862. * @param withChildren defines if children must be serialized as well
  111863. * @returns a JSON compatible object
  111864. */
  111865. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  111866. }
  111867. }
  111868. declare module BABYLON {
  111869. /**
  111870. * This represents the different options avilable for the video capture.
  111871. */
  111872. export interface VideoRecorderOptions {
  111873. /** Defines the mime type of the video */
  111874. mimeType: string;
  111875. /** Defines the video the video should be recorded at */
  111876. fps: number;
  111877. /** Defines the chunk size for the recording data */
  111878. recordChunckSize: number;
  111879. /** The audio tracks to attach to the record */
  111880. audioTracks?: MediaStreamTrack[];
  111881. }
  111882. /**
  111883. * This can helps recording videos from BabylonJS.
  111884. * This is based on the available WebRTC functionalities of the browser.
  111885. *
  111886. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  111887. */
  111888. export class VideoRecorder {
  111889. private static readonly _defaultOptions;
  111890. /**
  111891. * Returns wehther or not the VideoRecorder is available in your browser.
  111892. * @param engine Defines the Babylon Engine to check the support for
  111893. * @returns true if supported otherwise false
  111894. */
  111895. static IsSupported(engine: Engine): boolean;
  111896. private readonly _options;
  111897. private _canvas;
  111898. private _mediaRecorder;
  111899. private _recordedChunks;
  111900. private _fileName;
  111901. private _resolve;
  111902. private _reject;
  111903. /**
  111904. * True wether a recording is already in progress.
  111905. */
  111906. readonly isRecording: boolean;
  111907. /**
  111908. * Create a new VideoCapture object which can help converting what you see in Babylon to
  111909. * a video file.
  111910. * @param engine Defines the BabylonJS Engine you wish to record
  111911. * @param options Defines options that can be used to customized the capture
  111912. */
  111913. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  111914. /**
  111915. * Stops the current recording before the default capture timeout passed in the startRecording
  111916. * functions.
  111917. */
  111918. stopRecording(): void;
  111919. /**
  111920. * Starts recording the canvas for a max duration specified in parameters.
  111921. * @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.
  111922. * @param maxDuration Defines the maximum recording time in seconds.
  111923. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  111924. * @return a promise callback at the end of the recording with the video data in Blob.
  111925. */
  111926. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  111927. /**
  111928. * Releases internal resources used during the recording.
  111929. */
  111930. dispose(): void;
  111931. private _handleDataAvailable;
  111932. private _handleError;
  111933. private _handleStop;
  111934. }
  111935. }
  111936. declare module BABYLON {
  111937. /**
  111938. * Helper class to push actions to a pool of workers.
  111939. */
  111940. export class WorkerPool implements IDisposable {
  111941. private _workerInfos;
  111942. private _pendingActions;
  111943. /**
  111944. * Constructor
  111945. * @param workers Array of workers to use for actions
  111946. */
  111947. constructor(workers: Array<Worker>);
  111948. /**
  111949. * Terminates all workers and clears any pending actions.
  111950. */
  111951. dispose(): void;
  111952. /**
  111953. * Pushes an action to the worker pool. If all the workers are active, the action will be
  111954. * pended until a worker has completed its action.
  111955. * @param action The action to perform. Call onComplete when the action is complete.
  111956. */
  111957. push(action: (worker: Worker, onComplete: () => void) => void): void;
  111958. private _execute;
  111959. }
  111960. }
  111961. declare module BABYLON {
  111962. /**
  111963. * Class containing a set of static utilities functions for screenshots
  111964. */
  111965. export class ScreenshotTools {
  111966. /**
  111967. * Captures a screenshot of the current rendering
  111968. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111969. * @param engine defines the rendering engine
  111970. * @param camera defines the source camera
  111971. * @param size This parameter can be set to a single number or to an object with the
  111972. * following (optional) properties: precision, width, height. If a single number is passed,
  111973. * it will be used for both width and height. If an object is passed, the screenshot size
  111974. * will be derived from the parameters. The precision property is a multiplier allowing
  111975. * rendering at a higher or lower resolution
  111976. * @param successCallback defines the callback receives a single parameter which contains the
  111977. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111978. * src parameter of an <img> to display it
  111979. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  111980. * Check your browser for supported MIME types
  111981. */
  111982. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  111983. /**
  111984. * Generates an image screenshot from the specified camera.
  111985. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  111986. * @param engine The engine to use for rendering
  111987. * @param camera The camera to use for rendering
  111988. * @param size This parameter can be set to a single number or to an object with the
  111989. * following (optional) properties: precision, width, height. If a single number is passed,
  111990. * it will be used for both width and height. If an object is passed, the screenshot size
  111991. * will be derived from the parameters. The precision property is a multiplier allowing
  111992. * rendering at a higher or lower resolution
  111993. * @param successCallback The callback receives a single parameter which contains the
  111994. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  111995. * src parameter of an <img> to display it
  111996. * @param mimeType The MIME type of the screenshot image (default: image/png).
  111997. * Check your browser for supported MIME types
  111998. * @param samples Texture samples (default: 1)
  111999. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  112000. * @param fileName A name for for the downloaded file.
  112001. */
  112002. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  112003. }
  112004. }
  112005. declare module BABYLON {
  112006. /**
  112007. * A cursor which tracks a point on a path
  112008. */
  112009. export class PathCursor {
  112010. private path;
  112011. /**
  112012. * Stores path cursor callbacks for when an onchange event is triggered
  112013. */
  112014. private _onchange;
  112015. /**
  112016. * The value of the path cursor
  112017. */
  112018. value: number;
  112019. /**
  112020. * The animation array of the path cursor
  112021. */
  112022. animations: Animation[];
  112023. /**
  112024. * Initializes the path cursor
  112025. * @param path The path to track
  112026. */
  112027. constructor(path: Path2);
  112028. /**
  112029. * Gets the cursor point on the path
  112030. * @returns A point on the path cursor at the cursor location
  112031. */
  112032. getPoint(): Vector3;
  112033. /**
  112034. * Moves the cursor ahead by the step amount
  112035. * @param step The amount to move the cursor forward
  112036. * @returns This path cursor
  112037. */
  112038. moveAhead(step?: number): PathCursor;
  112039. /**
  112040. * Moves the cursor behind by the step amount
  112041. * @param step The amount to move the cursor back
  112042. * @returns This path cursor
  112043. */
  112044. moveBack(step?: number): PathCursor;
  112045. /**
  112046. * Moves the cursor by the step amount
  112047. * If the step amount is greater than one, an exception is thrown
  112048. * @param step The amount to move the cursor
  112049. * @returns This path cursor
  112050. */
  112051. move(step: number): PathCursor;
  112052. /**
  112053. * Ensures that the value is limited between zero and one
  112054. * @returns This path cursor
  112055. */
  112056. private ensureLimits;
  112057. /**
  112058. * Runs onchange callbacks on change (used by the animation engine)
  112059. * @returns This path cursor
  112060. */
  112061. private raiseOnChange;
  112062. /**
  112063. * Executes a function on change
  112064. * @param f A path cursor onchange callback
  112065. * @returns This path cursor
  112066. */
  112067. onchange(f: (cursor: PathCursor) => void): PathCursor;
  112068. }
  112069. }
  112070. declare module BABYLON {
  112071. /** @hidden */
  112072. export var blurPixelShader: {
  112073. name: string;
  112074. shader: string;
  112075. };
  112076. }
  112077. declare module BABYLON {
  112078. /** @hidden */
  112079. export var bones300Declaration: {
  112080. name: string;
  112081. shader: string;
  112082. };
  112083. }
  112084. declare module BABYLON {
  112085. /** @hidden */
  112086. export var instances300Declaration: {
  112087. name: string;
  112088. shader: string;
  112089. };
  112090. }
  112091. declare module BABYLON {
  112092. /** @hidden */
  112093. export var pointCloudVertexDeclaration: {
  112094. name: string;
  112095. shader: string;
  112096. };
  112097. }
  112098. // Mixins
  112099. interface Window {
  112100. mozIndexedDB: IDBFactory;
  112101. webkitIndexedDB: IDBFactory;
  112102. msIndexedDB: IDBFactory;
  112103. webkitURL: typeof URL;
  112104. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  112105. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  112106. WebGLRenderingContext: WebGLRenderingContext;
  112107. MSGesture: MSGesture;
  112108. CANNON: any;
  112109. AudioContext: AudioContext;
  112110. webkitAudioContext: AudioContext;
  112111. PointerEvent: any;
  112112. Math: Math;
  112113. Uint8Array: Uint8ArrayConstructor;
  112114. Float32Array: Float32ArrayConstructor;
  112115. mozURL: typeof URL;
  112116. msURL: typeof URL;
  112117. VRFrameData: any; // WebVR, from specs 1.1
  112118. DracoDecoderModule: any;
  112119. setImmediate(handler: (...args: any[]) => void): number;
  112120. }
  112121. interface HTMLCanvasElement {
  112122. requestPointerLock(): void;
  112123. msRequestPointerLock?(): void;
  112124. mozRequestPointerLock?(): void;
  112125. webkitRequestPointerLock?(): void;
  112126. /** Track wether a record is in progress */
  112127. isRecording: boolean;
  112128. /** Capture Stream method defined by some browsers */
  112129. captureStream(fps?: number): MediaStream;
  112130. }
  112131. interface CanvasRenderingContext2D {
  112132. msImageSmoothingEnabled: boolean;
  112133. }
  112134. interface MouseEvent {
  112135. mozMovementX: number;
  112136. mozMovementY: number;
  112137. webkitMovementX: number;
  112138. webkitMovementY: number;
  112139. msMovementX: number;
  112140. msMovementY: number;
  112141. }
  112142. interface Navigator {
  112143. mozGetVRDevices: (any: any) => any;
  112144. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112145. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112146. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  112147. webkitGetGamepads(): Gamepad[];
  112148. msGetGamepads(): Gamepad[];
  112149. webkitGamepads(): Gamepad[];
  112150. }
  112151. interface HTMLVideoElement {
  112152. mozSrcObject: any;
  112153. }
  112154. interface Math {
  112155. fround(x: number): number;
  112156. imul(a: number, b: number): number;
  112157. }
  112158. interface WebGLProgram {
  112159. context?: WebGLRenderingContext;
  112160. vertexShader?: WebGLShader;
  112161. fragmentShader?: WebGLShader;
  112162. isParallelCompiled: boolean;
  112163. onCompiled?: () => void;
  112164. }
  112165. interface WebGLRenderingContext {
  112166. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  112167. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  112168. vertexAttribDivisor(index: number, divisor: number): void;
  112169. createVertexArray(): any;
  112170. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  112171. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  112172. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  112173. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  112174. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  112175. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  112176. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  112177. // Queries
  112178. createQuery(): WebGLQuery;
  112179. deleteQuery(query: WebGLQuery): void;
  112180. beginQuery(target: number, query: WebGLQuery): void;
  112181. endQuery(target: number): void;
  112182. getQueryParameter(query: WebGLQuery, pname: number): any;
  112183. getQuery(target: number, pname: number): any;
  112184. MAX_SAMPLES: number;
  112185. RGBA8: number;
  112186. READ_FRAMEBUFFER: number;
  112187. DRAW_FRAMEBUFFER: number;
  112188. UNIFORM_BUFFER: number;
  112189. HALF_FLOAT_OES: number;
  112190. RGBA16F: number;
  112191. RGBA32F: number;
  112192. R32F: number;
  112193. RG32F: number;
  112194. RGB32F: number;
  112195. R16F: number;
  112196. RG16F: number;
  112197. RGB16F: number;
  112198. RED: number;
  112199. RG: number;
  112200. R8: number;
  112201. RG8: number;
  112202. UNSIGNED_INT_24_8: number;
  112203. DEPTH24_STENCIL8: number;
  112204. /* Multiple Render Targets */
  112205. drawBuffers(buffers: number[]): void;
  112206. readBuffer(src: number): void;
  112207. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  112208. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  112209. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  112210. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  112211. // Occlusion Query
  112212. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  112213. ANY_SAMPLES_PASSED: number;
  112214. QUERY_RESULT_AVAILABLE: number;
  112215. QUERY_RESULT: number;
  112216. }
  112217. interface WebGLBuffer {
  112218. references: number;
  112219. capacity: number;
  112220. is32Bits: boolean;
  112221. }
  112222. interface WebGLProgram {
  112223. transformFeedback?: WebGLTransformFeedback | null;
  112224. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  112225. }
  112226. interface EXT_disjoint_timer_query {
  112227. QUERY_COUNTER_BITS_EXT: number;
  112228. TIME_ELAPSED_EXT: number;
  112229. TIMESTAMP_EXT: number;
  112230. GPU_DISJOINT_EXT: number;
  112231. QUERY_RESULT_EXT: number;
  112232. QUERY_RESULT_AVAILABLE_EXT: number;
  112233. queryCounterEXT(query: WebGLQuery, target: number): void;
  112234. createQueryEXT(): WebGLQuery;
  112235. beginQueryEXT(target: number, query: WebGLQuery): void;
  112236. endQueryEXT(target: number): void;
  112237. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  112238. deleteQueryEXT(query: WebGLQuery): void;
  112239. }
  112240. interface WebGLUniformLocation {
  112241. _currentState: any;
  112242. }
  112243. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  112244. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  112245. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  112246. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112247. interface WebGLRenderingContext {
  112248. readonly RASTERIZER_DISCARD: number;
  112249. readonly DEPTH_COMPONENT24: number;
  112250. readonly TEXTURE_3D: number;
  112251. readonly TEXTURE_2D_ARRAY: number;
  112252. readonly TEXTURE_COMPARE_FUNC: number;
  112253. readonly TEXTURE_COMPARE_MODE: number;
  112254. readonly COMPARE_REF_TO_TEXTURE: number;
  112255. readonly TEXTURE_WRAP_R: number;
  112256. readonly HALF_FLOAT: number;
  112257. readonly RGB8: number;
  112258. readonly RED_INTEGER: number;
  112259. readonly RG_INTEGER: number;
  112260. readonly RGB_INTEGER: number;
  112261. readonly RGBA_INTEGER: number;
  112262. readonly R8_SNORM: number;
  112263. readonly RG8_SNORM: number;
  112264. readonly RGB8_SNORM: number;
  112265. readonly RGBA8_SNORM: number;
  112266. readonly R8I: number;
  112267. readonly RG8I: number;
  112268. readonly RGB8I: number;
  112269. readonly RGBA8I: number;
  112270. readonly R8UI: number;
  112271. readonly RG8UI: number;
  112272. readonly RGB8UI: number;
  112273. readonly RGBA8UI: number;
  112274. readonly R16I: number;
  112275. readonly RG16I: number;
  112276. readonly RGB16I: number;
  112277. readonly RGBA16I: number;
  112278. readonly R16UI: number;
  112279. readonly RG16UI: number;
  112280. readonly RGB16UI: number;
  112281. readonly RGBA16UI: number;
  112282. readonly R32I: number;
  112283. readonly RG32I: number;
  112284. readonly RGB32I: number;
  112285. readonly RGBA32I: number;
  112286. readonly R32UI: number;
  112287. readonly RG32UI: number;
  112288. readonly RGB32UI: number;
  112289. readonly RGBA32UI: number;
  112290. readonly RGB10_A2UI: number;
  112291. readonly R11F_G11F_B10F: number;
  112292. readonly RGB9_E5: number;
  112293. readonly RGB10_A2: number;
  112294. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  112295. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  112296. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  112297. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  112298. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  112299. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  112300. 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;
  112301. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  112302. readonly TRANSFORM_FEEDBACK: number;
  112303. readonly INTERLEAVED_ATTRIBS: number;
  112304. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  112305. createTransformFeedback(): WebGLTransformFeedback;
  112306. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  112307. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  112308. beginTransformFeedback(primitiveMode: number): void;
  112309. endTransformFeedback(): void;
  112310. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  112311. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112312. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112313. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  112314. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  112315. }
  112316. interface ImageBitmap {
  112317. readonly width: number;
  112318. readonly height: number;
  112319. close(): void;
  112320. }
  112321. interface WebGLQuery extends WebGLObject {
  112322. }
  112323. declare var WebGLQuery: {
  112324. prototype: WebGLQuery;
  112325. new(): WebGLQuery;
  112326. };
  112327. interface WebGLSampler extends WebGLObject {
  112328. }
  112329. declare var WebGLSampler: {
  112330. prototype: WebGLSampler;
  112331. new(): WebGLSampler;
  112332. };
  112333. interface WebGLSync extends WebGLObject {
  112334. }
  112335. declare var WebGLSync: {
  112336. prototype: WebGLSync;
  112337. new(): WebGLSync;
  112338. };
  112339. interface WebGLTransformFeedback extends WebGLObject {
  112340. }
  112341. declare var WebGLTransformFeedback: {
  112342. prototype: WebGLTransformFeedback;
  112343. new(): WebGLTransformFeedback;
  112344. };
  112345. interface WebGLVertexArrayObject extends WebGLObject {
  112346. }
  112347. declare var WebGLVertexArrayObject: {
  112348. prototype: WebGLVertexArrayObject;
  112349. new(): WebGLVertexArrayObject;
  112350. };
  112351. // Type definitions for WebVR API
  112352. // Project: https://w3c.github.io/webvr/
  112353. // Definitions by: six a <https://github.com/lostfictions>
  112354. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  112355. interface VRDisplay extends EventTarget {
  112356. /**
  112357. * Dictionary of capabilities describing the VRDisplay.
  112358. */
  112359. readonly capabilities: VRDisplayCapabilities;
  112360. /**
  112361. * z-depth defining the far plane of the eye view frustum
  112362. * enables mapping of values in the render target depth
  112363. * attachment to scene coordinates. Initially set to 10000.0.
  112364. */
  112365. depthFar: number;
  112366. /**
  112367. * z-depth defining the near plane of the eye view frustum
  112368. * enables mapping of values in the render target depth
  112369. * attachment to scene coordinates. Initially set to 0.01.
  112370. */
  112371. depthNear: number;
  112372. /**
  112373. * An identifier for this distinct VRDisplay. Used as an
  112374. * association point in the Gamepad API.
  112375. */
  112376. readonly displayId: number;
  112377. /**
  112378. * A display name, a user-readable name identifying it.
  112379. */
  112380. readonly displayName: string;
  112381. readonly isConnected: boolean;
  112382. readonly isPresenting: boolean;
  112383. /**
  112384. * If this VRDisplay supports room-scale experiences, the optional
  112385. * stage attribute contains details on the room-scale parameters.
  112386. */
  112387. readonly stageParameters: VRStageParameters | null;
  112388. /**
  112389. * Passing the value returned by `requestAnimationFrame` to
  112390. * `cancelAnimationFrame` will unregister the callback.
  112391. * @param handle Define the hanle of the request to cancel
  112392. */
  112393. cancelAnimationFrame(handle: number): void;
  112394. /**
  112395. * Stops presenting to the VRDisplay.
  112396. * @returns a promise to know when it stopped
  112397. */
  112398. exitPresent(): Promise<void>;
  112399. /**
  112400. * Return the current VREyeParameters for the given eye.
  112401. * @param whichEye Define the eye we want the parameter for
  112402. * @returns the eye parameters
  112403. */
  112404. getEyeParameters(whichEye: string): VREyeParameters;
  112405. /**
  112406. * Populates the passed VRFrameData with the information required to render
  112407. * the current frame.
  112408. * @param frameData Define the data structure to populate
  112409. * @returns true if ok otherwise false
  112410. */
  112411. getFrameData(frameData: VRFrameData): boolean;
  112412. /**
  112413. * Get the layers currently being presented.
  112414. * @returns the list of VR layers
  112415. */
  112416. getLayers(): VRLayer[];
  112417. /**
  112418. * Return a VRPose containing the future predicted pose of the VRDisplay
  112419. * when the current frame will be presented. The value returned will not
  112420. * change until JavaScript has returned control to the browser.
  112421. *
  112422. * The VRPose will contain the position, orientation, velocity,
  112423. * and acceleration of each of these properties.
  112424. * @returns the pose object
  112425. */
  112426. getPose(): VRPose;
  112427. /**
  112428. * Return the current instantaneous pose of the VRDisplay, with no
  112429. * prediction applied.
  112430. * @returns the current instantaneous pose
  112431. */
  112432. getImmediatePose(): VRPose;
  112433. /**
  112434. * The callback passed to `requestAnimationFrame` will be called
  112435. * any time a new frame should be rendered. When the VRDisplay is
  112436. * presenting the callback will be called at the native refresh
  112437. * rate of the HMD. When not presenting this function acts
  112438. * identically to how window.requestAnimationFrame acts. Content should
  112439. * make no assumptions of frame rate or vsync behavior as the HMD runs
  112440. * asynchronously from other displays and at differing refresh rates.
  112441. * @param callback Define the eaction to run next frame
  112442. * @returns the request handle it
  112443. */
  112444. requestAnimationFrame(callback: FrameRequestCallback): number;
  112445. /**
  112446. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  112447. * Repeat calls while already presenting will update the VRLayers being displayed.
  112448. * @param layers Define the list of layer to present
  112449. * @returns a promise to know when the request has been fulfilled
  112450. */
  112451. requestPresent(layers: VRLayer[]): Promise<void>;
  112452. /**
  112453. * Reset the pose for this display, treating its current position and
  112454. * orientation as the "origin/zero" values. VRPose.position,
  112455. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  112456. * updated when calling resetPose(). This should be called in only
  112457. * sitting-space experiences.
  112458. */
  112459. resetPose(): void;
  112460. /**
  112461. * The VRLayer provided to the VRDisplay will be captured and presented
  112462. * in the HMD. Calling this function has the same effect on the source
  112463. * canvas as any other operation that uses its source image, and canvases
  112464. * created without preserveDrawingBuffer set to true will be cleared.
  112465. * @param pose Define the pose to submit
  112466. */
  112467. submitFrame(pose?: VRPose): void;
  112468. }
  112469. declare var VRDisplay: {
  112470. prototype: VRDisplay;
  112471. new(): VRDisplay;
  112472. };
  112473. interface VRLayer {
  112474. leftBounds?: number[] | Float32Array | null;
  112475. rightBounds?: number[] | Float32Array | null;
  112476. source?: HTMLCanvasElement | null;
  112477. }
  112478. interface VRDisplayCapabilities {
  112479. readonly canPresent: boolean;
  112480. readonly hasExternalDisplay: boolean;
  112481. readonly hasOrientation: boolean;
  112482. readonly hasPosition: boolean;
  112483. readonly maxLayers: number;
  112484. }
  112485. interface VREyeParameters {
  112486. /** @deprecated */
  112487. readonly fieldOfView: VRFieldOfView;
  112488. readonly offset: Float32Array;
  112489. readonly renderHeight: number;
  112490. readonly renderWidth: number;
  112491. }
  112492. interface VRFieldOfView {
  112493. readonly downDegrees: number;
  112494. readonly leftDegrees: number;
  112495. readonly rightDegrees: number;
  112496. readonly upDegrees: number;
  112497. }
  112498. interface VRFrameData {
  112499. readonly leftProjectionMatrix: Float32Array;
  112500. readonly leftViewMatrix: Float32Array;
  112501. readonly pose: VRPose;
  112502. readonly rightProjectionMatrix: Float32Array;
  112503. readonly rightViewMatrix: Float32Array;
  112504. readonly timestamp: number;
  112505. }
  112506. interface VRPose {
  112507. readonly angularAcceleration: Float32Array | null;
  112508. readonly angularVelocity: Float32Array | null;
  112509. readonly linearAcceleration: Float32Array | null;
  112510. readonly linearVelocity: Float32Array | null;
  112511. readonly orientation: Float32Array | null;
  112512. readonly position: Float32Array | null;
  112513. readonly timestamp: number;
  112514. }
  112515. interface VRStageParameters {
  112516. sittingToStandingTransform?: Float32Array;
  112517. sizeX?: number;
  112518. sizeY?: number;
  112519. }
  112520. interface Navigator {
  112521. getVRDisplays(): Promise<VRDisplay[]>;
  112522. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  112523. }
  112524. interface Window {
  112525. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  112526. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  112527. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  112528. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112529. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  112530. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  112531. }
  112532. interface Gamepad {
  112533. readonly displayId: number;
  112534. }
  112535. interface XRDevice {
  112536. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  112537. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  112538. }
  112539. interface XRSession {
  112540. getInputSources(): Array<any>;
  112541. baseLayer: XRWebGLLayer;
  112542. requestFrameOfReference(type: string): Promise<void>;
  112543. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  112544. end(): Promise<void>;
  112545. requestAnimationFrame: Function;
  112546. addEventListener: Function;
  112547. }
  112548. interface XRSessionCreationOptions {
  112549. outputContext?: WebGLRenderingContext | null;
  112550. immersive?: boolean;
  112551. environmentIntegration?: boolean;
  112552. }
  112553. interface XRLayer {
  112554. getViewport: Function;
  112555. framebufferWidth: number;
  112556. framebufferHeight: number;
  112557. }
  112558. interface XRView {
  112559. projectionMatrix: Float32Array;
  112560. }
  112561. interface XRFrame {
  112562. getDevicePose: Function;
  112563. getInputPose: Function;
  112564. views: Array<XRView>;
  112565. baseLayer: XRLayer;
  112566. }
  112567. interface XRFrameOfReference {
  112568. }
  112569. interface XRWebGLLayer extends XRLayer {
  112570. framebuffer: WebGLFramebuffer;
  112571. }
  112572. declare var XRWebGLLayer: {
  112573. prototype: XRWebGLLayer;
  112574. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  112575. };